Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Type Mismatch Using ScemaCache

Status
Not open for further replies.

CraigB1

Programmer
Joined
Mar 15, 2004
Messages
4
Location
GB
Hi All,
tried posting in XML with no luck,

I am trying to use a DTD to validate an xml file my app loads. I am using MSXML 3.0 and xmlSchemaCache, the code I use is almost straight from the msdn help file:

'load string into XML DOM
Set objXMLDoc = New MSXML2.DOMDocument
Set objSchemaCache = New MSXML2.XMLSchemaCache

** objSchemaCache.Add "", App.Path & "\ryder.dtd" **

Set objXMLDoc.schemas = objSchemaCache

objXMLDoc.async = False
objXMLDoc.loadXML (strXMLString)

Select Case objXMLDoc.parseError.errorCode

But when I try and load my perfectly valid xml and DTD I get a type mismatch on the ** line above.

I have tried it with the files from the Microsoft example and it works fine, however I dont use namespaces! but according to the help file objSchemaCache.add can have the namespace field left blank as above, but apparantly not!!

I am really confused, do I have to use namespaces in order for VB to be able to validate it? why? If not what else could be causing the type mismatch, and ultimatley I have no intention of using namespaces and so how do I go about validating using a dtd without namespaces in VB??

P.S I know the schema and XML are well formed and valid because if I dont use the schemaCache and use 'validate on parse' property and hard code the dtd location into the xml file, it parses fine. However it is not gona be possible for me to do this because of the app nature.

Thanks in advance

Craig
 
Do this and see what the value is:
Code:
Debug.Print App.Path & "\ryder.dtd"

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Hi Chip, cheers for the reply,

It gives the following which is the correct path to the DTD

D:\dev\DBUserIE\VB\ryder.dtd

 
It also still gives the error even if I use a filename that doesnt exist!!?

Does this mean its not possible to do if its nothing to do with the dtd? And a namespace has to be passed? surely not??


I will have to hard code the dtd into the start of every xml file the app creates then use it to validate itself when loading using 'validate on parse = true'

If anyone can tell me how to load a DTD and validate an xml file against it in VB6 using MSXML 3 please post I will monitor this thread.

Many thanks

Craig
 
Um...the good news is that it works fine here. The bad news is that I'm using exactly the same code as you. Why is this bad news? Well, because it means I can't see anything wrong with your code and so cannot advise on how you might move forward on this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top