Re: Trying to validate a sample xml file against a schema I am develo ping.

[inline] ( Look for <MJG></MJG> )
----- Original Message -----
From: "Michael Burns" <Michael.Burns@sas.com>
To: "Martin Gudgin" <marting@develop.com>
Cc: "Michael Burns" <michael.burns@sas.com>; <xmlschema-dev@w3.org>
Sent: Wednesday, October 11, 2000 6:08 PM
Subject: Re: Trying to validate a sample xml file against a schema I am
develo ping.


I  previously got xsv to validate some sample xml files (can't remember
exactly which ones though),
but cannot get it to validate much of anything now.

I have put several attempts on my personal web site:

http://www.realtime.net/~mburns/po.xml
cut and paste directly out of the primer, and the schema for it:
http://www.realtime.net/~mburns/po.xsd
The only thing I changed in the xml file was to add
    xmlns:xsi = "http://www.w3.org/2000/10/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation = "po.xsd"

That brings up one of my burning questions:   Given the initial contents
of po.xml and po.xsd as shown
in the primer, how in the world is a parser supposed to connect the two?

What are all or some or the
recommended way for a parser to determine which schema to use.

<MJG>
The Working Draft is careful not to specify this because we did not wish to
limit schema processors with respect to where they find schemas.

One company's schema processor may be initialised with a set of schema files
when it first starts, maybe these are the only schemas the company in
question cares about. Other processors may always look for
xsi:schemaLocation ( or xsi:noNamespaceSchemaLocation ). Others may
dereference namespace URIs... Some may do all of these and more. The point
is that although the link between the instance and the schema is always the
namespace URI of the instance, how a schema processor finds the schema for a
given namespace is entirely up that processor.
</MJG>

I added
these two attributes to
the top level element in po.xml and it still does not seem to find the
schema and use it.   When I run
the xerces parser on this with schema validation turned on it complains
that:

[Error] po.xml:6:4: Element type "purchaseOrder" must be declared.
[Error] po.xml:7:26: Element type "shipTo" must be declared.
[Error] po.xml:8:15: Element type "name" must be declared.
[Error] po.xml:9:17: Element type "street" must be declared.
[Error] po.xml:10:15: Element type "city" must be declared.
[Error] po.xml:11:16: Element type "state" must be declared.
...

If I rename the po.xsd file so it can't be found, then xerces does not
complain,
so it appears it is not looking for the specified file.  What am I
missing?

It appears clear to me that the xerces parser only recognizes the 1999
spec
and I am guessing that the xsv only recognizes the 2000/10 spec.

<MJG>
I've not done much with Xerces yet so I don't know how they locate schemas,
I'll try and look at this over the next week and get back to you. You are
correct that at the moment Xerces supports the
http://www.w3.org/1999/XMLSchema namespace and not
http://www.w3.org/2000/10/XMLSchema. Apache have said that they will update
Xerces but it is likely to take them a few months to do so.

XSV has support for both http://www.w3.org/1999/XMLSchema ( which you will
find at[1] ) and http://www.w3.org/2000/10/XMLSchema ( which you will find
at[2] )
</MJG>

I have created a bunch of test cases using both the sample that comes
with
xerces (personal-schema.xml + personal.xsd) and the po.xml + po.xsd that

I copied from the primer.  I have created both 1999 and 2000 versions of
each
and still have been having poor luck getting much to validate properly.

All of these are in http://www.realtime.net/~mburns/

1999 spec samples:

http://www.realtime.net/~mburns/po99.xml + po99.xsd                   <-
copied from primer and changed to 1999 format
http://www.realtime.net/~mburns/personal-schema.xml + personal.xsd
< - works with xerces as expected
http://www.realtime.net/~mburns/personal-schema-fails.xml + personal.xsd
<- xerces reports errors as expected

2000 spec samples:

http://www.realtime.net/~mburns/po.xml + po.xsd                   <-
copied from primer
http://www.realtime.net/~mburns/personal-schema-2000.xml +
personal-2000.xsd
http://www.realtime.net/~mburns/personal-schema-2000-fails.xml +
personal-2000.xsd

Those last two I can get to run through xsv but don't understand the
results,
it does not seem to be validating and I don't understand why not:

<MJG>
The schema at http://www.realtime.net/~mburns/personal-2000.xsd is invalid
per http://www.w3.org/2000/10/XMLSchema which I think explains why you are
getting the output you are from XSV.

You need to amend the anonymous simpleType definition inside the attribute
'contr' inside the anonymous complex type inside the element decl 'person'
to read as follows;

    <simpleType>
      <restriction base='string'>
        <enumeration value='true'/>
        <enumeration value='false' />
      </restriction>
    </simpleType>

I'm also curious as to why you didn't just use a restriction of boolean
here?
</MJG>


- - - - - - - - snip - - - - - - - - - -

Schema validating with XSV 1.166/1.77 of 2000/09/28 15:54:50

• Target: http://www.realtime.net/~mburns/po.xml
   (Real name: http://www.realtime.net/~mburns/po.xml
    Length: 1106 bytes
    Last Modified: Wed, 11 Oct 2000 15:28:00 GMT
    Server: Apache/1.2.5)
• docElt: {None}purchaseOrder
• Validation was strict, starting with type {None}:PurchaseOrderType
• schemaLocs: None -> po.xsd
• The schema(s) used for schema-validation had no errors
• instanceAssessed: true
• No schema-validity problems were found in the target




Low-level XML well-formedness and/or validity processing output


Warning: Document has no DTD, validating abandoned
 (detected at end of prolog of document
http://www.realtime.net/~mburns/po.xsd)




Schema resources involved

Attempt to import a schema document from
http://www.realtime.net/~mburns/po.xsd for no namespace, succeeded

/- - - - - - - - snip - - - - - - - - - -

At least it seems to be finding the po.xsd, but this tells me that did
not validate the schema.

<MJG>
Ignore the "Warning: Document has no DTD, validating abandoned " this just
means that the underlying *XML* parser did not validate the schema ( or the
instance ) against a DTD. Look at the "The schema(s) used for
schema-validation had no errors " message to figure out whether your schemas
are OK or not.
</MJG>

<SNIP/>

I would also like to have a copy of xsv locally so I can use it offline.

There was a hint that it was possible but not easy.  I got ltxml to
build locally,
what else is required for xsv?

<MJG>
You need to install Python 1.6[3] and then download the CVS source tree for
XSV[4]. You can run it with

    python <pathtoxsvsource>\applyschema.py -s <stylesheet> <instance>
<schema>
</MJG>

Thanks for all your help.

<MJG>
NO worries...

Regards

Martin


[1] http://www.w3.org/2000/06/webdata/xsv
[2] http://www.w3.org/2000/09/webdata/xsv
[3] http://www.python.org
[4] http://dev.w3.org/cvsweb/xmlschema/
</MJG>

Received on Saturday, 14 October 2000 15:59:16 UTC