xsl-list
[Top] [All Lists]

[xsl] How to change namespace prefixes in a import file hierarchy? Or at least append som pattern?

2009-12-21 07:36:36
How to append a pattern to a namespace prefix? How to change a namespace prefix 
in a import file hierarchy?

Assume there is a directory (tree) of XSD schema files which start with ONE 
single "root" XSD 
schema file "root.xsd" and which in turn imports other, related XSD schema 
files.

Regarding the used, embedded namespaces and their prefix it looks like similar 
to:

root.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
     xmlns:mypref1="http://www.somedomain.com/foo/bar/";
     ...
     xmlns:other22="http://www.somedomain.com/blah/";
     ....>
     
     <xsd:import namespace="http://www.somedomain.com/foo/bar/"; 
                 schemaLocation="myfoobar/subschema1.xsd"/>
     ....
     <xsd:import namespace="http://www.somedomain.com/blah/";
                 schemaLocation="myblah/subschema22.xsd"/>
                 
     <xsd:element name="..."  type="mypref1:myelement111Type"/>
     <xsd:element name="..."  type="other22:myelement222Type"/>
     ...
     

Keep in mind that this is a simplified sample. In real life I could have a 
system of dozends of imports,
hundreds of namespace prefixes and thousands of elements. 

Now I want to change all prefixes "mypref1" to "newpre7". I could this manually 
but due to the amount
of occurencies and the necessary changes this is not feasible. 
Furthermore I dont want to use an text editor replace function because this 
could be ambigious and 
not much simpler.

I would like to use a XLST script which would do the job for me (after changing 
just a
"from" and a "to" pattern inside this XSLT script.

Is this possible somehow?

All the prefix occurencies should be changed in the prefix definition and the 
usage places (e.g. <xsd:element>)
in all files of the import hierarchy.

How can I do this?

If a pure change is not possible: Can I at least append some postfix to a 
prefix (e.g. add

from: mypref1
to:   mypref1new

Thank you
Ben












--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>