dtd

Does python's xml.etree.ElementTree support DTD?

a 夏天 提交于 2019-12-08 00:31:29
Does xml.etree.ElementTree support DTD? if it supports it, can I force ElementTree check a XML file against a dtd file, even if the XML file already has one. (internal or external). I'm not sure about xml.etree , but lxml supports DTD validation: http://lxml.de/validation.html 来源: https://stackoverflow.com/questions/5396135/does-pythons-xml-etree-elementtree-support-dtd

JAXB binding schema of dtd file

核能气质少年 提交于 2019-12-07 10:03:23
问题 A noobie question. I am generating Java code from a dtd file (USPTO dtd). The DTD specifies the root element as follows: <!ELEMENT us-patent-grant (doc-page+ | (us-bibliographic-data-grant , abstract* , drawings? , description , us-sequence-list-doc? , us-megatable-doc?,table-external-doc* , us-chemistry* , us-math* ,us-claim-statement , claims))> When I run xjc with the following binding schema <?xml version="1.0"?> <xml-java-binding-schema version="1.0ea2"> <element name="us-patent-grant"

XML Reader wants ProhibitDTD to be false but it is!

人走茶凉 提交于 2019-12-07 08:16:28
Here is the code Stream stream = request.InputStream; String xsd = // Path to file XmlReaderSettings settings = new XmlReaderSettings(); if (xsd.Length != 0 && File.Exists(xsd)) { settings.ProhibitDtd = false; settings.Schemas.Add("", xsd); settings.ValidationType = ValidationType.Schema; } else { throw new cXMLException("XSD file not found", ResponseStatus.InternalServerError); } using (XmlReader reader = XmlReader.Create(stream, settings)) { XmlDocument doc = new XmlDocument(); // Attempt to validate the XML document try { doc.Load(reader); } catch (XmlSchemaValidationException e) {

Can I reference an external DTD for the structure of an ELEMENT in a DTD?

本秂侑毒 提交于 2019-12-07 07:27:33
问题 Can I define a DTD such that elements in it have their structures defined in an external DTD? I mean something like the following (this is an example that I know is invalid in several ways, but which hopefully will give you an idea of what I am looking for): <?xml version="1.0" encoding="UTF-8"?> <!ENTITY % MessageHdr-DTD SYSTEM "./messagehdr.dtd"> <!ENTITY % MessageBody-DTD SYSTEM "./messagebody.dtd"> <!ELEMENT Message (MessageHdr, MessageBody)> <!ELEMENT MessageHdr (MessageHdr-DTD)> <

HTML5 is not based on SGML, and therefore does not require a reference to a DTD

做~自己de王妃 提交于 2019-12-07 07:10:15
问题 From: http://www.w3schools.com/tags/tag_doctype.asp The < !DOCTYPE > declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in. In HTML 4.01, the < !DOCTYPE > declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly. HTML5 is not based on SGML, and therefore does not require a reference to a DTD. Tip: Always add the <

Python xml etree DTD from a StringIO source?

左心房为你撑大大i 提交于 2019-12-07 07:08:44
问题 I'm adapting the following code (created via advice in this question), that took an XML file and it's DTD and converted them to a different format. For this problem only the loading section is important: xmldoc = open(filename) parser = etree.XMLParser(dtd_validation=True, load_dtd=True) tree = etree.parse(xmldoc, parser) This worked fine, whilst using the file system, but I'm converting it to run via a web framework, where the two files are loaded via a form. Loading the xml file works fine:

How to apply validation of local DTD file to xml file in java?

徘徊边缘 提交于 2019-12-07 04:42:45
问题 I need to parse a bunch of incoming XML documents but it does not contain DTD declaration. Currently I am parsing xml documents using SAX Parser but without DTD validation. Now I want to apply DTD validation. DTD is created by myself. How can I validate an XML file using DTD created by myself (SAX parser) ? I found some tutorials using Transformer but all for DOM Parser. How to parse XML file using SAX Parser and also applying DTD validation. Any help.... 回答1: Below is a sample that I believe

DTD Entities vs XML-Schema Elements

大兔子大兔子 提交于 2019-12-07 02:57:36
问题 Using an Document DTD I did the following: file.xsl: <!DOCTYPE xsl:stylesheet[ <!ENTITY red "rgb(255,0,0)"> ]> <xsl:stylesheet> [...] <xsl:attribute name="color">&red;</xsl:attribute> [...] </xsl:stylesheet> I wanted to change everything to XML-Schema. So I tried: file.xsd: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="red" type="xs:token" fixed="rgb(255,0,0)" /> </xsd:schema> file.xsl: <xsl:stylesheet xmlns:defs="http://www.w3.org/2001/XMLSchema-instance" defs

The best way to validate XML in a unit test?

不问归期 提交于 2019-12-06 23:29:24
问题 I have a class with a ToString method that produces XML. I want to unit test it to ensure it is producing valid xml. I have a DTD to validate the XML against. Should I include the DTD as a string within the unit test to avoid a dependency on it, or is there a smarter way to do this? 回答1: If your program validates the XML against the DTD during normal execution, then you should just get the DTD from wherever your program will get it. If not and the DTD is extremely short (only a few lines),

dtd and mixed content

走远了吗. 提交于 2019-12-06 20:24:37
Does someone know way a mixet content element (in dtd) there is a need to add the "*" at the end? For example: <!ELEMENT note (#PCDATA|to|from|header|message)*> I'm reffering to the case where I don't want to repeat anything again... I just want to be able to choose between #PCDATA and other elements. I know that if I drop the "*" in the end of the decleration I will get a bad DTD decleration... But - I have no idea what is the reason of that... Anyone know why? Nic Gibson You're hitting this restriction because the mixed content model is only allowed to constrain which elements occur not