コード例 #1
0
        public void Append(PresentationLink arg, ArrayList errors)
        {
            Hashtable tempLocators = new Hashtable();

            if (arg.locators != null && arg.locators.Count > 0)
            {
                foreach (DictionaryEntry de in arg.locators)
                {
                    PresentationLocator presLocator
                        = locators[de.Key] as PresentationLocator;
                    if (presLocator != null)
                    {
                        tempLocators[de.Key] = de.Value;
                    }
                    else
                    {
                        locators[de.Key] = de.Value;
                    }
                }
            }

            // fix up the new locators
            foreach (DictionaryEntry de in tempLocators)
            {
                PresentationLocator presLocator = locators[de.Key] as PresentationLocator;
                PresentationLocator oldLocator  = de.Value as PresentationLocator;

                presLocator.Append(oldLocator);
            }

            //preserve the old BaseSchema, so roleRef href will point to the correct schema
            BaseSchema = arg.BaseSchema;
        }
コード例 #2
0
        internal PresentationLink CreateCopyForMerging()
        {
            PresentationLink ret = new PresentationLink();

            ret.role  = this.role;
            ret.title = this.title;

            ret.BaseSchema = this.BaseSchema;
            ret.MyHref     = this.MyHref;

            //need to copy the locators

            ret.locators = new Hashtable();
            foreach (DictionaryEntry de in this.locators)
            {
                PresentationLocator orig = de.Value as PresentationLocator;

                PresentationLocator copy = orig.CreateCopyForMerging();



                ret.locators[de.Key] = copy;
            }

            //using the parentnewvalue list we need to reset the parent infotrmationin
            //presentation locators
            foreach (PresentationLocator pl in ret.locators.Values)
            {
                pl.ResetParentInformation(ret.locators);
            }
            return(ret);
        }
コード例 #3
0
        /// <summary>
        /// Deprecated.  Do not use.
        /// </summary>
        /// <param name="numTabs">Not used.</param>
        /// <param name="verbose">Not used.</param>
        /// <param name="language">Not used</param>
        /// <param name="xml">Not used.</param>
        public override void ToXmlString(int numTabs, bool verbose, string language, StringBuilder xml)
        {
#if false
            if (numTabs == 0)
            {
                xml.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>").Append(Environment.NewLine);
                xml.Append("<!-- Linkbase based on XBRL standard v.2.1  Created by Aucent XBRLParser ").Append(ParserMessage.ExecutingAssemblyVersion).Append(" Contact www.aucent.com -->").Append(Environment.NewLine);
            }
            else
            {
                for (int i = 0; i < numTabs; ++i)
                {
                    xml.Append("\t");
                }
            }

            IDictionaryEnumerator enumer = null;
            if (processingPresenationType == PreseantationTypeCode.Presentation)
            {
                xml.Append("<").Append(HEADER_STR).Append(" file=\"").Append(schemaFile).Append("\">").Append(Environment.NewLine);
                enumer = presentationLinks.GetEnumerator();
            }
            else
            {
                if (processingPresenationType == PreseantationTypeCode.Calculation)
                {
                    xml.Append("<").Append(CALATIONHEADER_STR).Append(" file=\"").Append(schemaFile).Append("\">").Append(Environment.NewLine);
                    enumer = calculationLinks.GetEnumerator();
                }
            }

            while (enumer.MoveNext())
            {
                PresentationLink pl = enumer.Value as PresentationLink;
                pl.ToXmlString(numTabs + 1, verbose, language, xml);
            }

            for (int i = 0; i < numTabs; ++i)
            {
                xml.Append("\t");
            }

            xml.Append("</").Append(HEADER_STR).Append(">").Append(Environment.NewLine);
#endif
        }
