xsl-list
[Top] [All Lists]

RE: [xsl] Template matching with multiple namespaces

2009-03-20 05:20:30
My preferred approach to this is to first normalize the document to get rid
of trivial variations such as the choice of namespace, and then feed it into
a transformation that only handles the normalized form. Generally this
reduces the complexity and increases the reusability of your code. It's just
one example of the pipeline design pattern at work.

Michael Kay
http://www.saxonica.com/
 

-----Original Message-----
From: Tony Rowe [mailto:tony(_dot_)rowe(_at_)listech(_dot_)com(_dot_)au] 
Sent: 20 March 2009 03:19
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Template matching with multiple namespaces

Hi,

I have a stylesheet which works with one namespace, prefix 
say 'lml'. I now want the same stylesheet to work on 
documents under another namespace, say lml10.

Here is my namespace defs...

<xsl:stylesheet version="1.0"
 xmlns:lml=...
 xmlns:lml10=...
 xmlns:msxsl=...
 xmlns:xsl="...
 >

Now the stylesheet does, of course match nodes such as

<xsl:apply-templates select=".//lml:LandXML" />

But I want it to also match on

<xsl:apply-templates select=".//lml10:LandXML" />.

How can I set up some variable to allow me not to have to 
duplicate code?

This doesn't work...NodeTest expected.
<xsl:apply-templates select=".//{$namespacevariable}:LandXML" />

Or is there a better way to get the one stylesheet to work 
over multiple namespaces?

I am using XSLT 1.0 still because I need to use the MSXML parser 6.0.

Tony

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--