dtd

How to disable DTD fetching using JAXB2.0

微笑、不失礼 提交于 2019-11-26 18:08:52
问题 I'm trying to use JAXB to unmashall some XML which I used xjc to create in the first place. I don't want to do any validation on the unmarshalling, but even though I have disabled the validation according to the JAXB documentation with u.setSchema(null); , but this hasn't prevented a FileNotFoundException being thrown when it tries to run and can't find the schema. JAXBContext jc = JAXBContext.newInstance("blast"); Unmarshaller u = jc.createUnmarshaller(); u.setSchema(null); return u

Element that can only have one of two text values?

╄→гoц情女王★ 提交于 2019-11-26 17:51:53
问题 I'm constructing a DTD which has a fuel_system element. I want to restrict the text between <fuel_system> tag. It must be only carbureted or fuel-injected . How can I do this? I don't mention something like this = > attribute type (carbureted, fuel-injected), because I want to force this rule in <fuel_system> tags, not the attribute of fuel_system . 回答1: when defining an element in a DTD, there is no way to restrict the text inside the element. you can only tell what other element (child

Where is the HTML5 Document Type Definition?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 17:33:05
The "old" HTML/XHTML standards have a DTD (Document Type Definition) defined for them: HTML 4.01 http://www.w3.org/TR/html401/sgml/dtd.html XHTML 1.0 http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict This DTDs specify the rules for nesting elements - "which types of elements may appear in which types of elements". I made a diagram for XHTML 1.0 here (sorry, I no longer have that resource) I would like to update that diagram with a new version which also includes the new HTML5 elements. However, there doesn't seem to be a HTML5 DTD. It seems that the nesting rules are defined by the

Reference to undeclared entity exception while working with XML

别来无恙 提交于 2019-11-26 16:49:20
问题 I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity XmlDocument xmldoc = new XmlDocument(); string text = "Hello, I am text α   – —" xmldoc.InnerXml = "<p>" + text + "</p>"; This throws the exception: Reference to undeclared entity 'alpha'. Line 2, position 2.. How would I go about solving this problem? 回答1: XML, unlike HTML does not define entities (ie named references to UNICODE characters) so α — etc. are not translated to their corresponding

How do I validate xml against a DTD file in Python

核能气质少年 提交于 2019-11-26 15:37:51
问题 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 to choose between DTD and XSD

若如初见. 提交于 2019-11-26 15:27:28
问题 I want to use either a DTD or an XSD to describe my XML document. I've read that XSDs are better than DTDs since they support namespaces and data types, and that DTDs are older. Does this mean that I should only use XSDs for all future needs and totally ignore DTD as an option? Should I even bother learning the structure of DTDs? What factors should I consider when choosing between XSD and DTD? 回答1: It's probably important to learn DTDs as a separate exercise, just for the knowledge of how

how to disable dtd at runtime in java&#39;s xpath?

若如初见. 提交于 2019-11-26 14:22:13
问题 I got dtd in file and I cant remove it. When i try to parse it in Java I get "Caused by: java.net.SocketException: Network is unreachable: connect", because its remote dtd. can I disable somehow dtd checking? 回答1: You should be able to specify your own EntityResolver, or use specific features of your parser? See here for some approaches. A more complete example: <?xml version="1.0"?> <!DOCTYPE foo PUBLIC "//FOO//" "foo.dtd"> <foo> <bar>Value</bar> </foo> And xpath usage: import java.io.File;

Free DTD to XSD conversion utility? [closed]

 ̄綄美尐妖づ 提交于 2019-11-26 09:29:41
问题 I have a DTD that I need to convert to an XSD (XML schema) file. Is there a free utility or simple way to accomplish this? 回答1: The W3C offers one. There are also online converters. 回答2: If you happen to have Visual Studio, open the DTD file an you should have a button to "Create Schema" out of it. I haven't checked if it was available on Express edition, though. 回答3: Try xmlpad from http://www.wmhelp.com to convert DTD to XSD. Really nice tool. 回答4: http://www.thaiopensource.com/relaxng

Validate an XML file against local DTD file with Java

▼魔方 西西 提交于 2019-11-26 08:10:52
问题 How can I validate an XML file against a DTD that is stored locally as a file? The XML file does not have any DOCTYPE declaration (or may have one that should then be overridden). I had a look at this thread but besides the fact they are using .NET I doubt that this is a good solution. Any input appreciated! 回答1: In an ideal world, you'd be able to validate using a Validator. Something like this: SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.XML_DTD_NS_URI); Schema

What is difference between XML Schema and DTD?

你离开我真会死。 提交于 2019-11-26 07:53:41
问题 I have googled this question, but I do not understand clearly what is an XML schema and DTD (document type definition), and why the XML schema is more powerful compared to DTD. Any guidance would be highly appreciated. 回答1: From the Differences Between DTDs and Schema section of the Converting a DTD into a Schema article: The critical difference between DTDs and XML Schema is that XML Schema utilize an XML-based syntax, whereas DTDs have a unique syntax held over from SGML DTDs. Although DTDs