[xsl] match + default namespace

Subject: [xsl] match + default namespace
From: philippe drix <phdrix@xxxxxxx>
Date: Fri, 16 Nov 2001 16:03:22 +0100
Hi!
Sorry if my question is FAQ, but I found nothing in the archive.

I have a small xml file, like this :

------------------------------------------------------------
<foo>
  <table xmlns="http://abcd"; border="1" bgcolor="#E0E0E0">
	 <caption align="right" class="listingTitle">bar.java</caption>
	 <tr>
		<td>
			<pre class="programlisting">
import java.io.*;
public class bar {
		...
	}
}</pre>
			</td>
		</tr>
	</table>
</foo>
--------------------------------------------------------------

I want to write a XSL Transformation, with a rule matching <pre> like
this :


    <xsl:template match="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>
    
    
and a another rule like this :

    <xsl:template match="*">
		<xsl:copy>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates/>
		</xsl:copy>
		
    </xsl:template>
    
    
The problem is that the pattern "pre[@class='programlisting']" never
matches the tag <pre>.

Why ? Because it is too much selective. Even if I relax it, like that :
match="pre", it is still too selective.
To get the match, I must write : match="*[name() = 'pre']".

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 ...

Any idea ?

Best regards,
Philippe Drix
www.objectiva.fr

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


Current Thread