Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of <see cref="Choice"/>.
        /// </summary>
        /// <param name="container">The <see cref="Choices"/> object to which this <see cref="Choice"/>
        ///  object belongs.</param>
        /// <param name="elem">The <see cref="Element"/> to which this <see cref="Choice"/> belongs.</param>
        ///  <param name="minOccurs">The "minOccurs" value for this <see cref="Choice"/>.</param>
        ///  <param name="maxOccurs">The "maxOccurs" value for this <see cref="Choice"/>.</param>
        public Choice(Choices container, Element elem, int minOccurs, int maxOccurs)
        {
            MyElement = elem;
            MinOccurances = minOccurs;
            MaxOccurances = maxOccurs;

            ParentContainer = container;

            //container.TheChoices.Add( this );

            MyElement.IsChoice = true;
            MyElement.UseChoiceIcon = true;
        }
Exemplo n.º 2
0
        internal Element CreateCopyForMerging()
        {
            Element ret = new Element(this, false);

            ret.labelInfo = null;
            ret.referenceInfo = null;

            return ret;
        }
Exemplo n.º 3
0
        public void Test_ElementsEqual()
        {
            Element p1 = new Element( "p1_id", "parent_name", "subst1" );
            p1.AddOptionals( "type1", false, PeriodType.duration, BalanceType.credit, false );
            Element p2 = new Element( "p1_id", "parent_name", "subst1" );
            p2.AddOptionals( "type1", false, PeriodType.duration, BalanceType.credit, false );

            Assert.IsTrue( p1.Equals( p2 ), "p1 != P2" );

            Element p3 = new Element( "p3_id", "parent_name", "subst1" );
            p3.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );
            p3.AddChild( p1 );

            Element p4 = new Element( "p3_id", "parent_name", "subst1" );
            p4.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );
            p4.AddChild( p1 );

            Assert.IsTrue( p3.Equals( p4 ), "p3 != p4" );
        }
Exemplo n.º 4
0
        public void ElementToXml()
        {
            Element p1 = new Element( "Parent1", "Parent1", "substGroup1" );
            p1.AddOptionals( "Test", true, Element.PeriodType.duration, Element.BalanceType.debit, false );

            Element c1 = new Element( "Child1", "Child1", "substGroup1" );
            c1.AddOptionals( "Test", true, Element.PeriodType.duration, Element.BalanceType.debit, false );

            p1.AddChild( c1 );
            p1.AddChildInfo(c1.Id, 1, 2);

            Element c2 = new Element( "Child2", "Child2", "substGroup1" );
            c2.AddOptionals( "Test", true, Element.PeriodType.duration, Element.BalanceType.debit, false );

            p1.AddChild( c2 );
            p1.AddChildInfo(c2.Id, 2, int.MaxValue);

            StringBuilder sb = new StringBuilder();

            p1.ToXmlString( 0, null, sb );

            string result = "<parentElement name=\"Parent1\" nillable=\"True\" abstract=\"False\" tuple=\"False\" type=\"Test\" substitutionGroup=\"substGroup1\" periodType=\"duration\" balanceType=\"debit\" minOccurs=\"0\" maxOccurs=\""+Int32.MaxValue+"\">\r\n" +
                                  "\t<element name=\"Child1\" nillable=\"True\" abstract=\"False\" tuple=\"False\" type=\"Test\" substitutionGroup=\"substGroup1\" periodType=\"duration\" balanceType=\"debit\" minOccurs=\"1\" maxOccurs=\"2\"/>\r\n" +
                                  "\t<element name=\"Child2\" nillable=\"True\" abstract=\"False\" tuple=\"False\" type=\"Test\" substitutionGroup=\"substGroup1\" periodType=\"duration\" balanceType=\"debit\" minOccurs=\"2\" maxOccurs=\""+Int32.MaxValue+"\"/>\r\n" +
                                  "</parentElement>\r\n";

            Console.WriteLine( "*** Element.ToXmlString() ***" );
            Console.WriteLine( sb.ToString() );
            Console.WriteLine( "*** Element.ToXmlString() End ***" );

            Assert.AreEqual( result, sb.ToString() );

            XmlDocument doc = new XmlDocument();

            doc.LoadXml( result );
        }
Exemplo n.º 5
0
 /// <summary>
 /// Overloaded.  Creates a new <see cref="HtmlNode"/>/
 /// </summary>
 /// <param name="e">The <see cref="Element"/> whose cloned element collection is to be search for 
 /// and <see cref="Element"/> whose parent id is equal to <paramref name="parentId"/>.</param>
 /// <param name="level">The label to be assigned to the newly created <see cref="HtmlNode"/>.</param>
 /// <param name="parentId">The parent id for which the element's in the cloned element collection of 
 /// <paramref name="e"/> is to be searched.</param>
 public HtmlNode(Element e, int level, string parentId)
     : base(e, parentId)
 {
     Depth = level;
 }
