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

Re: including external xml files in an instance and validating across the files

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 4 Feb 2002 13:21:14 +0000
Message-ID: <10613252079.20020204132114@jenitennison.com>
To: Rolf Russell <rolf@powermarket.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
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 Monday, 4 February 2002 08:21:16 GMT

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