Solved

Incorrect definition for root element in schema

Posted on 2001-09-17
22
2,446 Views
Last Modified: 2013-11-19
I'm attempting to programatically validate an xml file using a schema(.xsd). My code is shown at the bottom. When I execute that code I get the above error at the "oxmlSchemaCache.Add" line. XSDDoc is a global variable defined as an MSXML2.DOMDocument which I successfully read as xml in another part of the program. The first part of the schema looks like the following. What is wrong?

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">



' Code
    Dim oxmlTempDoc As DOMDocument
    Dim oxmlSchemaCache As XMLSchemaCache

    Set oxmlTempDoc = New DOMDocument
    Set oxmlSchemaCache = New XMLSchemaCache

    ValidateXML = True

    oxmlTempDoc.async = False
    oxmlTempDoc.validateOnParse = False
   
    oxmlSchemaCache.Add "", XSDDoc
    Set oxmlTempDoc.schemas = oxmlSchemaCache
    oxmlTempDoc.Load gstrTempFileName
   
    If oxmlTempDoc.parseError <> 0 Then
        Err.Raise vbObjectError + 1, "PO Validation", oxmlTempDoc.parseError.reason

        ValidateXML = False
        Exit Function
    End If

    Set oxmlTempDoc = Nothing
    Set oxmlSchemaCache = Nothing
0
Comment
Question by:Martin Liss
  • 10
  • 6
  • 3
  • +3
22 Comments
 
LVL 3

Expert Comment

by:slok
ID: 6488880
did you save the schema or the XML file in UTF-8 encoding?
try opening the files in Notepad and do a Save-As,
you should be able to see the option UTF-8, ANSI, Unicode etc..

just a thought
0
 
LVL 3

Expert Comment

by:slok
ID: 6488882
or rather, if UTF-8 is the culprit, will ANSI works?
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6488886
When you refer to notepad, do you mean the "XML Notepad"? If so I don't have it. BTW, I didn't create the schema.
0
 
LVL 3

Expert Comment

by:slok
ID: 6488888
no, just the normal NOTEPAD
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6488986
When I do Save As with my Notepad, it doesn't give me any other options except *.txt
0
 
LVL 3

Expert Comment

by:slok
ID: 6489092
maybe we are on diferent OS.

I'm using win2k Professional.
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6489114
I'm using NT.

When I change UTF-8 to ANSI, I get a "System does not support the specified encoding". :(
0
 
LVL 3

Expert Comment

by:slok
ID: 6489162
what if you remove    elementFormDefault="qualified"


think the namespace for XML Schema has changed quite a
fair bit. So, you might need to check what the parser
supports.


eg.

Xerces 1.3 only takes http://www.w3.org/2000/10/XMLSchema and
http://www.w3.org/2000/10/XMLSchema-instance

Xerces 1.4 only takes http://www.w3.org/2001/XMLSchema and
http://www.w3.org/2001/XMLSchema-instance
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6493593
Removing elementFormDefault="qualified" makes no difference. I'm an xml novice; what is Xerces?
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6494031
I've increased the points since this obviously isn't easy. Do you code in VB? If so would you be willing to try to see if you could get my schema to work if I sent it to you.
I can be reached at martin.liss@icn.siemens.com
0
 
LVL 3

Expert Comment

by:slok
ID: 6494332
Xerces is XML parsers. Similiar to what MSXML is.

More info. on Xerces on
http://xml.apache.org/

though, I would think you would be using MSXML.



0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:wbradney
ID: 6494999
MartinLiss,

Can you post the entire schema?

Regards,
WMB
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6495013
It's huge. If you email me at martin.liss@icn.siemens.com I will send it to you.
0
 
LVL 6

Accepted Solution

by:
wbradney earned 150 total points
ID: 6495040
MartinLiss,

Having now read the rest of the thread here, I think I see the problem.

I'm not a Microsoft-technology expert, but the problem is almost certainly that Microsoft's MSXML technology does not follow the W3C XML Schema standard (shocker!). Microsoft uses a schema language based upon the now defunct XML-Data specification, called Microsoft XML Data Reduced (XDR). See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmrefxmlschemareference.asp for details. Microsoft submitted this spec to the W3C back in 1998, but it was not adopted. Instead the W3C recommended XML Schema (http://www.w3.org/TR/xmlschema-0/) in May.

I'm not sure what MSXML3 is capable of validating, but I wouldn't be surprised if it didn't understand XML Schema content models.

BTW, Apache Xerces (http://xml.apache.org) is compliant with the current W3C XML Schema specification, as are several other parsers.

Regards,
WMB
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6495045
It's huge. If you email me at martin.liss@icn.siemens.com I will send it to you.
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6495073
Changing to a different parser is not an option for me at this point. Are you saying that unless I can change the parser that I can't validate an xml file with my schema? I don't understand how that could be since XMLSpy can validate my xml file using my schema.
0
 
LVL 6

Expert Comment

by:wbradney
ID: 6495133
Martin,

XMLSpy probably doesn't use MSXML...

If I'm right about MSXML not supporting XML Schema, I'm afraid you're out of luck, and Microsoft has misled someone else into believing that their products are standards-compliant.

Regards,
WMB
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6495162
Changing to a different parser is not an option for me at this point. Are you saying that unless I can change the parser that I can't validate an xml file with my schema? I don't understand how that could be since XMLSpy can validate my xml file using my schema.
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6498039
Martin:

One thing to check: what version of MSXML are you running? Are you running the default version which comes as part of Internet Explorer 5.x? If so, try updating to the newest version of MSXML. There are instructions on how to do so at:

http://www.bayes.co.uk/xml/index.xml?/xml/utils/instalmsxml.xml

HTH

--Steve
0
 
LVL 45

Author Comment

by:Martin Liss
ID: 6543467
Unfortunately you are correct, so I guess it's only right that I award you the points.

(I hope you don't mind the grade.)
0
 

Expert Comment

by:CLT-Services
ID: 11540657
Hi All,

I have been having exactly the same problem (coding with Delphi and importing the TypeLib from MSXML5.DLL).

In fact I only subscribed to EE in order to be able to see this thread of answers to Martin Liss's question, but, just as Martin, changing to another parser was not an option. Browsing through MSDN samples I finally did find a working sample :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/XSD_HDI_Validate_schemaCacheJs.asp

Yet, comparing this code with my code, there didn't seem to be much difference.

I have been two days (not full time hopefully) without finding what it was and then light went on :
I was using the  '{373984C9-B845-449B-91E7-45AC83036ADE}' classID which stands in for XMLSchemaCache
It only works if you use the ClassID '{88D969E7-F192-11D4-A65F-0040963251E5}' (MSXML2.XMLSchemaCache.5.0)

It is a matter of version for your MSXML parser yet not, as I thought, of the version installed but rather of the version called !!!
0
 
LVL 30

Expert Comment

by:Axter
ID: 12885115
>>It is a matter of version for your MSXML parser yet not, as I thought, of the version installed but rather of the version
>>called !!!
FYI:

Actually, it seems to be both.
MSXML2.XMLSchemaCache.5.0 is not available in MSXML4.DLL and below.

I'm using MSXML3.DLL, with XMLSchemaCache30, and it still fails.

I believe XMLSchemaCache40 should work, but you need MSXML4 or above (MSXML5.DLL).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Nessus Scan 1 64
Create associate webpages / websites 3 52
JQuery tracking event. 3 39
PHP and Soap 3 27
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now