/// <summary> /// Creates a new ContextDimensionInfo. /// </summary> /// <param name="copy">The ContextDimensionInfo object to be copied.</param> public ContextDimensionInfo(ContextDimensionInfo copy) { this.Id = copy.Id; this.dimensionId = copy.dimensionId; this.type = copy.type; this.dimensionNode = copy.dimensionNode; //this is a shallow copy }
/// <summary> /// Creates a new ContextDimensionInfo. /// </summary> /// <param name="copy">The ContextDimensionInfo object to be copied.</param> public ContextDimensionInfo(ContextDimensionInfo copy) { this.Id = copy.Id; this.dimensionId = copy.dimensionId; this.type = copy.type; this.dimensionNode = copy.dimensionNode;//this is a shallow copy }
/// <summary> /// This method compares the values of two ContextDimensionInfo objects. /// Comparison order: /// (1) ID /// (2) DimensionID /// (3) Type /// </summary> /// <param name="s">The ContextDimensionInfo object.</param> /// <returns>Returns the comparison results.</returns> public int CompareValue(ContextDimensionInfo s) { int ret = Id.CompareTo(s.Id); if (ret != 0) { return(ret); } ret = dimensionId.CompareTo(s.dimensionId); if (ret != 0) { return(ret); } return(type.CompareTo(s.type)); }
/// <summary> /// This method sets the dimension info for the scenario. /// </summary> /// <param name="cdi">The ContextDimensionInfo.</param> public override void SetContextDimensionInfo(ContextDimensionInfo cdi) { DimensionInfo = cdi; }
/// <summary> /// Implemented only for Segment and Scenario derived classes. /// </summary> /// <param name="cdi">The ContextDimensionInfo.</param> public virtual void SetContextDimensionInfo(ContextDimensionInfo cdi) { }
/// <summary> /// This method sets the dimension info for the segment. /// </summary> /// <param name="cdi">The ContextDimensionInfo.</param> public override void SetContextDimensionInfo(ContextDimensionInfo cdi) { DimensionInfo = cdi; }
/// <summary> /// This method compares the values of two ContextDimensionInfo objects. /// Comparison order: /// (1) ID /// (2) DimensionID /// (3) Type /// </summary> /// <param name="s">The ContextDimensionInfo object.</param> /// <returns>Returns the comparison results.</returns> public int CompareValue(ContextDimensionInfo s) { int ret = Id.CompareTo( s.Id); if (ret != 0) return ret; ret = dimensionId.CompareTo(s.dimensionId); if (ret != 0) return ret; return type.CompareTo(s.type); }
/// <summary> /// Constructs a <see cref="ContextDimensionInfo"/> object from the /// parent <see cref="DimensionNode"/> of this <see cref="DimensionNode"/>. /// </summary> /// <returns>The newly constructed <see cref="ContextDimensionInfo"/>.</returns> public ContextDimensionInfo BuildContextInfo() { DimensionNode parentNode = GetParentDimensionTypeDimensionNode(); if (parentNode == null || parentNode.Id == this.Id ) return null; ContextDimensionInfo cdi = new ContextDimensionInfo(); cdi.Id = this.Id; cdi.dimensionId = parentNode.Id; cdi.type = ContextDimensionInfo.DimensionType.explicitMember; return cdi; }
private void WriteDimensionInfo(XmlElement parent, ContextDimensionInfo cdi, XmlElement root, XmlDocument doc, Taxonomy[] taxonomies) { if (taxonomies != null) { root.SetAttribute(string.Format(DocumentBase.NAME_FORMAT, DocumentBase.XMLNS, DocumentBase.XBRLDI_PREFIX), DocumentBase.XBRLDI_URI); //Add the dimension TI to the root attributes... Element dimensionEle; TaxonomyItem dimensionTI = GetMemberTaxonomyItem(cdi.dimensionId, taxonomies, out dimensionEle); if (dimensionTI != null) { root.SetAttribute(string.Format(DocumentBase.NAME_FORMAT, DocumentBase.XMLNS, dimensionTI.Namespace), dimensionTI.WebLocation); } else { //error return; } Element memberEle; TaxonomyItem memberTI = GetMemberTaxonomyItem(cdi.Id, taxonomies, out memberEle); if (memberTI != null) { root.SetAttribute(string.Format(DocumentBase.NAME_FORMAT, DocumentBase.XMLNS, memberTI.Namespace), memberTI.WebLocation); } else { //error return; } //need to find the member taxonomy item XmlElement innerEle = doc.CreateElement(DocumentBase.XBRLDI_PREFIX, EXPLICITMEMBER, DocumentBase.XBRLDI_URI); innerEle.SetAttribute(DIMENSION, string.Format(DocumentBase.NAME_FORMAT, dimensionTI.Namespace, dimensionEle.Name)); parent.AppendChild(innerEle); innerEle.InnerText = string.Format(DocumentBase.NAME_FORMAT, memberTI.Namespace, memberEle.Name); } else { //error } }
internal static bool TryCreateFromXml( XmlNode node, XmlNamespaceManager theManager, out ContextProperty cp, ref ArrayList errors ) { if ( errors == null ) { errors = new ArrayList(); } cp = new ContextProperty(); cp.ErrorList = errors; cp.ContextID = node.Attributes[ ID_ATTR ].Value; XmlNode entity = node.SelectSingleNode( "./link2:" + ENTITY, theManager ); if ( entity == null ) { if ( ( entity = node.SelectSingleNode( ENTITY ) ) == null ) { Common.WriteError( "XBRLParser.Error.MissingRequiredField", errors, "Entity" ); return false; } } XmlNode identifier = entity.SelectSingleNode( "./link2:" + IDENTIFIER, theManager ); if ( identifier == null ) { if ( ( identifier = entity.SelectSingleNode( "./" + IDENTIFIER ) ) == null ) { Common.WriteError( "XBRLParser.Error.MissingRequiredField", errors, "identifier" ); return false; } } cp.EntitySchema = identifier.Attributes[ SCHEME_ATTR ].Value; cp.EntityValue = identifier.InnerXml; XmlNode segments = entity.SelectSingleNode( "./link2:" + SEGMENT, theManager ); if ( segments == null ) { segments = entity.SelectSingleNode( "./" + SEGMENT ); } if ( segments != null ) { foreach ( XmlNode segment in segments.ChildNodes ) { if (segment is XmlComment) continue; bool createSegment = true; if (segment.LocalName.ToLower().Equals(EXPLICITMEMBER.ToLower()) && segment.NamespaceURI.Equals( DocumentBase.XBRLDI_URI) ) { //we have a dimension info string dimensionId=null; string valueId = segment.InnerXml.Replace( ":", "_"); foreach (XmlAttribute attr in segment.Attributes) { if (attr.Name.Equals(DIMENSION)) { dimensionId = attr.Value.Replace( ":", "_"); break; } } if (dimensionId != null) { Segment seg = new Segment(string.Empty, valueId, dimensionId, DocumentBase.XBRLDI_PREFIX, segment.NamespaceURI); ContextDimensionInfo di = new ContextDimensionInfo(); di.dimensionId = dimensionId; di.Id = valueId; seg.DimensionInfo = di; cp.AddSegment(seg); createSegment = false; } } if (createSegment) { cp.AddSegment(segment.Prefix, segment.InnerXml, segment.LocalName, segment.NamespaceURI); } } } XmlNode scenarios = node.SelectSingleNode( "./link2:" + SCENARIO, theManager ); if ( scenarios == null ) { scenarios = node.SelectSingleNode( "./" + SCENARIO ); } if ( scenarios != null ) { foreach ( XmlNode scenario in scenarios ) { bool createScenario = true; if (scenario.LocalName.ToLower().Equals(EXPLICITMEMBER.ToLower()) && scenario.NamespaceURI.Equals(DocumentBase.XBRLDI_URI)) { //we have a dimension info string dimensionId = null; string valueId = scenario.InnerXml.Replace(":", "_"); foreach (XmlAttribute attr in scenario.Attributes) { if (attr.Name.Equals(DIMENSION)) { dimensionId = attr.Value.Replace(":", "_"); break; } } if (dimensionId != null) { Scenario seg = new Scenario(string.Empty, valueId, dimensionId, DocumentBase.XBRLDI_PREFIX, scenario.NamespaceURI); ContextDimensionInfo di = new ContextDimensionInfo(); di.dimensionId = dimensionId; di.Id = valueId; seg.DimensionInfo = di; cp.AddScenario(seg); createScenario = false; } } if (createScenario) { cp.AddScenario(scenario.Prefix, scenario.InnerXml, scenario.LocalName, scenario.NamespaceURI); } } } // lastly, repopulate the time period XmlNode timePeriod = node.SelectSingleNode( "./link2:" + PERIOD, theManager ); if ( timePeriod == null ) { timePeriod = node.SelectSingleNode( "./" + PERIOD ); if ( timePeriod == null ) { Common.WriteError( "XBRLParser.Error.MissingRequiredField", errors, "TimePeriod" ); return false; } else { if ( !cp.ParsePeriods( timePeriod, theManager ) ) { return false; } } } else { if ( !cp.ParsePeriods( timePeriod, theManager ) ) { return false; } } return cp.IsValid(); }