Exemplo n.º 6
0
        private bool LoadChoices( XmlNode choice, Element parent, ref int numErrors )
        {
            // create the new choice
            int minOccurs = 0;
            int maxOccurs = 1;

            GetOccurances( (XmlElement)choice, out minOccurs, out maxOccurs );

            if ( parent.ChoiceContainer != null )
            {
                Common.WriteError( "XBRLParser.Error.ChoiceContainerFull", errorList, parent.Id );

                ++numErrors;
                return false;
            }

            parent.ChoiceContainer = new Choices( minOccurs, maxOccurs );

            foreach ( XmlElement child in choice )
            {
                int elemMinOccurs = 0;
                int elemMaxOccurs = 0;

                Element e = LoadChild( child, parent, ref numErrors );
                GetOccurances( child, out elemMinOccurs, out elemMaxOccurs );

                if ( e == null )
                {
                    return false;
                }

                parent.ChoiceContainer.TheChoices.Add( new Choice( parent.ChoiceContainer, e, elemMinOccurs, elemMaxOccurs ) );
            }

            return true;
        }
Exemplo n.º 7
0
        private Element LoadChild( XmlElement child, Element parent, ref int numErrors )
        {
            string elementRef = null;

            if ( !Common.GetAttribute( child, REF_TAG, ref elementRef, null ) )
            {
                if ( child.Name == "attribute" )
                {
                    Common.WriteWarning( "Tuple has an attribute defined and Parser does not read attributes " + child.OuterXml, errorList, child.OuterXml );
                    return null;
                }

                // write our own error
                Common.WriteError( "XBRLParser.Warning.NoTagForLocator2", errorList, REF_TAG, child.OuterXml );
                ++numErrors;
                return null;
            }

            // lookup the element
            string[] refStrings = elementRef.Split( ':' );
            //
            //				if ( refStrings.Length != 2 )
            //				{
            //					Common.WriteError( "XBRLParser.Warning.IncorrectRefFormat", errorList, elementRef, refStrings.Length.ToString(), child.OuterXml );
            //					++numErrors;
            //					continue;
            //				}

            string ns = theManager.LookupNamespace( theManager.NameTable.Get( refStrings[0] ) );

            if ( ns == null )
            {
                Common.WriteError( "XBRLParser.Warning.IncorrectChildNamespace", errorList, new string[] { refStrings[0], elementRef, schemaFile, child.OuterXml } );
                ++numErrors;
                return null;
            }

            string elemId = elementRef.Replace( ':', '_' );

            Element e = allElements[elemId] as Element;

            // TODO: stupid check?
            // No, not stupid - we need to bind the element that is defined in another schema to this parent,
            // but we have no way to get the other element
            if ( ns != targetNamespace )
            {
                // see if it's in one of the dependant taxonomies
                foreach ( Taxonomy t in dependantTaxonomies )
                {
                    // see if it's in all elements, if so, return it
                    if (t.allElements == null) continue;
                    if ( (e = t.allElements[elemId] as Element) != null )
                    {
                        break;
                    }
                }

                if ( e == null )
                {

                    if (this.TopLevelTaxonomy != null)
                    {
                        foreach (Taxonomy t in TopLevelTaxonomy.dependantTaxonomies)
                        {
                            // see if it's in all elements, if so, return it
                            if (t.allElements == null) continue;
                            if ((e = t.allElements[elemId] as Element) != null)
                            {
                                break;
                            }
                        }
                    }

                    if (e == null)
                    {
                        // if we made it here there is no element that matches
                        Common.WriteError("XBRLParser.Warning.NotSupportedRemoteLinks", errorList, new string[] { refStrings[0], elementRef, schemaFile, child.OuterXml });
                        ++numErrors;
                        return null;
                    }
                }
            }

            // lookup the child node in the element table
            // this ensures we always get the element, even though it may have been removed from the

            if ( e == null )
            {
                if ( refStrings.Length == 1 )
                {
                    Common.WriteError( "XBRLParser.Warning.IncorrectRefFormat", errorList, elementRef, refStrings.Length.ToString(), child.OuterXml );
                    ++numErrors;
                    return null;
                }
                else
                {
                    e = allElements[refStrings[1]] as Element;

                    if ( e == null )
                    {
                        Common.WriteError( "XBRLParser.Error.ComplexElementsNotSupported", errorList, elemId, elementRef );
                        ++numErrors;
                        return null;
                    }
                }
            }

            //e.Parent = parent;

            parent.AddChild( e );

            return e;
        }
