On 10/02/2011 15:11, Philippe.Favrais@continental-corporation.com wrote:
Hello all,
i am a bit lost with what is possible and what not concerning the namespaces
i have 2 different input xml files having different namespaces and i would like to have a single xsl to read them

Here is an example of my problem

xml file 1:
<ROOT xmlns="http://myexample/2.10">
        <child1>abc        </child1>

xml file 2: (with a different namespace)
<ROOT xmlns="http://myexample/2.20">
        <child1>abcdef        </child1>

in my xslt, i would like to be able to handle both kind of file.
So far i was looking for to read the file name space at runtime and to change the default namepsapce dynamically but it seems not possible.
Does anyone know how to do that ?

This is a request for XSLT coding help, rather than anything specific to Saxon. There are many good places for such queries, for example the xsl-list at mulberrytech.com. Please take it there next time!

Usually if the namespace is different, then there are differences in the source documents as well (otherwise why would anyone change the namespace?). So my preferred approach is to preprocess one variant of the input format to the other variant, and then have the main stylesheet process only one variant. That way, the code to convert one variant to another is highly reusable, and it gives you good separation of concerns. However, if you really want to handle both input formats in one stylesheet, the construct *:ROOT, which selects any element with local name ROOT regardless of namespace, can be useful.

Michael Kay