[xsl] Matching all elements in a namespace

Subject: [xsl] Matching all elements in a namespace
From: Kjetil Kjernsmo <kjetil@xxxxxxxxxxxx>
Date: Sat, 7 Feb 2004 21:40:20 +0100
Hello World!

I just subscribed, as I heard this is _the_ list for XSLT "user" 
questions? :-)

My question feels like a common requirement, and therefore a FAQ, but I 
really can't find the answer... 

To take an example, my XML contains a few XHTML elements, and I figured 
I'll just declare them in the XHTML namespace, and then copy-of all 
elements in this namespace to the result document, with the namespace 
declaration and all... (later, I want to do similar things with other 
namespaces).

So, the obvious thing felt like something like...:
<xsl:template match="namespace-uri() = 
'http://www.w3.org/TR/xhtml1/strict'">
	      <xsl:copy-of select="."/>
</xsl:template>

...and I've tried numerous variations over this theme over the past 
couple of weeks, but it doesn't "work". 

I'm developing on the top of AxKit, so I'm using XML::LibXSLT and 
Apache::AxKit::Language::LibXSLT to do the work. I could use Sablotron 
also, however. 

Also complicating matters, is that this is just a part of a pipeline, 
starting with AxKit's XSP page. So, I am to a certain extent at the 
mercy of what AxKit will give me, which again implies that whatever I 
do should work if I have a xmlns attribute on the root element, and 
shorthand prefixes on the rest, or a xmlns attribute on whatever 
elements there are in that namespace, or, well, you get the idea... :-) 

I figured it should be most robust to match on the namespace-uri rather 
than a prefix shorthand, since the latter can be chosen rather 
arbitrarily by an author, whereas the namespace-uri has a more clearly 
defined meaning. Is this reasoning sound?

BTW, if anybody's interested (ok, it is a shameless plug), the 
application I'm developing I've called TABOO, I'm introducing a bit 
more abstraction and OO design, and the first thing I'm building is a 
news-site. I've released something allready: 
http://www.kjetil.kjernsmo.net/software/TABOO/

Cheers,

Kjetil
-- 
Kjetil Kjernsmo
Astrophysicist/IT Consultant/Skeptic/Ski-orienteer/Orienteer/Mountaineer
kjetil@xxxxxxxxxxxx  webmaster@xxxxxxxxxx  editor@xxxxxxxxxxxxxxxxxxxxxx
Homepage: http://www.kjetil.kjernsmo.net/        OpenPGP KeyID: 6A6A0BBC


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread