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

Subject: [xsl] How to change namespace prefixes in a import file hierarchy? Or at least append som pattern?
From: "Ben Stover" <bxstover@xxxxxxxxxxx>
Date: Mon, 21 Dec 2009 13:35:59 +0100
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

Current Thread