EDN Admin
Well-known member
Hi!
I need your help... Im trying to validate a XML file using a DTD located in my localhost, and I dont get it....
First, I found the problem with the "ProhibitDtd" attribute, the solution: <font size=2>
</font><font color="#008000" size=2> // Set the validation settings.</font>
<font color="#008080" size=2>1 XmlReaderSettings</font><font size=2> settings = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>XmlReaderSettings</font><font size=2>();
2 settings.ProhibitDtd = </font><font color="#0000ff" size=2>false</font><font size=2>;
3 settings.ValidationType = </font><font color="#008080" size=2>ValidationType</font><font size=2>.DTD;</font><font size=2>
4 settings.Schemas.Add( </font> <font color="#0000ff" size=2>null</font><font size=2>,</font><font color="#008080" size=2>XmlTextReader</font> <font size=2> .Create(dtdXml,settings)); </font><font size=2>
5 settings.ValidationEventHandler += </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>ValidationEventHandler</font><font size=2>(MyValidationEventHandler);
</font><font color="#008000" size=2> // Create the XmlReader object. </font><font size=2>
</font><font color="#008080" size=2>6 XmlReader</font><font size=2> reader = </font><font color="#008080" size=2>XmlReader</font><font size=2>.Create(fichXml, settings);</font>
<font size=2> .....</font>
<font size=2> dtdXml => Path of the DTD file in my computer </font>
<font size=2></font>
but now, I have other problem that I have no idea how to solve it! When I load the XML file, and try to validate it, the application give me the following message of XMLException in line 4:
"ELEMENT is an unexpected token. The expected token is DOCTYPE. Línea 3, posición 3."
I think that it could be because identify the DTD file as if it was a normal XML, but I dont know what can I do...
Could anybody help me? Please!!
Thank you very much!!!
-----------------------------------------------------------
DTD File (xml.dtd) <font color="#008080" size=2>
<?xml version="1.0" encoding="UTF-8"?> </font><font color="#000080" size=2>
<!ELEMENT Table (Words, Relations)> </font><font color="#000080" size=2>
<!ELEMENT Words (Word+)> </font><font color="#000080
<font size=2><!ELEMENT Word EMPTY></font>
<font size=2><!ATTLIST Word</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>></font> </font><font color="#000080" size=2>
<!ELEMENT Relations (Relation*)> </font><font color="#000080
<font size=2><!ELEMENT Relation EMPTY></font>
<font size=2><!ATTLIST Relation</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>></font> </font>
--------------------------------
XML (ejemplo.xml) <font color="#008080" size=2>
<?xml version="1.0" encoding="UTF-8"?> </font><font color="#0000ff
<font size=2><!--</font></font><font color="#808080" size=2>DOCTYPE Table SYSTEM "xml.dtd"</font><font color="#0000ff <font size=2>--></font>
<font size=2><</font></font><font size=2><font color="#800000 Table</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Words</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Word</font><font color="#ff0000 name</font><font color="#0000ff ="</font>home<font color="#0000ff "/> </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Word</font><font color="#ff0000 name</font><font color="#0000ff ="</font>place<font color="#0000ff "/> </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Word</font><font color="#ff0000 name</font><font color="#0000ff ="</font>domicile<font color="#0000ff "/></font></font>
<font size=2><font color="#0000ff continues..... </font></font>
<font size=2><font color="#0000ff </font></font><font size=2><font color="#0000ff </</font><font color="#800000 Words</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Relations</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Relation</font><font color="#ff0000 value</font><font color="#0000ff ="</font>0,66<font color="#0000ff "</font><font color="#ff0000 word1</font><font color="#0000ff ="</font>home<font color="#0000ff "</font><font color="#ff0000 word2</font><font color="#0000ff ="</font>place<font color="#0000ff "/> </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Relation</font><font color="#ff0000 value</font><font color="#0000ff ="</font>0,83<font color="#0000ff "</font><font color="#ff0000 word1</font><font color="#0000ff ="</font>home<font color="#0000ff "</font><font color="#ff0000 word2</font><font color="#0000ff ="</font>domicile<font color="#0000ff "/></font></font>
<font size=2><font color="#0000ff continues... </font></font>
<font size=2><font color="#0000ff </</font><font color="#800000 Relations</font></font><font color="#0000ff <font size=2>></font>
<font size=2></</font></font><font size=2><font color="#800000 Table</font><font color="#0000ff > </font></font>
View the full article
I need your help... Im trying to validate a XML file using a DTD located in my localhost, and I dont get it....
First, I found the problem with the "ProhibitDtd" attribute, the solution: <font size=2>
</font><font color="#008000" size=2> // Set the validation settings.</font>
<font color="#008080" size=2>1 XmlReaderSettings</font><font size=2> settings = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>XmlReaderSettings</font><font size=2>();
2 settings.ProhibitDtd = </font><font color="#0000ff" size=2>false</font><font size=2>;
3 settings.ValidationType = </font><font color="#008080" size=2>ValidationType</font><font size=2>.DTD;</font><font size=2>
4 settings.Schemas.Add( </font> <font color="#0000ff" size=2>null</font><font size=2>,</font><font color="#008080" size=2>XmlTextReader</font> <font size=2> .Create(dtdXml,settings)); </font><font size=2>
5 settings.ValidationEventHandler += </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>ValidationEventHandler</font><font size=2>(MyValidationEventHandler);
</font><font color="#008000" size=2> // Create the XmlReader object. </font><font size=2>
</font><font color="#008080" size=2>6 XmlReader</font><font size=2> reader = </font><font color="#008080" size=2>XmlReader</font><font size=2>.Create(fichXml, settings);</font>
<font size=2> .....</font>
<font size=2> dtdXml => Path of the DTD file in my computer </font>
<font size=2></font>
but now, I have other problem that I have no idea how to solve it! When I load the XML file, and try to validate it, the application give me the following message of XMLException in line 4:
"ELEMENT is an unexpected token. The expected token is DOCTYPE. Línea 3, posición 3."
I think that it could be because identify the DTD file as if it was a normal XML, but I dont know what can I do...
Could anybody help me? Please!!
Thank you very much!!!
-----------------------------------------------------------
DTD File (xml.dtd) <font color="#008080" size=2>
<?xml version="1.0" encoding="UTF-8"?> </font><font color="#000080" size=2>
<!ELEMENT Table (Words, Relations)> </font><font color="#000080" size=2>
<!ELEMENT Words (Word+)> </font><font color="#000080
<font size=2><!ELEMENT Word EMPTY></font>
<font size=2><!ATTLIST Word</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>></font> </font><font color="#000080" size=2>
<!ELEMENT Relations (Relation*)> </font><font color="#000080
<font size=2><!ELEMENT Relation EMPTY></font>
<font size=2><!ATTLIST Relation</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>CDATA #REQUIRED</font>
<font size=2>></font> </font>
--------------------------------
XML (ejemplo.xml) <font color="#008080" size=2>
<?xml version="1.0" encoding="UTF-8"?> </font><font color="#0000ff
<font size=2><!--</font></font><font color="#808080" size=2>DOCTYPE Table SYSTEM "xml.dtd"</font><font color="#0000ff <font size=2>--></font>
<font size=2><</font></font><font size=2><font color="#800000 Table</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Words</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Word</font><font color="#ff0000 name</font><font color="#0000ff ="</font>home<font color="#0000ff "/> </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Word</font><font color="#ff0000 name</font><font color="#0000ff ="</font>place<font color="#0000ff "/> </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Word</font><font color="#ff0000 name</font><font color="#0000ff ="</font>domicile<font color="#0000ff "/></font></font>
<font size=2><font color="#0000ff continues..... </font></font>
<font size=2><font color="#0000ff </font></font><font size=2><font color="#0000ff </</font><font color="#800000 Words</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Relations</font><font color="#0000ff > </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Relation</font><font color="#ff0000 value</font><font color="#0000ff ="</font>0,66<font color="#0000ff "</font><font color="#ff0000 word1</font><font color="#0000ff ="</font>home<font color="#0000ff "</font><font color="#ff0000 word2</font><font color="#0000ff ="</font>place<font color="#0000ff "/> </font></font>
<font size=2><font color="#0000ff <</font><font color="#800000 Relation</font><font color="#ff0000 value</font><font color="#0000ff ="</font>0,83<font color="#0000ff "</font><font color="#ff0000 word1</font><font color="#0000ff ="</font>home<font color="#0000ff "</font><font color="#ff0000 word2</font><font color="#0000ff ="</font>domicile<font color="#0000ff "/></font></font>
<font size=2><font color="#0000ff continues... </font></font>
<font size=2><font color="#0000ff </</font><font color="#800000 Relations</font></font><font color="#0000ff <font size=2>></font>
<font size=2></</font></font><font size=2><font color="#800000 Table</font><font color="#0000ff > </font></font>
View the full article