spyro2000 Posted July 22, 2009 Posted July 22, 2009 (edited) Hi there,I got three files (see attachment) in the same directory c:\xml:test.xml (UTF-8 textfile)rules.dtd (UTF-8 textfile)validate.au3 (AutoItScript)Content of test.xml:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE root SYSTEM "rules.dtd"> <root> Testfile with a <not_existing_element/> </root>Content of rules.dtd:<?xml version="1.0" encoding="UTF-8"?> <!ELEMENT root(#PCDATA)>Content of validate.au3:$xml = ObjCreate("MSXML2.DOMdocument.6.0") With $xml .setProperty ("ProhibitDTD",False) .async = False .validateOnParse = True .resolveExternals = True .Load ("c:\xml\test.xml") EndWith msgbox (16, "Error", $xml.parseError.reason)Normally I would expect a parsing error because of the not declared <not_existing_element/>. But no matter what I do with the source document - I always get the message "0". If the source document is not well-formed the parser delivers a error message as expected but no validation results at all.Is there any working example to validate a xml against a DTD with AutoIt? I also tried the "_XMLDOMWrapper"-Extension but I got no parse error there, too. When trying to validate the source with the "_XMLSchemaValidate"-Procedure I got a error message which says "Cannot have a DTD declaration outside of a DTD". No matter how I try, I simply can't get that to work. Any help appreciated,spyrovalidate.zip Edited July 22, 2009 by spyro2000
evilertoaster Posted July 22, 2009 Posted July 22, 2009 There's a working a example in java: http://www.webreference.com/programming/javascript/rg35/2.html and a related question here: http://objectmix.com/xml-soap/713782-dtd-prohibited-when-trying-add-xmlschema-xsd-schema-schemas-schema-cache-msxml6.html and here: http://bytes.com/groups/xml/827933-problem-dtd-declaration You might test if the problem is specific to AutoIt or if it is duplicable in another language like VB.
spyro2000 Posted July 23, 2009 Author Posted July 23, 2009 (edited) On 7/22/2009 at 8:40 PM, 'evilertoaster said: You might test if the problem is specific to AutoIt or if it is duplicable in another language like VB. Hi there and thanks for your quick answer. I've tested this code with only minor changes in the syntax within a VBS file and I ran smooth like a babies ass... I seems in fact to be a AutoIt-specific problem. This is the VBS code I used for exactly the same XML-File an DTD: Set xml = CreateObject("MSXML2.DOMdocument.6.0") With xml Call .setProperty("ProhibitDTD", False) .async = False .validateOnParse = True .resolveExternals = True .Load ("c:\xml\test.xml") End With msgbox xml.parseError.reason This gives me the excepted parsing error message as delivered by MSXML instead of the value "0"... Could this possibly be a bug in the AutoIt COM interface or something like that? spyro Edited July 23, 2009 by spyro2000
evilertoaster Posted July 23, 2009 Posted July 23, 2009 (edited) Quote Could this possibly be a bug in the AutoIt COM interface or something like that?Could be. I'm a bit surprised by this as well, and I'm not sure why it's happening. There is no COM error thrown, but the methods clearly aren't working as they should... Even more curious is this- $xml = ObjCreate("MSXML2.DOMdocument.5.0") With $xml .setProperty ("ProhibitDTD",False) .async = False .resolveExternals = True .Load (@ScriptDir&"\test.xml") EndWith msgbox (16, "Error", $xml.parseError.reason) Which uses and older version of the XML COM object but does work (validateOnPrase defaults to true in this version)... I'm not sure if the bug is in the COM object or AutoIts handling of the COM object, or in some silly implmentation detail we've overlooked. If you have the time, try putting in a support ticket to the AutoIt devs and see if they'll take a look. Edited July 23, 2009 by evilertoaster
spyro2000 Posted July 31, 2009 Author Posted July 31, 2009 (edited) On 7/23/2009 at 8:12 PM, 'evilertoaster said: If you have the time, try putting in a support ticket to the AutoIt devs and see if they'll take a look.Hello evilertoaster,Done. Unfortunely the ticked was rejected without reading because I linked the initial post of this thread. >_< Maybe it would make more sense to capsule a VBScript-based solution to get the correct messages from MSXML.thanks anyway,spyro Edited July 31, 2009 by spyro2000
jvanegmond Posted July 31, 2009 Posted July 31, 2009 Try looking for com errors in your code. github.com/jvanegmond
spyro2000 Posted August 1, 2009 Author Posted August 1, 2009 On 7/31/2009 at 11:32 AM, 'Manadar said: Try looking for com errors in your code.Hi,there are no com errors, that's what makes all this so weird...spyro
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now