[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: match + default namespace

Subject: Re: match + default namespace
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 16 Nov 2001 15:19:22 +0000
xslt match default namespace
Hi Philippe,

> So, match="pre" is not the same than match="*[name() = 'pre']"
> Actually, this oddity disappears if I suppress the default namespace
> declared with the <table> element.
>
> Why ? This time, I have not really the true answer ...

XPath is namespace aware. When you say match="pre" or select="pre" you
are matching or selecting a 'pre' element *in no namespace*. To match
or select an element that is in a namespace, as the pre elements are
in your example, you have to declare the namespace in the stylesheet
with a prefix (e.g. 'abcd') and then use that prefix in your pattern
or expression to match or select the element (e.g. match="abcd:pre").

So try:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:abcd="http://abcd">
                
    <xsl:template match="abcd:pre[@class='programlisting']">
        <pre class="programlisting">
             <xsl:call-template name="replace_first_tabs_on_all_lines">
                        <xsl:with-param name="codeSource" select="." />
                </xsl:call-template>
        </pre>
    </xsl:template>

...
</xsl:stylesheet>

You should be very careful using name() = 'pre' because if someone
used a different prefix in the source document, the test would not be
true any more (one of the points of namespaces being to allow you to
use whatever prefix you like with a namespace).

This is a common error that will hopefully be alleviated a little in
XSLT/XPath 2.0 by allowing people to determine the namespace
associated with unprefixed element names in patterns and expressions,
rather than having it fixed to no namespace as it is in XSLT/XPath
1.0.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.