[xsl] Optional namespace declaration in XML document

Subject: [xsl] Optional namespace declaration in XML document
From: "h e ayestaran" <H.E.Ayestaran@xxxxxxxxxxxxxxx>
Date: Tue, 28 Feb 2006 15:52:41 -0000
Hi,

Is there any way to have one XSLT 1.0 stylesheet handle situations where the
XML input has different namespace declarations? In particular, I want to be
able to use the same stylesheet to parse data which (because the standard is
still only loosely supported by the various packages that claim to support it)
can contain different namespace declarations (or no declaration at all) in the
XML file. For all intents and purposes, the data structure is the same,
regardless of the namespace declared. For example the data might be:

<mydata xmlns="myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="myns myns.xsd">
  <mydataitem>sample data</mydataitem>
 </mydata>

or

<mydata xmlns="otherns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="otherns otherns.xsd">
  <mydataitem>sample data</mydataitem>
</mydata>

or simply

<mydata>
  <mydataitem>sample data</mydataitem>
</mydata>

(it's possible I made a mistake there, as it is obviously fictitious data). I
can think of ways to get around the problem, but it seems ludicrously
complicated. Is there a simple solution? Cheers,

Enrique

Current Thread