dtd

Problem validation a XML file with a local DTD file in C#

感情迁移 提交于 2019-12-03 16:39:55
I'm triying to validate a XML file. I'm using this code XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; settings.ValidationType = ValidationType.DTD; settings.ValidationEventHandler += new ValidationEventHandler(validationError); XmlSchemaSet schemas = new XmlSchemaSet(); settings.Schemas = schemas; XmlReader reader = XmlReader.Create(lblXmlPath.Text, settings); reader.Settings.Schemas.Add(null, lblDTDPath.Text); while (reader.Read()) { // empty by now } reader.Close(); But in the line "reader.Settings.Schemas.Add(null, lblDTDPath.Text);" Visual Studio show

Is Scala/Java not respecting w3 “excess dtd traffic” specs?

僤鯓⒐⒋嵵緔 提交于 2019-12-03 05:07:02
问题 I'm new to Scala, so I may be off base on this, I want to know if the problem is my code. Given the Scala file httpparse, simplified to: object Http { import java.io.InputStream; import java.net.URL; def request(urlString:String): (Boolean, InputStream) = try { val url = new URL(urlString) val body = url.openStream (true, body) } catch { case ex:Exception => (false, null) } } object HTTPParse extends Application { import scala.xml._; import java.net._; def fetchAndParseURL(URL:String) = { val

Why external system entities are not working for me in Chrome, IE or Netscape?

a 夏天 提交于 2019-12-02 14:12:16
问题 I am attempting to replicate the example given in this answer: https://stackoverflow.com/a/5127928/356011 that illustrates using external entities to include a fragment of XML file in another XML file. doc.xml: <?xml version="1.0" standalone="no" ?> <!DOCTYPE doc [ <!ENTITY otherFile SYSTEM "otherFile.xml"> ]> <doc> <foo> <bar>&otherFile;</bar> </foo> </doc> otherFile.xml: <baz>this is my content</baz> When I attempt to test this by opening doc.xml in any browser, I just get: <doc> <foo> <bar

Create DTD for node with inner xml node and text

ぃ、小莉子 提交于 2019-12-02 07:05:44
I have pretty simple XML shown below. <?xml version="1.0" ?> <message> This is a message with some <bold>highlights</bold> in a text. </message> How can I create DTD to validate things inside message element? A mixture of node and text. This does not work. <!DOCTYPE message [ <!ELEMENT message (#PCDATA, bold)> <!ELEMENT bold (#PCDATA)> ]> When you have mixed content (both elements and text), you can't specify order (use | instead of , ) and it has to be zero or more occurrences ( * ). Example: <!DOCTYPE message [ <!ELEMENT message (#PCDATA|bold)*> <!ELEMENT bold (#PCDATA)> ]> <message> This is

What is the reason for not allowing non-deterministic element declarations in DTDs and XSD schemas?

巧了我就是萌 提交于 2019-12-02 02:30:54
The following declaration: <!ELEMENT p ((b, a) | (b, c))> and its XSD equivalent are both invalid because they are not deterministic, according to validators and a quick check of the spec(s). However, since every non-deterministic finite automaton has an equivalent deterministic finite automaton and since there are algorithms for converting NFAs into DFAs, what is the reason for prohibiting non-deterministic declarations? There are two classes of possible answer to a question like this: technical and historical. There is no sound technical reason for the determinism rules of XML DTDs or XSD.

Prevent XmlReader from expanding XML entities

随声附和 提交于 2019-12-01 22:57:14
问题 Is there a way to prevent .NET's XmlReader class from expanding XML entities into their value when reading the content? For instance, suppose the following XML is used as input: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE author PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML" "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent" > <author>á</author> Let's assume it is not possible to reach the external OASIS DTD needed for the expansion of the aacute

Prevent XmlReader from expanding XML entities

扶醉桌前 提交于 2019-12-01 20:26:10
Is there a way to prevent .NET's XmlReader class from expanding XML entities into their value when reading the content? For instance, suppose the following XML is used as input: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE author PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML" "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent" > <author>á</author> Let's assume it is not possible to reach the external OASIS DTD needed for the expansion of the aacute entity. I would like the reader to read, in sequence, the author element, then the aacute node of type

How do I validate xml against a DTD file in Python

丶灬走出姿态 提交于 2019-12-01 20:11:41
问题 I need to validate an XML string (and not a file) against a DTD description file. How can that be done in python ? 回答1: Another good option is lxml's validation which I find quite pleasant to use. A simple example taken from the lxml site: from StringIO import StringIO from lxml import etree dtd = etree.DTD(StringIO("""<!ELEMENT foo EMPTY>""")) root = etree.XML("<foo/>") print(dtd.validate(root)) # True root = etree.XML("<foo>bar</foo>") print(dtd.validate(root)) # False print(dtd.error_log

How do I validate xml against a DTD file in Python

蓝咒 提交于 2019-12-01 17:48:16
I need to validate an XML string (and not a file) against a DTD description file. How can that be done in python ? Michael Twomey Another good option is lxml's validation which I find quite pleasant to use. A simple example taken from the lxml site: from StringIO import StringIO from lxml import etree dtd = etree.DTD(StringIO("""<!ELEMENT foo EMPTY>""")) root = etree.XML("<foo/>") print(dtd.validate(root)) # True root = etree.XML("<foo>bar</foo>") print(dtd.validate(root)) # False print(dtd.error_log.filter_from_errors()) # <string>:1:0:ERROR:VALID:DTD_NOT_EMPTY: Element foo was declared EMPTY

.NET : How to validate XML file with DTD without DOCTYPE declaration

我的未来我决定 提交于 2019-12-01 03:46:11
I have an XML file with no DOCTYPE declaration that I would like to validate with an external DTD upon reading. Dim x_set As Xml.XmlReaderSettings = New Xml.XmlReaderSettings() x_set.XmlResolver = Nothing x_set.CheckCharacters = False x_set.ProhibitDtd = False x = XmlTextReader.Create(sChemin, x_set) How do you set the path for that external DTD? How do you validate? I have used the following function successfully before, which should be easy to adapt. How ever this relies on creating a XmlDocument as magnifico mentioned. This can be achieved by: XmlDocument doc = new XmlDocument(); doc.Load(