Inheritance: XmlLinkedNode
		public void TestValue ()
		{
			XmlTextReader xtr = new XmlTextReader ("<!DOCTYPE x:foo [<!ENTITY foo 'fooent'><!ENTITY bar 'test &foo;'>]><x:foo xmlns:x='hoge' />", XmlNodeType.Document, null);
			document.Load (xtr);
			xtr.Close ();
			docType = document.DocumentType;
			AssertEquals (2, docType.Entities.Count);
			XmlEntity foo = docType.Entities.Item (0) as XmlEntity;
			XmlEntity bar = docType.Entities.Item (1) as XmlEntity;
			AssertEquals ("foo", foo.Name);
			AssertNull (bar.Value);
			AssertEquals (1, foo.ChildNodes.Count);
			AssertEquals ("bar", bar.Name);
			AssertNull (bar.Value);
			AssertEquals (1, foo.ChildNodes.Count);
		}
Example #2
0
        private void LoadDocumentType(IDtdInfo dtdInfo, XmlDocumentType dtNode)
        {
            SchemaInfo schInfo = dtdInfo as SchemaInfo;
            if (schInfo == null)
            {
                throw new XmlException(SR.Xml_InternalError, string.Empty);
            }

            dtNode.DtdSchemaInfo = schInfo;
            if (schInfo != null)
            {
                //set the schema information into the document
                _doc.DtdSchemaInfo = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null)
                {
                    foreach (SchemaNotation scNot in schInfo.Notations.Values)
                    {
                        dtNode.Notations.SetNamedItem(new XmlNotation(scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, _doc));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.GeneralEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }

                if (schInfo.ParameterEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.ParameterEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }
                _doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator();
                if (elementDecls != null)
                {
                    elementDecls.Reset();
                    while (elementDecls.MoveNext())
                    {
                        SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value;
                        if (elementDecl.AttDefs != null)
                        {
                            IDictionaryEnumerator attDefs = elementDecl.AttDefs.GetEnumerator();
                            while (attDefs.MoveNext())
                            {
                                SchemaAttDef attdef = (SchemaAttDef)attDefs.Value;
                                if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID)
                                {
                                    //we only register the XmlElement based on their Prefix/LocalName and skip the namespace
                                    _doc.AddIdInfo(
                                        _doc.AddXmlName(elementDecl.Prefix, elementDecl.Name.Name, string.Empty, null),
                                        _doc.AddAttrXmlName(attdef.Prefix, attdef.Name.Name, string.Empty, null));
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver)
        {
            _doc = dtNode.OwnerDocument;
            XmlParserContext pc = new XmlParserContext(null, new XmlNamespaceManager(_doc.NameTable), null, null, null, null, _doc.BaseURI, string.Empty, XmlSpace.None);
            XmlTextReaderImpl tr = new XmlTextReaderImpl("", XmlNodeType.Element, pc);
            tr.Namespaces = dtNode.ParseWithNamespaces;
            if (bUseResolver)
            {
                tr.XmlResolver = resolver;
            }

            IDtdParser dtdParser = DtdParser.Create();
            XmlTextReaderImpl.DtdParserProxy proxy = new XmlTextReaderImpl.DtdParserProxy(tr);

            IDtdInfo dtdInfo = dtdParser.ParseFreeFloatingDtd(_doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, proxy);
            LoadDocumentType(dtdInfo, dtNode);
        }
Example #4
0
		public void GetReady ()
		{
			document = new XmlDocument ();
			docType = document.CreateDocumentType ("book", null, null, "<!ELEMENT book ANY>");
			document.AppendChild (docType);
		}
 public String GetDocumentTypeAttr ( XmlDocumentType docType, String name ) {
     //PreCondition: nav is pointing at DocumentType node or one of its virtual attributes
     if ( name == strPublicID )
         return docType.PublicId;
     if ( name == strSystemID )
         return docType.SystemId;
     return null;
 }
        private void LoadDocumentType(SchemaInfo schInfo, XmlDocumentType dtNode)
        {
            dtNode.DtdSchemaInfo = schInfo;
            if (schInfo != null)
            {
                //set the schema information into the document
                doc.DtdSchemaInfo = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null)
                {
                    foreach (SchemaNotation scNot in schInfo.Notations.Values)
                    {
                        dtNode.Notations.SetNamedItem(new XmlNotation(scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, doc));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.GeneralEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }

                if (schInfo.ParameterEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.ParameterEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }
                doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator();
                if (elementDecls != null)
                {
                    elementDecls.Reset();
                    while (elementDecls.MoveNext())
                    {
                        SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value;
                        if (elementDecl.AttDefs != null)
                        {
                            IDictionaryEnumerator attDefs = elementDecl.AttDefs.GetEnumerator();
                            while (attDefs.MoveNext())
                            {
                                SchemaAttDef attdef = (SchemaAttDef)attDefs.Value;
                                if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID)
                                {
                                    //we only register the XmlElement based on their Prefix/LocalName and skip the namespace
                                    doc.AddIdInfo(
                                        doc.AddXmlName(elementDecl.Prefix, elementDecl.Name.Name, string.Empty, null),
                                        doc.AddAttrXmlName(attdef.Prefix, attdef.Name.Name, string.Empty, null));
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
 internal void ParseDocumentType(XmlDocumentType dtNode)
 {
     XmlDocument ownerDocument = dtNode.OwnerDocument;
     if (ownerDocument.HasSetResolver)
     {
         this.ParseDocumentType(dtNode, true, ownerDocument.GetResolver());
     }
     else
     {
         this.ParseDocumentType(dtNode, false, null);
     }
 }
Example #8
0
 private void ParseDocumentType ( XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver ) {
     this.doc = dtNode.OwnerDocument;
     XmlNameTable nt = this.doc.NameTable;
     XmlNamespaceManager mgr = new XmlNamespaceManager( nt );
     XmlParserContext pc = new XmlParserContext( nt,
                                                 mgr,
                                                 dtNode.Name,
                                                 dtNode.PublicId,
                                                 dtNode.SystemId,
                                                 dtNode.InternalSubset,
                                                 this.doc.BaseURI,
                                                 String.Empty,
                                                 XmlSpace.None
                                                 );
     XmlValidatingReader vr = new XmlValidatingReader( "", XmlNodeType.Element, pc );
     vr.Namespaces = dtNode.ParseWithNamespaces;
     if ( bUseResolver )
         vr.XmlResolver = resolver;
     vr.ValidationType = ValidationType.None;
     vr.Read();
     LoadDocumentType( vr, dtNode );
     vr.Close();
 }
Example #9
0
        public override string GetAttribute(int attributeIndex)
        {
            if (NodeType == XmlNodeType.XmlDeclaration)
            {
                XmlDeclaration decl = current as XmlDeclaration;
                if (attributeIndex == 0)
                {
                    return(decl.Version);
                }
                else if (attributeIndex == 1)
                {
                    if (decl.Encoding != String.Empty)
                    {
                        return(decl.Encoding);
                    }
                    else if (decl.Standalone != String.Empty)
                    {
                        return(decl.Standalone);
                    }
                }
                else if (attributeIndex == 2 &&
                         decl.Encoding != String.Empty && decl.Standalone != null)
                {
                    return(decl.Standalone);
                }
                throw new ArgumentOutOfRangeException("Index out of range.");
            }
            else if (NodeType == XmlNodeType.DocumentType)
            {
                XmlDocumentType doctype = current as XmlDocumentType;
                if (attributeIndex == 0)
                {
                    if (doctype.PublicId != "")
                    {
                        return(doctype.PublicId);
                    }
                    else if (doctype.SystemId != "")
                    {
                        return(doctype.SystemId);
                    }
                }
                else if (attributeIndex == 1)
                {
                    if (doctype.PublicId == "" && doctype.SystemId != "")
                    {
                        return(doctype.SystemId);
                    }
                }
                throw new ArgumentOutOfRangeException("Index out of range.");
            }

            // This is MS.NET bug which returns attributes in spite of EndElement.
            if (isEndElement || current == null)
            {
                return(null);
            }

            if (attributeIndex < 0 || attributeIndex > AttributeCount)
            {
                throw new ArgumentOutOfRangeException("Index out of range.");
            }

            return(ownerLinkedNode.Attributes [attributeIndex].Value);
        }
 private void LoadDocumentType(IDtdInfo dtdInfo, XmlDocumentType dtNode)
 {
     SchemaInfo info = dtdInfo as SchemaInfo;
     if (info == null)
     {
         throw new XmlException("Xml_InternalError", string.Empty);
     }
     dtNode.DtdSchemaInfo = info;
     if (info != null)
     {
         this.doc.DtdSchemaInfo = info;
         if (info.Notations != null)
         {
             foreach (SchemaNotation notation in info.Notations.Values)
             {
                 dtNode.Notations.SetNamedItem(new XmlNotation(notation.Name.Name, notation.Pubid, notation.SystemLiteral, this.doc));
             }
         }
         if (info.GeneralEntities != null)
         {
             foreach (SchemaEntity entity in info.GeneralEntities.Values)
             {
                 XmlEntity node = new XmlEntity(entity.Name.Name, entity.Text, entity.Pubid, entity.Url, entity.NData.IsEmpty ? null : entity.NData.Name, this.doc);
                 node.SetBaseURI(entity.DeclaredURI);
                 dtNode.Entities.SetNamedItem(node);
             }
         }
         if (info.ParameterEntities != null)
         {
             foreach (SchemaEntity entity3 in info.ParameterEntities.Values)
             {
                 XmlEntity entity4 = new XmlEntity(entity3.Name.Name, entity3.Text, entity3.Pubid, entity3.Url, entity3.NData.IsEmpty ? null : entity3.NData.Name, this.doc);
                 entity4.SetBaseURI(entity3.DeclaredURI);
                 dtNode.Entities.SetNamedItem(entity4);
             }
         }
         this.doc.Entities = dtNode.Entities;
         IDictionaryEnumerator enumerator = info.ElementDecls.GetEnumerator();
         if (enumerator != null)
         {
             enumerator.Reset();
             while (enumerator.MoveNext())
             {
                 SchemaElementDecl decl = (SchemaElementDecl) enumerator.Value;
                 if (decl.AttDefs != null)
                 {
                     IDictionaryEnumerator enumerator2 = decl.AttDefs.GetEnumerator();
                     while (enumerator2.MoveNext())
                     {
                         SchemaAttDef def = (SchemaAttDef) enumerator2.Value;
                         if (def.Datatype.TokenizedType == XmlTokenizedType.ID)
                         {
                             this.doc.AddIdInfo(this.doc.AddXmlName(decl.Prefix, decl.Name.Name, string.Empty, null), this.doc.AddAttrXmlName(def.Prefix, def.Name.Name, string.Empty, null));
                             continue;
                         }
                     }
                 }
             }
         }
     }
 }
Example #11
0
        private void LoadDocumentType(IDtdInfo dtdInfo, XmlDocumentType dtNode)
        {
            SchemaInfo?schInfo = dtdInfo as SchemaInfo;

            if (schInfo == null)
            {
                throw new XmlException(SR.Xml_InternalError, string.Empty);
            }

            dtNode.DtdSchemaInfo = schInfo;
            if (schInfo != null)
            {
                //set the schema information into the document
                _doc !.DtdSchemaInfo = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null)
                {
                    foreach (SchemaNotation scNot in schInfo.Notations.Values)
                    {
                        dtNode.Notations.SetNamedItem(new XmlNotation(scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, _doc));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.GeneralEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }

                if (schInfo.ParameterEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.ParameterEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }
                _doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                foreach (KeyValuePair <XmlQualifiedName, SchemaElementDecl> elementDecls in schInfo.ElementDecls)
                {
                    SchemaElementDecl elementDecl = elementDecls.Value;
                    if (elementDecl.AttDefs != null)
                    {
                        foreach (KeyValuePair <XmlQualifiedName, SchemaAttDef> attDefs in elementDecl.AttDefs)
                        {
                            SchemaAttDef attdef = attDefs.Value;
                            if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID)
                            {
                                //we only register the XmlElement based on their Prefix/LocalName and skip the namespace
                                _doc.AddIdInfo(
                                    _doc.AddXmlName(elementDecl.Prefix, elementDecl.Name.Name, string.Empty, null),
                                    _doc.AddAttrXmlName(attdef.Prefix, attdef.Name.Name, string.Empty, null));
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #12
0
        private XmlNode ImportNodeInternal(XmlNode node, bool deep)
        {
            XmlNode newNode = null;

            if (node == null)
            {
                throw new InvalidOperationException(SR.Xdom_Import_NullNode);
            }
            else
            {
                switch (node.NodeType)
                {
                case XmlNodeType.Element:
                    newNode = CreateElement(node.Prefix, node.LocalName, node.NamespaceURI);
                    ImportAttributes(node, newNode);
                    if (deep)
                    {
                        ImportChildren(node, newNode, deep);
                    }
                    break;

                case XmlNodeType.Attribute:
                    Debug.Assert(((XmlAttribute)node).Specified);
                    newNode = CreateAttribute(node.Prefix, node.LocalName, node.NamespaceURI);
                    ImportChildren(node, newNode, true);
                    break;

                case XmlNodeType.Text:
                    newNode = CreateTextNode(node.Value);
                    break;

                case XmlNodeType.Comment:
                    newNode = CreateComment(node.Value);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    newNode = CreateProcessingInstruction(node.Name, node.Value);
                    break;

                case XmlNodeType.XmlDeclaration:
                    XmlDeclaration decl = (XmlDeclaration)node;
                    newNode = CreateXmlDeclaration(decl.Version, decl.Encoding, decl.Standalone);
                    break;

                case XmlNodeType.CDATA:
                    newNode = CreateCDataSection(node.Value);
                    break;

                case XmlNodeType.DocumentType:
                    XmlDocumentType docType = (XmlDocumentType)node;
                    newNode = CreateDocumentType(docType.Name, docType.PublicId, docType.SystemId, docType.InternalSubset);
                    break;

                case XmlNodeType.DocumentFragment:
                    newNode = CreateDocumentFragment();
                    if (deep)
                    {
                        ImportChildren(node, newNode, deep);
                    }
                    break;

                case XmlNodeType.EntityReference:
                    newNode = CreateEntityReference(node.Name);
                    // we don't import the children of entity reference because they might result in different
                    // children nodes given different namespace context in the new document.
                    break;

                case XmlNodeType.Whitespace:
                    newNode = CreateWhitespace(node.Value);
                    break;

                case XmlNodeType.SignificantWhitespace:
                    newNode = CreateSignificantWhitespace(node.Value);
                    break;

                default:
                    throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, SR.Xdom_Import, node.NodeType.ToString()));
                }
            }

            return(newNode);
        }
#pragma warning restore 618

        private XmlParserContext GetContext(XmlNode node)
        {
            String          lang      = null;
            XmlSpace        spaceMode = XmlSpace.None;
            XmlDocumentType docType   = this.doc.DocumentType;
            String          baseURI   = this.doc.BaseURI;
            //constructing xmlnamespace
            Hashtable           prefixes = new Hashtable();
            XmlNameTable        nt       = this.doc.NameTable;
            XmlNamespaceManager mgr      = new XmlNamespaceManager(nt);
            bool bHasDefXmlnsAttr        = false;

            // Process all xmlns, xmlns:prefix, xml:space and xml:lang attributes
            while (node != null && node != doc)
            {
                if (node is XmlElement && ((XmlElement)node).HasAttributes)
                {
                    mgr.PushScope();
                    foreach (XmlAttribute attr in ((XmlElement)node).Attributes)
                    {
                        if (attr.Prefix == doc.strXmlns && prefixes.Contains(attr.LocalName) == false)
                        {
                            // Make sure the next time we will not add this prefix
                            prefixes.Add(attr.LocalName, attr.LocalName);
                            mgr.AddNamespace(attr.LocalName, attr.Value);
                        }
                        else if (!bHasDefXmlnsAttr && attr.Prefix.Length == 0 && attr.LocalName == doc.strXmlns)
                        {
                            // Save the case xmlns="..." where xmlns is the LocalName
                            mgr.AddNamespace(String.Empty, attr.Value);
                            bHasDefXmlnsAttr = true;
                        }
                        else if (spaceMode == XmlSpace.None && attr.Prefix == doc.strXml && attr.LocalName == doc.strSpace)
                        {
                            // Save xml:space context
                            if (attr.Value == "default")
                            {
                                spaceMode = XmlSpace.Default;
                            }
                            else if (attr.Value == "preserve")
                            {
                                spaceMode = XmlSpace.Preserve;
                            }
                        }
                        else if (lang == null && attr.Prefix == doc.strXml && attr.LocalName == doc.strLang)
                        {
                            // Save xml:lag context
                            lang = attr.Value;
                        }
                    }
                }
                node = node.ParentNode;
            }
            return(new XmlParserContext(
                       nt,
                       mgr,
                       (docType == null) ? null : docType.Name,
                       (docType == null) ? null : docType.PublicId,
                       (docType == null) ? null : docType.SystemId,
                       (docType == null) ? null : docType.InternalSubset,
                       baseURI,
                       lang,
                       spaceMode
                       ));
        }
 public string GetDocumentTypeAttr(XmlDocumentType docType, string name)
 {
     if (name == "PUBLIC")
     {
         return docType.PublicId;
     }
     if (name == "SYSTEM")
     {
         return docType.SystemId;
     }
     return null;
 }
 private void ParseDocumentType(XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver)
 {
     this.doc = dtNode.OwnerDocument;
     XmlParserContext context = new XmlParserContext(null, new XmlNamespaceManager(this.doc.NameTable), null, null, null, null, this.doc.BaseURI, string.Empty, XmlSpace.None);
     XmlTextReaderImpl reader = new XmlTextReaderImpl("", XmlNodeType.Element, context) {
         Namespaces = dtNode.ParseWithNamespaces
     };
     if (bUseResolver)
     {
         reader.XmlResolver = resolver;
     }
     IDtdParser parser = DtdParser.Create();
     XmlTextReaderImpl.DtdParserProxy adapter = new XmlTextReaderImpl.DtdParserProxy(reader);
     IDtdInfo dtdInfo = parser.ParseFreeFloatingDtd(this.doc.BaseURI, dtNode.Name, dtNode.PublicId, dtNode.SystemId, dtNode.InternalSubset, adapter);
     this.LoadDocumentType(dtdInfo, dtNode);
 }
Example #16
0
 internal void ParseDocumentType ( XmlDocumentType dtNode ) {
     XmlDocument doc = dtNode.OwnerDocument;
     //if xmlresolver is set on doc, use that one, otherwise use the default one being created by xmlvalidatingreader
     if ( doc.HasSetResolver )
         ParseDocumentType( dtNode, true, doc.GetResolver() );
     else
         ParseDocumentType( dtNode, false, null );
 }
Example #17
0
		internal DOMDocumentType(XmlDocumentType/*!*/ xmlDocumentType)
			: base(ScriptContext.CurrentContext, true)
		{
			this.XmlDocumentType = xmlDocumentType;
		}
Example #18
0
        private void LoadDocumentType( XmlValidatingReader vr , XmlDocumentType dtNode ) {
            SchemaInfo schInfo = vr.GetSchemaInfo();
            if (schInfo != null) {
                //set the schema information into the document
                doc.SchemaInformation = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null) {
                    foreach( SchemaNotation scNot in schInfo.Notations.Values ) {
                        dtNode.Notations.SetNamedItem(new XmlNotation( scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, doc ));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null) {
                    foreach( SchemaEntity scEnt in schInfo.GeneralEntities.Values ) {
                        XmlEntity ent = new XmlEntity( scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc );
                        ent.SetBaseURI( scEnt.DeclaredURI );
                        dtNode.Entities.SetNamedItem( ent );
                    }
                }

                if (schInfo.ParameterEntities != null) {
                    foreach( SchemaEntity scEnt in schInfo.ParameterEntities.Values ) {
                        XmlEntity ent = new XmlEntity( scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc );
                        ent.SetBaseURI( scEnt.DeclaredURI );
                        dtNode.Entities.SetNamedItem( ent );
                    }
                }
                doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator();
                if (elementDecls != null) {
                    elementDecls.Reset();
                    while (elementDecls.MoveNext()) {
                        SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value;
                        if (elementDecl.AttDefs != null) {
                            IDictionaryEnumerator attDefs =  elementDecl.AttDefs.GetEnumerator();
                            while (attDefs.MoveNext()) {
                                SchemaAttDef attdef = (SchemaAttDef)attDefs.Value;
                                if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID) {
                                    doc.AddIdInfo(
                                        doc.GetXmlName(elementDecl.Name.Name, elementDecl.Name.Namespace),
                                        doc.GetXmlName(attdef.Name.Name, attdef.Name.Namespace));
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
 private void ParseDocumentType ( XmlDocumentType dtNode, bool bUseResolver, XmlResolver resolver ) {
     this.doc = dtNode.OwnerDocument;
     XmlNameTable nt = this.doc.NameTable;
     XmlNamespaceManager mgr = new XmlNamespaceManager( nt );
     SchemaInfo schemaInfo = DtdParser.Parse( nt, mgr, dtNode.ParseWithNamespaces, this.doc.BaseURI, dtNode.Name, dtNode.PublicId, 
                                              dtNode.SystemId, dtNode.InternalSubset, bUseResolver, resolver );
     LoadDocumentType( schemaInfo, dtNode );
 }
Example #20
0
 public XmlDocumentTypeWrapper(XmlDocumentType documentType)
     : base(documentType)
 {
     _documentType = documentType;
 }
        /// <summary>
        /// Compares properties of the doctype declaration.
        /// </summary>
        private ComparisonResult CompareDocTypes(XmlDocumentType control,
                                                 XPathContext controlContext,
                                                 XmlDocumentType test,
                                                 XPathContext testContext)
        {
            ComparisonResult lastResult =
                Compare(new Comparison(ComparisonType.DOCTYPE_NAME,
                                       control, GetXPath(controlContext),
                                       control.Name,
                                       test, GetXPath(testContext),
                                       test.Name));
            if (lastResult == ComparisonResult.CRITICAL) {
                return lastResult;
            }

            lastResult =
                Compare(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID,
                                       control, GetXPath(controlContext),
                                       control.PublicId,
                                       test, GetXPath(testContext),
                                       test.PublicId));
            if (lastResult == ComparisonResult.CRITICAL) {
                return lastResult;
            }

            return Compare(new Comparison(ComparisonType.DOCTYPE_SYSTEM_ID,
                                          control, GetXPath(controlContext),
                                          control.SystemId,
                                          test, GetXPath(testContext),
                                          test.SystemId));
        }