Re: [xsl] filtering elements using identity transform

Subject: Re: [xsl] filtering elements using identity transform
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 31 Mar 2005 15:39:43 +0100
> An article I read on the web 
Not a good article I would guess.

> discouraged using local-name b'cos it strips the prefixes.

using local-name makes sense iff you want to just match on the local
name, ignoring namespaces, which you would want to do here, if you can't
change your input format. So this is a possibility.

> The recommended one was
> <xsl:template match="node()[not(starts-with(name(), "b:"))].

No, that form is almost always (actually I would say always) a bad idea
as it is matching on a specific prefix rather than the namespace name
(ie the URI associated with the namespace).

Really, if you have control over your input format you would be in a
much better position if you used xhtml for the html elements 
and the v3 namespace for the v3 elements, used like this

<html xmlns=""; xmlns:v3="urn:hl7-org/v3">

          <v3:slideshow author="Yours Truly" title="Sample Slide Show" date
="Date of publication"  >

By using a v3: prefix on the slideshow element uyou avoid polluting the
nested elements into that namespace so they are still xhtml.

In the XSLT you then no longer needs separate templates for all the html
elements you can simply do

<xsl:template match="h:*" >
 an xhtml element was here

<xsl:template match="v3:*">
 an v3 element is copied
 <xsl:copy-of select="@*"/>

so long as you have


on your xsl:stylesheet so these namespaces are in scope in the


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread