RE: [xsl] Optional namespace declaration in XML document

Subject: RE: [xsl] Optional namespace declaration in XML document
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Feb 2006 11:56:48 -0500
At 2006-02-28 16:24 +0000, Michael Kay wrote:

> Is there any way to have one XSLT 1.0 stylesheet handle
> situations where the XML input has different namespace
> declarations?

My preferred approach to this is to write a two pass transformation. The
first part moves the data into the "correct" namespace, the second part does
the real transformation. This is much easier and cleaner than trying to
transform data which can arrive in a variety of forms.

In my customer's situation I was using stylesheet association and pointing to the stylesheet that would render my instance being edited. Only one pass is available in this situation, without having to use node-set() and having to put into memory a transformed instance to then be fed into the process again.

Each copy of the read-only stylesheet library was configured by the entities for the given namespaces, so all I had to do was point to the appropriate subdirectory's copy and everything worked.

Oh, and having the entity strings available for URI strings made it easy to provide the correct string to instructions like <xsl:element> when doing transformations that augmented the input instances.

I'm a big fan of using entities to help with the management of my XML instances.

. . . . . . . . . Ken

At 2006-02-28 11:04 -0500, I wrote:
Every stylesheet fragment pulls in a common set of general entity string declarations with which namespaces are declared. The parameter entity with these general entity declarations is in an ancestral directory of the stylesheet library.

By installing the read-only stylesheet library in two different locations of the file system, and changing the parameter entity file at each location that is "above" the read-only bits, then all of the stylesheets support the new namespace.

Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-03-13/17
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05
Legal business disclaimers:

Current Thread