[xsl] RE: Template matching with multiple namespaces

Subject: [xsl] RE: Template matching with multiple namespaces
From: "Laura Porter" <Laura.Porter@xxxxxxxxx>
Date: Fri, 20 Mar 2009 11:51:52 -0000
Tony,

You need to use the union operator, i.e.:

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

Note that | is not an "or" operator - it creates a union of the two
nodesets.

As a side note, use of // is inefficient - don't use it if you can avoid
it.

Laura.



------------------
Date: Fri, 20 Mar 2009 14:18:58 +1100
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: "Tony Rowe" <tony.rowe@xxxxxxxxxxxxxx>
Subject: Template matching with multiple namespaces
Message-ID:
<387B30B1FAC2384AB527E8AF1DDADC482E77E4@xxxxxxxxxxxxxxxxxxxxx>

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=3D"1.0"
 xmlns:lml=3D...
 xmlns:lml10=3D...
 xmlns:msxsl=3D...
 xmlns:xsl=3D"...
 >

Now the stylesheet does, of course match nodes such as

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

But I want it to also match on

<xsl:apply-templates select=3D".//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=3D".//{$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

------------------------------


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on
it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

Current Thread