コード例 #4
0
        private void ProcessCalculationLinks(XmlNode plNode,
                                             string role, string title, ref int errorsEncountered,
                                             Dictionary <string, string> discoveredSchemas)
        {
            PresentationLink pl = calculationLinks[role] as PresentationLink;

            if (pl == null)
            {
                // create the object
                pl = new PresentationLink(title, role, BaseSchema, errorList);

                // put it in the hashtable
                calculationLinks[role] = pl;
            }

            // and load up the links
            int linkErrors = 0;

            pl.LoadChildren(plNode, theManager, discoveredSchemas, this.schemaPath, out linkErrors);

            errorsEncountered += linkErrors;
        }
コード例 #5
0
        private void CheckRecursionInCalculation(PresentationLink link,
            Node current, ref List<ValidationErrorInfo> secValidationErrors)
        {
            if (current.IsProhibited) return;

            if (current.parent != null)
            {
                if (current.parent.GetParent(current.Id) != null)
                {
                    ValidationErrorInfo info = new ValidationErrorInfo(
                string.Format("Report '{0}' has a recursive relationship for the element '{1}' in the calculation view.", link.Title, current.Label),
                ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.RECURSION_IN_CALCULATION);
                    secValidationErrors.Add(info);
                }
            }

            if (current.children != null)
            {
                foreach (Node c in current.children)
                {
                    CheckRecursionInCalculation(link, c, ref secValidationErrors);
                }
            }
        }
コード例 #6
0
        public void CheckOrderDiffPriority()
        {
            PresentationLocator parent	= new TestPresentationLocator( "parent", "xsd#parent" );
            ArrayList errors = new ArrayList();

            parent.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            PresentationLocator child	= new TestPresentationLocator( "child", "xsd#child" );
            PresentationLocator child2	= new TestPresentationLocator( "child2", "xsd#child2" );
            //			PresentationLocator child3	= new TestPresentationLocator( "child_7.0_pro", "xsd#child" );

            child.ParseHRef( errors );
            //child.MyElement = new Element( "child_1.7", false );
            Assert.AreEqual( 0, errors.Count );

            child2.ParseHRef( errors );
            //child2.MyElement = new Element( "child_7.0_opt", false );
            Assert.AreEqual( 0, errors.Count );

            //child3.ParseHRef( errors );
            //child3.MyElement = new Element( "child_7.0_pro", false );
            //Assert.AreEqual( 0, errors.Count );

            PresentationLink pl = new PresentationLink("Test", "Test", new ArrayList() );
            pl.AddLocator( parent );
            pl.AddLocator( child );
            pl.AddLocator( child2 );

            parent.AddChild( child, "Label", "0", 1.7F, "label", "0", false );
            parent.AddChild( child, "Label", "0", 7.0F, "label", "0", false );
            parent.AddChild( child, "Label", "2", 7.0F, "label", "0", true );

            parent.AddChild( child2, "Label", "0", 2.0F, "label", "0", false );

            //			pl.AddLocator( child3 );

            Node n = parent.CreateNode( "en", "", "", pl );

            //should be:
            //	child (1.7)
            //	child2 (2.0)
            //  child - prohibited (7.0)

            Assert.AreEqual( "parent", n.Label, "parent expected" );
            Assert.AreEqual( "child", ((Node)n.Children[0]).Label, "child 0 wrong" );
            Assert.AreEqual( "child2", ((Node)n.Children[1]).Label, "child 1 wrong" );

            Assert.AreEqual( 3, n.Children.Count, "wrong number of children" );
            Assert.AreEqual( "child", ((Node)n.Children[2]).Label, "child 2 wrong" );

            Assert.IsFalse( ((Node)n.Children[0]).IsProhibited, "child 0 is not prohibited" );
            Assert.IsFalse( ((Node)n.Children[1]).IsProhibited, "child 1 is not prohibited" );
            Assert.IsTrue( ((Node)n.Children[2]).IsProhibited, "child 2 is  prohibited" );
        }
コード例 #7
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;
        }
