[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

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

or simply

  <mydataitem>sample data</mydataitem>

(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,


Current Thread