Exemplo n.º 8
0
        private bool BindReferenceToElement( Element e )
        {
            ReferenceLocator rl = null;

            if ( referenceTable != null )
            {

                rl = referenceTable[e.Id] as ReferenceLocator;

                if ( rl == null )
                {

                    //Common.WriteInfo( "XBRLParser.Warning.NoReferenceForElement", errorList, e.Id );
                    return true;
                }

                e.ReferenceInfo = rl;
            }
            return true;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Checks if an markup's element is a duration type, and attempts to parse the markup value from a w3c duration.
        /// </summary>
        /// <param name="el">The <see cref="Element"/> whose type should be checked for duration.</param>
        /// <param name="w3cDuration">The markup value which may or may not be a w3c duration.</param>
        /// <param name="newValue">The verbose representation of the w3c duration.</param>
        /// <returns>True on success or false on fail.</returns>
        /// <see>http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#duration</see>
        private bool TryGetW3CDuration( Element el, string w3cDuration, out string newValue )
        {
            newValue = string.Empty;

            if( el == null )
                return false;

            bool isDurationElement = string.Equals( el.OrigElementType, "xbrli:durationItemType" ) || string.Equals( el.OrigElementType, "us-types:durationStringItemType" );
            if( !isDurationElement )
                return false;

            if( !w3cDurationRegex.IsMatch( w3cDuration ) )
                return false;

            Match m = w3cDurationRegex.Match( w3cDuration );
            StringBuilder durationString = new StringBuilder();
            if( m.Groups[ "minus" ].Success )
            {
                durationString.Append( "minus " );
            }

            if( m.Groups[ "years" ].Success )
            {
                int years = int.Parse( m.Groups[ "years" ].Value );
                if( years == 1 )
                    durationString.AppendFormat( "{0} year ", years );
                else
                    durationString.AppendFormat( "{0} years ", years );
            }

            if( m.Groups[ "months" ].Success )
            {
                int months = int.Parse( m.Groups[ "months" ].Value );
                if( months == 1 )
                    durationString.AppendFormat( "{0} month ", months );
                else
                    durationString.AppendFormat( "{0} months ", months );
            }

            if( m.Groups[ "days" ].Success )
            {
                int days = int.Parse( m.Groups[ "days" ].Value );
                if( days == 1 )
                    durationString.AppendFormat( "{0} day ", days );
                else
                    durationString.AppendFormat( "{0} days ", days );
            }

            if( m.Groups[ "hours" ].Success )
            {
                int hours = int.Parse( m.Groups[ "hours" ].Value );
                if( hours == 1 )
                    durationString.AppendFormat( "{0} hour ", hours );
                else
                    durationString.AppendFormat( "{0} hours ", hours );
            }

            if( m.Groups[ "minutes" ].Success )
            {
                int minutes = int.Parse( m.Groups[ "minutes" ].Value );
                if( minutes == 1 )
                    durationString.AppendFormat( "{0} minute ", minutes );
                else
                    durationString.AppendFormat( "{0} minutes ", minutes );
            }

            if( m.Groups[ "seconds" ].Success )
            {
                decimal seconds = decimal.Parse( m.Groups[ "seconds" ].Value );
                if( seconds == 1 )
                    durationString.AppendFormat( "{0} second ", seconds );
                else
                    durationString.AppendFormat( "{0} seconds ", seconds );
            }

            newValue = durationString.ToString().TrimEnd();
            if( string.IsNullOrEmpty( newValue ) )
                return false;
            else
                return true;
        }
Exemplo n.º 10
0
 private Node CreateNode( Element elem )
 {
     Node n = new Node(elem);
     return n;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructs a new instance of <see cref="DimensionNode"/>.
 /// </summary>
 public DimensionNode(Element elem)
     : base(elem)
 {
 }
Exemplo n.º 12
0
        //get the member and the taxonomy item..
        private TaxonomyItem GetMemberTaxonomyItem(string id, Taxonomy[] taxonomies, out Element ele)
        {
            ele = null;
            foreach (Taxonomy tax in taxonomies)
            {
                ele = tax.AllElements[id] as Element;
                if (ele != null)
                {
                    return tax.TaxonomyItems[ele.TaxonomyInfoId];
                }
            }

            return null;
        }
Exemplo n.º 13
0
        private Element(Element e, bool UseClone)
        {
            this.id = e.id;
            this.prefix = e.prefix;
            this.nameWithNSPrefix = e.nameWithNSPrefix;
            this.name = e.name;
            this.type = e.type;
            this.origElementType = e.origElementType;
            this.substGroup = e.substGroup;
            this.attributeType = e.attributeType;
            this.isNull = e.isNull;
            this.tuple = e.tuple;
            this.nillable = e.nillable;
            this.perType = e.perType;
            this.balType = e.balType;
            this.abst = e.abst;
            this.typedDimensionId = e.typedDimensionId;

            //this.tupleChildren = e.tupleChildren;

            // need to do a deep copy - the IM taxonomy on .NET 2.0 children are pointing to the wrong parent
            // this didn't seem to make a difference, but I think it's a good thing, so I'm going to leave it in
            if (UseClone)
            {
                if (e.tupleChildren != null)
                {
                    tupleChildren = new SortedList();
                    IDictionaryEnumerator enumer = e.tupleChildren.GetEnumerator();

                    while (enumer.MoveNext())
                    {
                        this.AddChild((double)enumer.Key, (Element)((Element)enumer.Value).Clone());
                    }
                }

                if (e.tupleParentList != null)
                {
                    tupleParentList = new List<Element>();
                    foreach( Element tp in e.tupleParentList )
                    {
                        if (tp.id == this.id)
                        {
                            tupleParentList.Add(this);
                        }
                        else
                        {
                            tupleParentList.Add(tp.Clone() as Element);
                        }
                    }
                }

            }
            else
            {
                this.tupleChildren = e.tupleChildren;
                this.tupleParentList = e.tupleParentList;
            }
            this.labelInfo = e.labelInfo;
            this.referenceInfo = e.referenceInfo;
            this.taxonomyInfoId = e.taxonomyInfoId;
            this.markupValues = e.markupValues;
            this.EnumData = e.EnumData;
            this.IsAucentExtendedElement = e.IsAucentExtendedElement;
            this.HasCompleteTupleFamily = e.HasCompleteTupleFamily;

            this.isChoice = e.isChoice;
            this.UseChoiceIcon = e.UseChoiceIcon;
            this.ChoiceContainer = e.ChoiceContainer;
            this.childrenInfo = e.childrenInfo;
        }
Exemplo n.º 14
0
 /// <summary>
 /// Overloaded.  Creates a new instance of <see cref="Element"/> and initializes it properties 
 /// from a parameter-supplied <see cref="Element"/>.
 /// </summary>
 /// <param name="e">The <see cref="Element"/> from which properties are to be copies to the newly-created 
 /// <see cref="Element"/>.</param>
 public Element(Element e)
     : this(e, true)
 {
 }
Exemplo n.º 15
0
        private void AddParentElement(Element parent)
        {
            if (this.tupleParentList == null) this.tupleParentList = new List<Element>();

            if (!tupleParentList.Contains(parent))
            {
                tupleParentList.Add(parent);
            }
        }
Exemplo n.º 16
0
        internal bool BindLabelToElement( Element e )
        {
            /* BUG 3558 - The labelTable has label as the key, which may or may not match the e.Id.
             * In the gg-2006-12-31.xsd taxonomy some labels have a label that matches the e.Id  but
             * others don't, so use the labelHrefHash and get the labels for each HRef. */

            if ( labelHrefHash.ContainsKey( e.Id ) )
            {
                e.LabelInfo = labelHrefHash[e.Id] as LabelLocator;
            }

            if ( e.LabelInfo == null )
            {
                //Common.WriteInfo( "XBRLParser.Warning.NoLabelForElement", errorList, e.Id );
                return true;
            }

            return true;
        }
Exemplo n.º 17
0
        private int AddAdditionalElementInfo( Element e, XmlNode elem, ArrayList errorList )
        {
            string type = null;
            string nillable = "false";
            string ptype = "na";
            string bal = "na";
            string abst = "false";

            // get optional arguments
            if ( !Common.GetAttribute( elem, TYPE_TAG, ref type, null ) )
            {
                if( elem.ChildNodes != null )
                {
                    foreach (XmlNode cn in elem.ChildNodes)
                    {
                        if (cn is XmlComment) continue;

                        if (cn.Name.IndexOf(@"complexType") > 0)
                        {
                            XmlNode restrictionNode = cn.SelectSingleNode(RESTRICTION_KEY, theManager);

                            if (restrictionNode != null)
                            {
                                type = restrictionNode.Attributes[BASE_TAG].Value;

                            }

                        }
                    }

                    if (type == null)
                    {
                        //Write it ourselves
                        Common.WriteError("XBRLParser.Warning.NoTagForLocator2", errorList, TYPE_TAG, elem.OuterXml);
                        return 1;
                    }
                }

            }

            ////fix type perfix to make sure it says xbrli if it is a xbrli type
            //if (!type.StartsWith("xbrli"))
            //{
            //    bool convertToxbrli= false;
            //    string[] parts = type.Split(':');
            //    if( parts.Length > 1 )
            //    {
            //    //it might be a different prefix but still uses the same namespace
            //    theManager.LookupNamespace(
            //}
            Common.GetAttribute(elem, NILLABLE_TAG, ref nillable, null);
            Common.GetAttribute(elem, ABSTRACT_TAG, ref abst, null);
            if (this.HasStandardXBRLIPrefix)
            {
                Common.GetAttribute(elem, PERIOD_TYPE_TAG, ref ptype, null);
                Common.GetAttribute(elem, BALANCE_TAG, ref bal, null);
            }
            else
            {
                //convert the value retured by type...

                type = this.ConvertToXBRLIPrefixIfValidPrefix(type);
                Common.GetAttribute(elem, ConvertXBRLIToValidPrefix(PERIOD_TYPE_TAG), ref ptype, null);
                Common.GetAttribute(elem, ConvertXBRLIToValidPrefix(BALANCE_TAG), ref bal, null);

            }

            e.AddOptionals( type,
                Boolean.Parse( nillable ),
                (Element.PeriodType)Enum.Parse( typeof( Element.PeriodType ), ptype, true ),
                (Element.BalanceType)Enum.Parse( typeof( Element.BalanceType ), bal, true ),
                Boolean.Parse( abst ) );

            if ( type != null && enumTable.Count > 0 && enumTable.ContainsKey( type ) )
            {
                // set the enumeration
                e.EnumData = enumTable[type] as Enumeration;
            }

            return 0;
        }
Exemplo n.º 18
0
        /// <summary>
        /// <para>Writes the <paramref name="embedWarning"/> to the this.<see cref="currentFilingSummary"/>, exchanging templated tokens for their actual values.</para>
        /// <para><paramref name="embedWarning"/> is expected to be in a templated format.</para>
        /// </summary>
        /// <param name="row">Provides the element's PreferredLabelRole.</param>
        /// <param name="element">A taxonomy <see cref="Element"/> allowing us to look up its labels.</param>
        /// <param name="cell">A <see cref="Cell" /> object which provides the context and unit IDs.</param>
        /// <param name="embedWarning">The warning to rewrite.</param>
        /// <returns>The warning with substitution tokens replaced.</returns>
        private string WriteEmbedWarning( InstanceReportRow row, Element element, Cell cell, string embedWarning )
        {
            string labelForWarning = null;
            // Try preferred
            if( !string.IsNullOrEmpty( row.PreferredLabelRole ) )
            {
                element.TryGetLabel( this.preferredLanguage, row.PreferredLabelRole, out labelForWarning );
            }

            // If preferred not available, try default
            if( string.IsNullOrEmpty( labelForWarning ) )
            {
                element.TryGetLabel( this.preferredLanguage, "label", out labelForWarning );
            }

            // If default not available, fall back to element name
            if( string.IsNullOrEmpty( labelForWarning ) )
            {
                labelForWarning = element.Name;
            }

            // Specify warning scope and trace
            embedWarning = embedWarning.Replace( "[Unknown Element]", labelForWarning );
            // Unit refs are not required
            if( cell.Markup.unitRef != null )
            {
                embedWarning = embedWarning.Replace( "[Unknown UnitID]", cell.Markup.unitRef.UnitID );
            }
            else
            {
                embedWarning = embedWarning.Replace( "[Unknown UnitID]", "No UnitID Specified" );
            }
            embedWarning = embedWarning.Replace( "[Unknown ContextID]", cell.Markup.contextRef.ContextID );
            this.currentFilingSummary.TraceWarning( embedWarning );
            return embedWarning;
        }
Exemplo n.º 19
0
        private Element LoadBaseElement( XmlNode elem )
        {
            string id = null;
            string name = null;
            string substGroup = null;

            // id is optional
            Common.GetAttribute( elem, ID_TAG, ref id, null );

            if ( !Common.GetAttribute( elem, NAME_TAG, ref name, errorList ) ||
                !Common.GetAttribute( elem, SUBST_GROUP_TAG, ref substGroup, errorList )  )
            {
                throw new AucentException( "XBRLParser.Error.NoNameOrSubstitutionGroup" );
            }
            if (!this.HasStandardXBRLIPrefix)
            {

                substGroup = ConvertToXBRLIPrefixIfValidPrefix(substGroup);
            }

            if ( id == null )
            {
                Common.WriteWarning( "XBRLParser.Warning.NoIDForElement", errorList, name );
                ++numWarnings;
            }

            Element el = new Element( id, name, substGroup );

            el.CreateNameWithNamespacePrefix(this.nsPrefix);

            if ( el.SubstitutionGroup == Element.DIMENSION_ITEM_TYPE )
            {
                //check if it is a typed dimension and if it is then need to set the name
                string typedDimensionId = null;
                if ( Common.GetAttribute( elem, XBRLDT_TYPEDDOMAINREF, ref typedDimensionId, null ) )
                {
                    if ( typedDimensionId != null )
                    {
                        if ( typedDimensionId.IndexOf( '#' ) >= 0 )
                        {
                            string[] vals = typedDimensionId.Split( '#' );
                            if ( vals.Length == 2 )
                            {
                                typedDimensionId = vals[1];
                            }
                        }
                        //add name to the list of complex type to load...
                        el.TypedDimensionId = typedDimensionId;

                        customDataTypesHash[typedDimensionId] = 1;
                    }
                }
            }

            return el;
        }
Exemplo n.º 20
0
        public Node CreateNode( string lang, string role, int level,
			string currentId, Node parentNode, LocatorRelationshipInfo relation, 
			PresentationLink pLink, bool recursive,
			Dimension dimensionInfo )
        {
            Node current = null;

            if (e == null && pLink != null)
            {
                /* Something went wrong during mergePresentation because we should have an element at
                 * this point.  Go to the presentationLink and try to get the element. */
                PresentationLocator loc = null;
                pLink.TryGetLocator(this.HRef, out loc);
                if (loc != null && loc.MyElement != null)
                {
                    //update the element and the child locators
                    e = loc.MyElement;
                    this.childLocatorsByHRef = loc.childLocatorsByHRef;
                }
            }
            if (e == null)
            {
                //it is a locator to an invalid element

                //just return null at this point...
                return null;
            }
            //make sure we have the right element if there's a parent (there could be clones)
            Element elementToUse = e;

            if (dimensionInfo != null && elementToUse != null)
            {
                if (elementToUse.IsDimensionItem())
                {
                    //get the parent node
                    if (parentNode != null)
                    {

                            //DimensionNode hierNode;
                            //if (dimensionInfo.TryGetHypercubeNode(lang,
                            //    role, pLink.Role, parentNode.Id, out hierNode))
                            //{
                            //    foreach (DimensionNode dn in hierNode.Children)
                            //    {
                            //        if (dn.Id == elementToUse.Id)
                            //        {
                            //            if (parentNode != null)
                            //            {

                            //                 and add it
                            //                parentNode.AddChild(dn);

                            //            }

                            //            return dn;
                            //        }
                            //    }

                            //}

                        DimensionNode hierNode;
                        if (dimensionInfo.TryGetHypercubeNode(lang,
                            role, pLink.Role, parentNode.Id,true, out hierNode))
                        {
                            if (hierNode.Children != null)
                            {
                                foreach (DimensionNode dn in hierNode.Children)
                                {
                                    if (dn.Id == elementToUse.Id)
                                    {
                                        if (parentNode != null)
                                        {

                                            // and add it
                                            parentNode.AddChild(dn);

                                        }

                                        return dn;
                                    }
                                }

                            }

                            return null; //strange ..could not find the correct hierarchy..
                        }
                        else
                        {
                            return null;
                        }
                    }
                }
            }

            current = elementToUse==null ? new Node( href ) : elementToUse.CreateNode( lang, role, false );

            if (relation != null)
            {
                current.SetOrder(relation.Order);
                current.CalculationWeight = relation.CalculationWeight;

                if (preferredLabelRole.Equals(role))
                {
                    if (relation.PrefLabel != null)
                    {
                        current.UpdatePreferredLabel(lang, relation.PrefLabel);
                    }
                }
                // now check to see if it's prohibited
                current.IsProhibited = relation.IsProhibited;

            }
            if (parentNode != null)
            {

                // and add it
                parentNode.AddChild(current);

            }

            if ( childLocatorsByHRef != null && recursive )
            {

                foreach( ChildPresentationLocator cpl in childLocatorsByHRef.Values )
                {
                    PresentationLocator childLocator;
                    if ( !pLink.TryGetLocator( cpl.HRef, out childLocator ))
                    {
                        continue;
                    }

                    bool innerRecursive = true;
                    if (parentNode != null && parentNode.GetParent(cpl.HRef) != null)
                    {
                        //this might be ok if one of the links is a prohibitted link...
                        innerRecursive = false; //looks like we have a recursion...
                    }

                    //organize locators by base order
                    //we should have only one valid LocatorRelationshipInfo for each non xlink information...
                    LocatorRelationshipInfo currentRelationShip=null;
                    for (int i = cpl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                    {
                        LocatorRelationshipInfo lri = cpl.LocatorRelationshipInfos[i] as LocatorRelationshipInfo;
                        if (currentRelationShip != null && lri.IsNonXlinkEquivalentRelationship(currentRelationShip)) continue;
                        currentRelationShip = lri;

                        // always create the child

                        childLocator.CreateNode(lang, role,
                            level + 1, cpl.HRef, current, lri, pLink, innerRecursive, dimensionInfo);

                    }

                }
                //need to sort the nodes
                if (current.Children != null)
                {
                    current.Children.Sort(new NodeOrderSorter());
                }
            }

            return current;
        }
Exemplo n.º 21
0
        private int LoadChildren( XmlNodeList childList, Element parent )
        {
            int numErrors = 0;
            XmlNode outerChild = GetFirstNonCommentNode( childList );

            while ( (outerChild != null) && (outerChild.Name.IndexOf( SEQ_TAG ) == -1)
                )
            {
                outerChild = outerChild.FirstChild;
            }
            if ( outerChild == null )
            {

                outerChild = GetFirstNonCommentNode( childList );
                while ( (outerChild != null) && (outerChild.Name.IndexOf( CHOICE_TAG ) == -1)
                    )
                {
                    outerChild = outerChild.FirstChild;
                }

                if ( outerChild == null )
                {
                    Common.WriteError( "XBRLParser.Error.AdvancedTuplesNotSupported", errorList );
                    ++numErrors;
                    return numErrors;
                }
                outerChild = outerChild.ParentNode;

            }

            // process the children of the tuple
            foreach ( XmlElement child in outerChild )
            {
                //ignore the comments
                if ( child.NodeType == XmlNodeType.Comment ) continue;

                if ( child.LocalName.CompareTo( CHOICE_TAG ) == 0 )
                {
                    if ( !LoadChoices( child, parent, ref numErrors ) )
                    {
                        return numErrors;
                    }
                }
                else
                {

                    Element e = LoadChild( child, parent, ref numErrors );

                    if ( e != null )
                    {
                        int minOccurs = 0;
                        int maxOccurs = 0;

                        GetOccurances( child, out minOccurs, out maxOccurs );

                        parent.AddChildInfo( e.Id, minOccurs, maxOccurs);
                    }

                }
            }

            return numErrors;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Constructs a new instance of <see cref="PresentationLocator"/>, initializing 
        /// properties from a parameter-supplied <see cref="PresentationLocator"/>.
        /// </summary>
        /// <param name="copy">The <see cref="PresentationLocator"/> from which the properties
        /// of the new <see cref="PresentationLocator"/> are to be initialized.</param>
        public PresentationLocator(PresentationLocator copy)
        {
            this.childLocatorsByHRef = copy.childLocatorsByHRef;
            this.childDisplayOrder = copy.childDisplayOrder;

            this.e = copy.e;
            this.HRef = copy.HRef;
            this.LabelArray = copy.LabelArray;
            this.e = copy.MyElement;
            this.parents = copy.parents;
            this.unpartitionedHref = copy.unpartitionedHref;
            this.xsd = copy.xsd;
        }
Exemplo n.º 23
0
        private void SetBaseType( Element e1 , List<string> checkedTypes )
        {
            //there is nothing to look up - exit recursion
            if( string.IsNullOrEmpty( e1.ElementType )  || checkedTypes.Contains( e1.ElementType) )
                return;

            //there was nothing found - exit recursion
            if( extendedDataMappings[ e1.ElementType ] == null )
                return;

            //remember this so that as we exit all of our loops
            //   we will ALWAYS have the original element type
            //SEE: finally{}
            string topMostType = e1.ElementType;

            try
            {
                //shift down from the current element...
                e1.OrigElementType = e1.ElementType;
                //... to the base element
                e1.ElementType = extendedDataMappings[ e1.ElementType ] as string;

                checkedTypes.Add(e1.ElementType);
                //when we do this recursively, we can get to the bottom-most element
                //  and its type
                SetBaseType(e1, checkedTypes);
            }
            finally
            {
                //remember this so that as we exit all of our loops
                //   we will ALWAYS have the original element type
                //SEE: topMostType = e1.ElementType;
                e1.OrigElementType = topMostType;
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// </summary>
 public LibrarySearchCriteria AddBalanceType(Element.BalanceType bt)
 {
     if (!balanceTypes.Contains(bt))
         balanceTypes.Add(bt);
     return this;
 }
Exemplo n.º 25
0
        /// <exclude/>
        protected void RecurseElementsForTuples(Element e)
        {
            if ( e.IsTuple )
            {
                Console.WriteLine( "{0} is a tuple", e.Name );
            }

            if ( e.HasChildren )
            {
                foreach ( Element c in e.TupleChildren.GetValueList() )
                {
                    RecurseElementsForTuples( c );
                }
            }
        }
Exemplo n.º 26
0
 /// <exclude/>
 public TestNode(string id, Element e)
     : base(e)
 {
 }
Exemplo n.º 27
0
        public void ElementToXmlFragment()
        {
            Element e1 = new Element( "Test1", "Test1", "substGroup1" );
            e1.AddOptionals( "Test", true, Element.PeriodType.duration, Element.BalanceType.debit, false );

            StringBuilder sb = new StringBuilder();

            Element.WriteXmlFragment(e1, true, null, sb);
            Assert.AreEqual( "name=\"Test1\" nillable=\"True\" abstract=\"False\" tuple=\"False\" type=\"Test\" substitutionGroup=\"substGroup1\" periodType=\"duration\" balanceType=\"debit\" minOccurs=\"0\" maxOccurs=\""+Int32.MaxValue+"\"", sb.ToString() );

            sb.Remove(0, sb.Length);
            Element.WriteXmlFragment( null, true, null, sb );
            Assert.AreEqual( "name=\"\" nillable=\"False\" abstract=\"True\" tuple=\"False\" type=\"\" substitutionGroup=\"\" periodType=\"na\" balanceType=\"na\" minOccurs=\"0\" maxOccurs=\""+Int32.MaxValue+"\"", sb.ToString() );
        }
Exemplo n.º 28
0
 /// <summary>
 /// Uses the taxonomy info id in the Node parameter and returns the
 /// corresponding TaxonomyItem from the internal list of infos.
 /// </summary>
 /// <param name="e">The element with the taxonomy info id for lookup in the internal list.</param>
 /// <returns></returns>
 public TaxonomyItem GetTaxonomyInfo(Element e)
 {
     return infos[e.TaxonomyInfoId];
 }
Exemplo n.º 29
0
        public void Test_ElementsNotEqual()
        {
            Element p1 = new Element( "p1_id", "parent_name", "subst1" );
            Element p2 = new Element( "p2_id", "parent_name", "subst1" );

            Assert.IsFalse( p1.Equals( p2 ), "p1 == p2" );

            Element p3 = new Element( "p3_id", "parent_name", "subst1" );
            Element p4 = new Element( "p3_id", "parent_name2", "subst1" );

            Assert.IsFalse( p3.Equals( p4 ), "p3 == p4" );

            Element p5 = new Element( "p5_id", "parent_name", "subst1" );
            Element p6 = new Element( "p5_id", "parent_name", "subst2" );

            Assert.IsFalse( p5.Equals( p6 ), "p5 == p6" );

            Element p7 = new Element( "p7_id", "parent_name", "subst1" );
            p7.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );

            Element p8 = new Element( "p7_id", "parent_name", "subst1" );
            p8.AddOptionals( "type4", false, PeriodType.duration, BalanceType.credit, false );

            Assert.IsFalse( p7.Equals( p8 ), "p7 == p8" );

            Element p9 = new Element( "p9_id", "parent_name", "subst1" );
            p9.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );

            Element p10 = new Element( "p9_id", "parent_name", "subst1" );
            p10.AddOptionals( "type3", true, PeriodType.duration, BalanceType.credit, false );

            Assert.IsFalse( p9.Equals( p10 ), "p9 == p10" );

            Element p11 = new Element( "p11_id", "parent_name", "subst1" );
            p11.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );

            Element p12 = new Element( "p11_id", "parent_name", "subst1" );
            p12.AddOptionals( "type3", false, PeriodType.instant, BalanceType.credit, false );

            Assert.IsFalse( p11.Equals( p12 ), "p11 == p12" );

            Element p13 = new Element( "p13_id", "parent_name", "subst1" );
            p13.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );

            Element p14 = new Element( "p13_id", "parent_name", "subst1" );
            p14.AddOptionals( "type3", false, PeriodType.duration, BalanceType.debit, false );

            Assert.IsFalse( p13.Equals( p14 ), "p13 == p14" );

            Element p15 = new Element( "p15_id", "parent_name", "subst1" );
            p15.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, false );

            Element p16 = new Element( "p15_id", "parent_name", "subst1" );
            p16.AddOptionals( "type3", false, PeriodType.duration, BalanceType.credit, true );

            Assert.IsFalse( p15.Equals( p16 ), "p15 == p16" );

            Element p17 = new Element( "p17_id", "parent_name", "subst1" );
            p17.AddChild( p1 );

            Element p18 = new Element( "p17_id", "parent_name", "subst1" );

            Assert.IsFalse( p17.Equals( p18 ), "p17 == p18" );

            Element p19 = new Element( "p19_id", "parent_name", "subst1" );
            p19.AddChild( p1 );

            Element p20 = new Element( "p19_id", "parent_name", "subst1" );
            p20.AddChild( p2 );

            Assert.IsFalse( p19.Equals( p20 ), "p19 == p20" );

            // c1 is considered the same element even though it has different parents
            Element c1 = new Element( "c1" );
            Element p21 = new Element( "p21_id", "parent_name", "subst1" );
            p21.AddChild( c1 );

            Element c2 = new Element( "c1" );
            Element p22 = new Element( "p21_id", "parent_name", "subst1" );
            p22.AddChild( c2 );

            Assert.IsTrue( c1.Equals( c2 ), "c1 != c2" );
        }
Exemplo n.º 30
0
        /// <summary>
        /// Write the tuple child information for the given parent element
        /// </summary>
        /// <param name="Parent"></param>
        /// <param name="prefix"></param>
        /// <param name="tupleParent"></param>
        /// <param name="doc"></param>
        /// <param name="theManager"></param>
        /// <param name="modifyDocument"></param>
        public void WriteTupleChildXml( Element Parent, 
            string prefix, XmlElement tupleParent, XmlDocument doc, XmlNamespaceManager theManager, bool modifyDocument)
        {
            XmlNode sequence = modifyDocument ? tupleParent.SelectSingleNode(".//link2:" + SEQUENCE, theManager) : tupleParent.SelectSingleNode(".//" + SEQUENCE);
            //XmlNode sequence =  tupleParent.SelectSingleNode( SEQUENCE );

            if (sequence == null)
            {
                sequence = CreateTupleParentStructure(doc, tupleParent, modifyDocument);
                // tupleParent is modified--child appended--by previous call.
            }

            // append the child
            XmlElement child = modifyDocument ? doc.CreateElement(ELEMENT, Taxonomy.XML_SCHEMA_URL) : doc.CreateElement(ELEMENT);
            sequence.AppendChild(child);

            XmlAttribute refAttr = doc.CreateAttribute(REF);
            child.Attributes.Append(refAttr);
            refAttr.Value = string.Format(DocumentBase.NAME_FORMAT, prefix, Name);

            XmlAttribute minOccurs = doc.CreateAttribute(MIN_OCCURS);
            child.Attributes.Append(minOccurs);
            minOccurs.Value = Parent.GetChildMinOccurance(this.id).ToString();

            XmlAttribute maxOccurs = doc.CreateAttribute(MAX_OCCURS);
            child.Attributes.Append(maxOccurs);
            int maxOccurances = Parent.GetChildMaxOccurance(id);
            // if maxOccurs is the max output unbounded, not the number
            if (maxOccurances == int.MaxValue)
            {
                maxOccurs.Value = StringResourceUtility.GetString("XBRLData.Wizard.Unbounded");
            }
            else
            {
                maxOccurs.Value = maxOccurances.ToString();
            }
        }