コード例 #8
0
 /// <summary>
 /// Creates a Node and also any children - e.g. it's recursive
 /// </summary>
 /// <param name="lang">The default language to use.</param>
 /// <param name="role">The default label role to use.</param>
 /// <param name="parentId"></param>
 /// <param name="pLink"></param>
 /// <returns></returns>
 /// <remarks>
 /// Note: Prohibited relationships are still created.  It is the job of the presenter to either ignore the 
 /// prohibited flag, or follow the rules and not display the node.
 /// </remarks>
 public Node CreateNode( string lang, string role,  string parentId , PresentationLink pLink)
 {
     return CreateNode( lang, role,  0,  parentId, null,null, pLink , true, null  );
 }
コード例 #9
0
ファイル: PresentationLink.cs プロジェクト: plamikcho/xbrlpoc
        internal PresentationLink CreateCopyForMerging()
        {
            PresentationLink ret = new PresentationLink();

            ret.role = this.role;
            ret.title = this.title;

            ret.BaseSchema = this.BaseSchema;
            ret.MyHref = this.MyHref;

            //need to copy the locators

            ret.locators = new Hashtable();
            foreach (DictionaryEntry de in this.locators)
            {
                PresentationLocator orig = de.Value as PresentationLocator;

                PresentationLocator copy = orig.CreateCopyForMerging();

                ret.locators[de.Key] = copy;
            }

            //using the parentnewvalue list we need to reset the parent infotrmationin
            //presentation locators
            foreach (PresentationLocator pl in ret.locators.Values)
            {
                pl.ResetParentInformation(ret.locators);
            }
            return ret;
        }
コード例 #10
0
ファイル: PresentationLink.cs プロジェクト: plamikcho/xbrlpoc
        public void Append( PresentationLink arg, ArrayList errors )
        {
            Hashtable tempLocators = new Hashtable();
            if ( arg.locators != null && arg.locators.Count > 0 )
            {
                foreach( DictionaryEntry de in arg.locators )
                {

                    PresentationLocator presLocator
                        = locators[de.Key] as PresentationLocator;
                    if ( presLocator != null )
                    {
                        tempLocators[de.Key] = de.Value;
                    }
                    else
                    {

                        locators[de.Key] = de.Value;
                    }
                }
            }

            // fix up the new locators
            foreach( DictionaryEntry de in tempLocators )
            {
                PresentationLocator presLocator = locators[de.Key] as PresentationLocator;
                PresentationLocator oldLocator = de.Value as PresentationLocator;

                presLocator.Append( oldLocator );

            }

            //preserve the old BaseSchema, so roleRef href will point to the correct schema
            BaseSchema = arg.BaseSchema;
        }
コード例 #11
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);
        }
コード例 #12
0
 /// <summary>
 /// Creates a Node and also any children - e.g. it's recursive
 /// </summary>
 /// <param name="lang">The default language to use.</param>
 /// <param name="role">The default label role to use.</param>
 /// <param name="parentId"></param>
 /// <param name="pLink"></param>
 /// <returns></returns>
 /// <remarks>
 /// Note: Prohibited relationships are still created.  It is the job of the presenter to either ignore the
 /// prohibited flag, or follow the rules and not display the node.
 /// </remarks>
 public Node CreateNode(string lang, string role, string parentId, PresentationLink pLink)
 {
     return(CreateNode(lang, role, 0, parentId, null, null, pLink, true, null));
 }
コード例 #13
0
ファイル: Presentation.cs プロジェクト: plamikcho/xbrlpoc
        private void ProcessPresentationLinks(XmlNode plNode,
			string role, string title, ref int errorsEncountered, 
			Dictionary<string, string> discoveredSchemas)
        {
            PresentationLink pl = presentationLinks[role] as PresentationLink;

            if (pl == null)
            {
                // create the object
                pl = new PresentationLink(title, role, BaseSchema, errorList);

                // put it in the hashtable
                presentationLinks[role] = pl;
            }

            // and load up the links
            int linkErrors = 0;
            pl.LoadChildren(plNode, theManager,  discoveredSchemas, this.schemaPath, out linkErrors);

            errorsEncountered += linkErrors;
        }