dtd

Using Python and lxml to validate XML against an external DTD

我们两清 提交于 2019-12-01 01:10:34
I'm trying to validate an XML file against an external DTD referenced in the doctype tag. Specifically: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd"> ...the rest of the document... I'm using Python 3.3 and the lxml module. From reading http://lxml.de/validation.html#validation-at-parse-time , I've thrown this together: enexFile = open(sys.argv[2], mode="rb") # sys.argv[2] is the path to an XML file in local storage. enexParser = etree.XMLParser(dtd_validation=True) enexTree = etree.parse(enexFile, enexParser) From what I

How do I validate an XML document against a DTD in C#?

余生颓废 提交于 2019-11-30 21:00:11
I don't want to do anything fancy, I just want to make sure a document is valid, and print an error message if it is not. Google pointed me to this , but it seems XmlValidatingReader is obsolete (at least, that's what MonoDevelop tells me). Edit: I'm trying Mehrdad's tip, but I'm having trouble. I think I've got most of it, but I can't find OnValidationEvent anywhere. Where go I get OnValidationEvent from? XmlReaderSettings settings = new XmlReaderSettings(); settings.ValidationType = ValidationType.DTD; settings.ValidationEventHandler += new ValidationEventHandler(/*trouble is here*/);

Validate XML using a custom DTD in PHP

核能气质少年 提交于 2019-11-30 12:45:21
Is there a way (without installing any libraries) of validating XML using a custom DTD in PHP? Take a look at PHP's DOM , especially DOMDocument::schemaValidate and DOMDocument::validate . The example for DOMDocument::validate is fairly simple: <?php $dom = new DOMDocument; $dom->Load('book.xml'); if ($dom->validate()) { echo "This document is valid!\n"; } ?> If you have the dtd in a string, you can validate against it by using a data wrapper for the dtd: $xml = '<?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don

Is it possible to use XML Schemas internally, just like DTDs?

早过忘川 提交于 2019-11-30 09:52:41
问题 I have the following XML file which includes internal DTD validation: <?xml version="1.0"?> <!DOCTYPE animals [ <!ELEMENT animals (animal)*> <!ELEMENT animal (skin, noise, eyes, diet, class, weight, special_skill)> <!ELEMENT skin (#PCDATA)> <!ELEMENT noise (#PCDATA)> <!ELEMENT eyes (#PCDATA)> <!ELEMENT diet (#PCDATA)> <!ELEMENT class (#PCDATA)> <!ELEMENT weight (#PCDATA)> <!ELEMENT special_skill (#PCDATA)> <!ATTLIST animal name CDATA #REQUIRED > <!ATTLIST weight unit CDATA "kg"> ]> <animals>

How to validate xml with dtd using java?

て烟熏妆下的殇ゞ 提交于 2019-11-30 08:41:30
I have following xml file: <?xml version = "1.0" ?> <Employee> <Emp_Id> E-001</Emp_Id> <Emp_Name> Vinod </Emp_Name> <Emp_E-mail> Vinod1@yahoo.com </Emp_E-mail> </Employee> I have following dtd file: <!ELEMENT Employee (Emp_Id, Emp_Name, Emp_E-mail)> <!ELEMENT Emp_Id (#PCDATA)> <!ELEMENT Emp_Name (#PCDATA)> <!ELEMENT Emp_E-mail (#PCDATA)> I want to validate this xml file with above dtd using java. Please, help thanks..:-) There are three things you should do: Associate the source XML document with its DTD using a doctype declaration after the XML declaration: <!DOCTYPE Employee SYSTEM "employee

DTD required elements ordering

淺唱寂寞╮ 提交于 2019-11-30 08:02:21
问题 I want to have list of required elements in any order defined in dtd, but have no idea how I could do this. For example, I have following definition: <!ELEMENT parent (child1, child2, child3)> This dtd declaration will successfully validate following piece of xml: <parent> <child1></child1> <child2></child2> <child3></child3> </parent> But in following case xml will not pass validation: <parent> <child2></child2> <child1></child1> <child3></child3> </parent> One of the possible solution is to

XML validation against given DTD in PHP

廉价感情. 提交于 2019-11-30 05:10:48
In PHP, I am trying to validate an XML document using a DTD specified by my application - not by the externally fetched XML document. The validate method in the DOMDocument class seems to only validate using the DTD specified by the XML document itself, so this will not work. Can this be done, and how, or do I have to translate my DTD to an XML schema so I can use the schemaValidate method? (this seems to have been asked in Validate XML using a custom DTD in PHP but without correct answer, since the solution only relies on DTD speicified by the target XML) mercator Note: XML validation could

Extending XHTML

坚强是说给别人听的谎言 提交于 2019-11-30 04:00:52
I'm playing around with writing a jQuery plugin that uses an attribute to define form validation behavior (yes, I'm aware there's already a validation plugin; this is as much a learning exercise as something I'll be using). Ideally, I'd like to have something like this: Example 1 - input: <input id="name" type="text" v:onvalidate="return this.value.length > 0;" /> Example 2 - wrapper: <div v:onvalidate="return $(this).find('[value]').length > 0;"> <input id="field1" type="text" /> <input id="field2" type="text" /> <input id="field3" type="text" /> </div> Example 3 - predefined: <input id="name

XML, what is this: null or empty element?

孤者浪人 提交于 2019-11-30 02:56:09
问题 Regarding to my other question: XML deserialize null elements? I've got elements like these from a third-party server for API testing: <Taxable /> <DefaultPurchasePrice /> I just realized that now I am confusing myself about whether elements like that represent null object or empty. Talking about objects, they are same, null object normally means empty object reference right? But trying to map a XML element to a datafield/value, they could be different i.e null string is empty string, but for

XML schema or DTD for logback.xml?

陌路散爱 提交于 2019-11-29 20:24:49
I've seen several discussions on the net about how great it would be to have an XML schema or DTD for logback.xml file to have at least the very basic validation and auto-completion in IDEs like IDEA or Eclipse, but I never saw any solution. Did you? It is not supported officially according to the documentation , but there is an independent project to provide Schema for Logback However, due to extreme flexibility of the Logback configuration, Schema cannot support all possible configuration options. Eugene Yokota As of June 2011, the official documentation states As shall become clear, the