[xsl] RE: Merging an imported xsd schema into the importing xsd schema with XSLT?

Subject: [xsl] RE: Merging an imported xsd schema into the importing xsd schema with XSLT?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 13 Dec 2004 14:59:45 -0000
You haven't addressed my question: if the two schemas have the same target
namespace, then it's illegal for one to import the other, while if they have
different target namespaces, then it's not possible to merge them except by
renaming all the components, and you haven't indicated how you want to do
this.

There's no problem having two namespace prefixes in a document that refer to
the same namespace URI. I think the real problem is your remark:

> Furthermore I have to prepend all unprefixed, naked elements
> and attributes with a new default namespace prefix "new".

in other words, you are indeed renaming the components of the imported
schema so they go in a new target namespace.

However, your examples confuse me. What are elements like <dum:person> doing
in your schema? I would expect to see things like <xs:element
name="dum:person">.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Matt Adams [mailto:mattad@xxxxxxxxx] 
> Sent: 13 December 2004 14:22
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Merging an imported xsd schema into the importing 
> xsd schema with XSLT?
> 
> Hello,
> 
> what I meant was the following scenario:
> 
> first.xsd:
> <schema ... xmlns:dum="http://www.dummy.com/myns"; >
> <import namespace="http://www.karl.com/"; 
> schemaLocation="second.xsd" />
> <dum:person  myattr1="xxx" dum:myattr2="yyy" />
> ...
> </schema>
> 
> second.xsd:
> <schema .... xmlns:bla="http://www.dummy.com/myns";
> <bla:profession bla:exper="12" title="MSc"/>
> ...
> </schema>
> 
> Now, when I merge second.xsd into first.xsd it looks
> (after the first step !!) like:
> 
> combined.xsd:
> <schema ... xmlns:dum="http://www.dummy.com/myns"; 
>             xmlns:bla="http://www.dummy.com/myns";
>             namespace="http://www.karl.com/";>
> <bla:profession bla:exper="12" title="MSc"/>
> ...
> <dum:person  myattr1="xxx" dum:myattr2="yyy" />
> ...
> </schema>
> 
> But the namespace prefix "bla" covers the same namespace as the prefix
> "dum". So I have to adjust all bla prefixes to dum in order 
> to get the final
> version. Furthermore I have to prepend all unprefixed, naked elements
> and attributes with a new default namespace prefix "new".
> 
> The final schema should be (from my point of view):
> 
> <schema ... xmlns:dum="http://www.dummy.com/myns"; 
>             xmlns:new="http://www.karl.com/";>
> <dum:profession dum:exper="12" new:title="MSc" />
> ...
> <dum:person  myattr1="xxx" dum:myattr2="yyy" />
> ...
> </schema>
> 
> Again: How do I do this conversion with XSLT?
> 
> Matt
> ----
> Michael Kay wrote:
> > As the subject said I want to textually merge an imported schema 
> > sub.xsd into the importing schema main.xsd.
> > Afterwards only one schema file should exist.
> >
> > Is there a simple way in XSLT (2.0) to achieve this with XSLT?
> 
> If one schema document imports another, then they must have 
> different target
> namespaces. Are you trying to combine two target namespaces 
> into one? If so,
> this is not just a "textual merge", it's a rather delicate 
> operation that
> involves changing the names of the objects in the imported 
> schema. Perhaps
> you can give us a (short) example of what you expect to happen.
> 
> Michael Kay
> http://www.saxonica.com/
> ------------
> Orig:
> >>As the subject said I want to textually merge an imported
> >>schema sub.xsd into the importing schema main.xsd.
> >>Afterwards only one schema file should exist.
> >>
> >>Is there a simple way in XSLT (2.0) to achieve this with XSLT?
> >>
> >>Otherwise I guess I have to include the imported schema file
> >>and to replace the old namespace prefixes by these prefixes 
> used in the=20
> >>main.xsd.
> >>
> >>Is the namespace replacement sufficient or do I have something more?
> >>
> >>How do I replace the prefixes with XSLT?
> >>
> >>Matt
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm

Current Thread