dtd

DTD or XML Schema. Which one is better? [closed]

房东的猫 提交于 2019-11-28 06:17:19
What are the pros / cons in DTD and XML Schemas (I'm not even sure what the official name of the latter is!)? Which is better? Why do we need two ways to do the same thing? Edit: I found this in an article I was reading, which is what prompted me to ask the question: Why W3C XML Schema Language? The W3C XML Schema Language is not the only schema language. In fact, the XML specification describes document-type definitions (DTDs) as the way to express a schema. In addition, pre-release versions of the JAXB Reference Implementation worked only with DTDs -- that is, not with schemas written in the

How to declare escape character as DTD Entities in external file and import in XML files

◇◆丶佛笑我妖孽 提交于 2019-11-28 05:38:32
问题 In a web project, I have a lot of XML files with non-escaped characters. I declare these characters as DTD Entities and include the list of declaration internally in each XML file, like so: !DOCTYPE article SYSTEM "../../pubmedref/archivearticle.dtd" [ <!ENTITY bull "•"> <!ENTITY copy "©"> ... a long list ... ]> Is there any way I can have these declarations in an external file and import it in the XML files? The XML files are rendered to the browser using XSLT. FWIW, I've tried referencing a

Difference between PCDATA and CDATA in DTD

倖福魔咒の 提交于 2019-11-28 02:58:44
What is the difference between #PCDATA and #CDATA in DTD ? Matthew Vines PCDATA - Parsed Character Data XML parsers normally parse all the text in an XML document. CDATA - (Unparsed) Character Data The term CDATA is used about text data that should not be parsed by the XML parser. Characters like "<" and "&" are illegal in XML elements. Rose Perrone PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded. CDATA is text that will not be parsed by a parser. Tags inside the text will not be treated as markup and entities will

XML, DTD: how to make the order not important

倖福魔咒の 提交于 2019-11-27 22:52:34
I started off using an XML file and a parser as a convenient way to store my data I want to use DTD to check the structure of the xml files when they arrive. Here is my DTD file < ?xml version="1.0" encoding="UTF-8"?> < !ELEMENT document (level*)> < !ELEMENT level (file,filelName?,fileNumber?)> < !ELEMENT file (#PCDATA)> < !ELEMENT filelName (#PCDATA)> < !ELEMENT fileNumber (#PCDATA)> (note that fileName and fileNumber are actually purely optional) and <document> <level> <file>group1file01</file> </level> <level> <file>group1file02</file> <fileName>file 2</fileName> <fileNumber>0</fileNumber>

How to disable DTD fetching using JAXB2.0

天涯浪子 提交于 2019-11-27 18:49:11
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.unmarshal(blast) I've seen similar questions for disabling SAX parsing from validation by setting the apache

Reference to undeclared entity exception while working with XML

戏子无情 提交于 2019-11-27 14:36:57
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? XML, unlike HTML does not define entities (ie named references to UNICODE characters) so α — etc. are not translated to their corresponding character. You must use the numerical value instead. You can only use < and & in XML If you want to create

Ignore DTD specification in scala

為{幸葍}努か 提交于 2019-11-27 13:46:44
问题 I'd like to occasionally ignore the dtd specification while parsing an xml file using Scala. I know that this can be done pretty easily with the java interface by doing DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setFeature("http://xml.org/sax/features/namespaces", false); dbf.setFeature("http://xml.org/sax/features/validation", false); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); dbf.setFeature(

schema validation with msxml in delphi

血红的双手。 提交于 2019-11-27 12:34:33
问题 I'm trying to validate an XML file against the schemas it references. (Using Delphi and MSXML2_TLB.) The (relevant part of the) code looks something like this: procedure TfrmMain.ValidateXMLFile; var xml: IXMLDOMDocument2; err: IXMLDOMParseError; schemas: IXMLDOMSchemaCollection; begin xml := ComsDOMDocument.Create; if xml.load('Data/file.xml') then begin schemas := xml.namespaces; if schemas.length > 0 then begin xml.schemas := schemas; err := xml.validate; end; end; end; This has the result

How do I validate xml against a DTD file in Python

三世轮回 提交于 2019-11-27 11:34:53
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

How to choose between DTD and XSD

随声附和 提交于 2019-11-27 11:06:12
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? Mike Mooney It's probably important to learn DTDs as a separate exercise, just for the knowledge of how they work in case you encounter them somewhere else, and so that you can appreciate some of the