W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

RE: including external xml files in an instance and validating ac ross the files

From: Rolf Russell <rolf@powermarket.com>
Date: Tue, 5 Feb 2002 21:52:44 -0500 (EST)
Message-ID: <BBCC7FA3CF18D511B30D0002B3312B6C7419A6@excserve1.powermarket.com>
To: "'Jeni Tennison'" <jeni@jenitennison.com>
Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Thanks for your quick help Jeni.  

I took your wrapper file DTD idea and was able to add a DTD to my
invoice.xml file that references the partlist.xml file, but unfortunately I
cannot validate the invoice.xml document if I add the KEY-KEYREF
relationship that I described.  I get the following error:  "Undefined key
values for keyref identity constraint 'Item-PartNumber-KeyRef' - the values
refered to by the field selector must match existing unique/key values."
This seems to indicate that my XML validation engine (XML Spy 4.2) does not
dereference external entity references before validation.  I checked this by
pasting in the actual xml instead of referencing it and the error went away.
Is it standard for all validation engines to not dereference, or dependent
on the engine?

Thanks again,

--Rolf Russell





-----Original Message-----
From: Jeni Tennison [mailto:jeni@jenitennison.com]
Sent: Monday, February 04, 2002 5:21 AM
To: Rolf Russell
Cc: 'xmlschema-dev@w3.org'
Subject: Re: including external xml files in an instance and validating
across the files


Hi Rolf,

> To explain my question it is probably best to give an example of the
> situation. Lets say that I have 2 types of xml documents: a
> partlist.xml including partnumber, description and other details,
> and an invoice.xml with a list of items including partnumber,
> quantity and cost. My company has 1 partlist.xml file but many
> invoice.xml files. I have defined xml schemas that validate each
> type of document independently, but would also like to validate the
> partnumbers across files (ie. make sure each partnumber in an
> invoice corresponds to a partnumber in my partlist). The best way
> seems to be to 'include' the partlist schema in the invoice schema
> and use KEY - KEYREF. My question is how do I then include/import
> the partlist.xml document in an invoice.xml document? I want to keep
> the files separate because of the many to 1 relationship.

One option would be to generate a wrapper file that defined entities
that pointed to the various smaller files:

<!DOCTYPE wrapper [
<!ENTITY invoice SYSTEM 'invoice.xml'>
<!ENTITY partlist SYSTEM 'partlist.xml'>
]>
<wrapper>
  &invoice;
  &partlist;
</wrapper>

You would have to define one of these wrapper files for each of the
invoices.

Or you could generate the same document with a simple XSLT stylesheet
applied to the particular invoice.xml document that you wanted to
check:

<wrapper xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xsl:version="1.0">
  <xsl:copy-of select="/" />
  <xsl:copy-of select="document('partlist.xml')" />
</wrapper>

You could then validate the resulting wrapper document with your
combined schema.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Thursday, 7 February 2002 16:45:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:26 GMT