Jump to content

Validating Xml Aginst Xsd Using Msxml4...


tvtiger

Recommended Posts

Greetings,I am trying to validate XML against XSD using MSXML4 (Visual basic 6). XML validate fine in XMLSPY but when I try to validate it using MSXML in VB6 application. I get an application error as "Memory could not read at "0x………" After further investigation I figured out that it's GEOMETRY tag is causing a problem. I am not sure what's causing this error, can anybody help me out on this error. My XSD file is as follows------------------------------------<?xml version="1.0" ?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="INVENTORY"> <xsd:complexType> <xsd:sequence> <xsd:element name="LOCATION" type="LOCATION" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="LOCATION"> <xsd:all> <xsd:element name="LOCATION_CODE" type="LOCATION_CODE"/> <xsd:element name="GEOMETRY"> <xsd:complexType> <xsd:complexContent mixed="true"> <xsd:extension base="xsd:anyType"> <xsd:attributeGroup ref="XY"/> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:element> </xsd:all> </xsd:complexType> <xsd:simpleType name="LOCATION_CODE"> <xsd:restriction base="xsd:string"> <xsd:maxLength value="20"/> </xsd:restriction></xsd:simpleType><xsd:attributeGroup name="XY"> <xsd:attribute name="X" type="xsd:decimal"/> <xsd:attribute name="Y" type="xsd:decimal"/></xsd:attributeGroup></xsd:schema>----------------------------END OF XSD-------------------------------XML File-----------------------<?xml version="1.0" encoding="utf-8" ?><INVENTORY xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="A.xsd"><LOCATION><LOCATION_CODE>XXX:YYY:A0000001</LOCATION_CODE><GEOMETRY>X="100000.000"Y="100000.000"</GEOMETRY></LOCATION></INVENTORY>-------------END OF XML-------------Thanks in advance,

Link to comment
Share on other sites

With the kind of error you're getting, I think you may instead be experiencing a crash of MSXML 4.0.Could you by any chance use MSXML 6.0 instead?

Link to comment
Share on other sites

  • 2 weeks later...
With the kind of error you're getting, I think you may instead be experiencing a crash of MSXML 4.0.Could you by any chance use MSXML 6.0 instead?
Thanks for reply.It's not giving same error with MSXML6. Now it's throwing error on last line of XML as "The node is neither valid nor invalid because no DTD/Schema declaration was found".Thnks,
Link to comment
Share on other sites

Thanks for reply.It's not giving same error with MSXML6. Now it's throwing error on last line of XML as "The node is neither valid nor invalid because no DTD/Schema declaration was found".Thnks,
All validators that I tried (within Stylus Studio I must say) completed with no particular error messages.SAXON's Schema validator, JAVA's built in, MSXML 6.0 DOM, .NET XML and XSV all say it's valid.For some reason, MSXML 4.0 DOM said there's an error, but it didn't specified what.MSXML 4.0 SAX crashes... I'm guessing that's the kind of validator you used, since this crash appears to be duplicateable.MSXML 6.0 SAX said "warning: Msxml2.SAXXMLReader.6.0 does not support DTD validation"... so I'm guessing THAT is what you're using now, and THAT is why the XML can't be validated - the parser attempts to use DTD, but it sees it isn't supported.Consider using any of the successful validators if possible. After all, these are bugs in MSXML's SAX implementations, and there's nothing you can do about them (except maybe report them to Microsoft if you can).
Link to comment
Share on other sites

All validators that I tried (within Stylus Studio I must say) completed with no particular error messages.SAXON's Schema validator, JAVA's built in, MSXML 6.0 DOM, .NET XML and XSV all say it's valid.For some reason, MSXML 4.0 DOM said there's an error, but it didn't specified what.MSXML 4.0 SAX crashes... I'm guessing that's the kind of validator you used, since this crash appears to be duplicateable.MSXML 6.0 SAX said "warning: Msxml2.SAXXMLReader.6.0 does not support DTD validation"... so I'm guessing THAT is what you're using now, and THAT is why the XML can't be validated - the parser attempts to use DTD, but it sees it isn't supported.Consider using any of the successful validators if possible. After all, these are bugs in MSXML's SAX implementations, and there's nothing you can do about them (except maybe report them to Microsoft if you can).
Yes, I'm using MSXML6.0 SAX.Thank you very much for your help.
Link to comment
Share on other sites

  • 1 year later...
With the kind of error you're getting, I think you may instead be experiencing a crash of MSXML 4.0.Could you by any chance use MSXML 6.0 instead?
reference http://forums.devx.com/archive/index.php/t-97477.htmlin vb 6.0 i am using msxml4 for validating against the xsdthis is the code i haveDim xmlschema As MSXML2.XMLSchemaCache40 Dim objXML As MSXML2.DOMDocument40 Dim xmldom As MSXML2.DOMDocument40'Dim xmlschema As MSXML2.XMLSchemaCache30Set xmlschema = New MSXML2.XMLSchemaCache40xmlschema.Add "abc", "c:\xml\schema.xsd"'Create an XML DOMDocument object.Set xmldom = New MSXML2.DOMDocument40'Assign the schema cache to the DOM document.'schemas collection.Set xmldom.schemas = xmlschema'Load books.xml as the DOM document.xmldom.async = Falsexmldom.Load "c:\xml\12.xml"'Return validation results in message to the user.If xmldom.parseError.errorCode <> 0 ThenMsgBox xmldom.parseError.errorCode & " " & _xmldom.parseError.reasonElseMsgBox "No Error"End IfExit SubErrHandler:MsgBox (Err.Description)xmlschema.Add "abc", "c:\xml\schema.xsd" in this line i just added abc, is anything frmxsd file to be referenced over therewhen i run it i am getting error ---------------------------Project1----------------------------2146697210 The system cannot locate the object specified.---------------------------OK ---------------------------how to resolve it & if the sml is not matching te xsd it shld throw a proper error msg with the reason
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...