[
Lists Home |
Date Index |
Thread Index
]
Thomas,
I have done this in two passes with XSLT. In my case, everything was in a
single big schema document, and I had to extract just the portion needed to
validate documents based on a single root element.
The schema document I was dealing with was big, but relatively simple.
The first pass went iteratively through the schema starting at the
definition of the root element of the instance. It copied all data type
definitions and element definitions, carrying out the same extraction
process on them. Here is a typical template:
<xsl:template match="xs:complexType[@name]">
<xsl:copy-of select="."/>
<xsl:apply-templates select=".//xs:element"/>
<!-- do the extensions and restrictions of simple and complex data
types -->
<xsl:apply-templates
select="/xs:schema/xs:complexType[@name=current()/*/*/@base]"/>
<xsl:apply-templates
select="/xs:schema/xs:simpleType[@name=current()/*/*/@base]"/>
</xsl:template>
This creates a document with all the definitions required, but many will be
repeated. The second stylesheet removes the repeats.
In this case, there was just a single target namespace. You have several,
which makes things substantially more complex. Not impossible - just harder.
I think one extra stylesheet and some script is needed.
Regards
Paul Spencer
Director
Boynings Consulting Ltd
http://www.boynings.co.uk
> -----Original Message-----
> From: Thomas B. Passin [mailto:tpassin@comcast.net]
> Sent: 31 July 2003 04:30
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] Extract A Subset of a W3C XML Schema?
>
>
> I have been asked what tools can extract a part of a schema. The overall
> schema is large, complex, and imports five or six other schemas
> into several
> target namespaces. The individual involved wants to create a
> smaller subset
> that contains everything that one project needs, for the purposes of
> instruction and training.
>
> The problem is how to get all the necessary pieces so that nothing is left
> out that is required for the schema to work. XML Spy can be helpful with
> its graphics, but there is no link from the graphics view to the
> text view,
> so it is hard to find the pictured piece of the XML for copying. You can
> do some degree of copying and pasting the graphics view blocks between
> schemas, but of course you have to keep track yourself of the
> bits you have
> already transferred. Also it is hard to be sure you have gotten
> everything
> you need.
>
> Does anyone know of such a tool? If not, any suggestions based on actual
> experience in doing this kind of task? It seems to me that
> finding all the
> dependencies within the schema and its imports would be the hardest part.
>
> Cheers,
>
> Tom P
>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>
|