RE: [xsl] 1 XSL for 2 XML

Subject: RE: [xsl] 1 XSL for 2 XML
From: Petr Mach3 <Mach3P@xxxxxxxxx>
Date: Mon, 14 Jun 2004 13:16:37 +0200 (CEST)
So, is it better to use
   <xsl:template match="f:MYTAB|MYTAB">
than
   <xsl:template match="*[local-name(.)='MYTAB']">
??

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:f="urn:schemas-cp-com:gen">
<xsl:output method="html" version="4.0"/>
<xsl:template match="/">
<html><body>
<xsl:apply-templates select="//f:MYTAB|//MYTAB"/>
</body></html>
</xsl:template>

<xsl:template match="f:MYTAB|MYTAB">
<table border="1">
<th>HEAD</th><th>
<xsl:value-of select="MYHEAD"/><xsl:value-of select="f:MYHEAD"/></th>
<xsl:apply-templates select="f:MYITEM|MYITEM"/>
</table>
</xsl:template>

<xsl:template match="f:MYITEM|MYITEM">
<tr><td>ITEM</td>
<td><xsl:value-of select="MYIT"/><xsl:value-of select="f:MYIT"/></td></tr>
</xsl:template>
</xsl:stylesheet>


> Selecting by local-name like this is not a very good idea, when all you are
> trying to do is to avoid specifying a correct namespace prefix. Firstly,
> it's selecting/matching elements that it shouldn't (elements in the wrong
> namespace).
>
> Secondly, with Saxon at any rate, it makes the search for a matching
> template rule very inefficient. Saxon organizes rules by the node-kind and
> node-name of the nodes that are matched, and then looks for "generic" rules
> that can match multiple node kinds or multiple node-names. If all the rules
> are generic, as here, then it potentially tries to match each element
> against every rule.
>
> Michael Kay
>
> > -----Original Message-----
> > From: Petr Mach3 [mailto:Mach3P@xxxxxxxxx]
> > Sent: 03 June 2004 10:13
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [xsl] 1 XSL for 2 XML
> >
> > Found answer, but ...
> > Is it possible to use     exclude-result-prefixes="f"  ????
> > It doesn't work for me.
> >
> > <?xml version="1.0"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> > xmlns:f="urn:schemas-cp-com:gen">
> > <xsl:output method="html" version="4.0"/>
> >
> > <xsl:template match="/">
> > <html><body>
> > <xsl:apply-templates select="//*[local-name(.)='MYTAB']"/>
> > </body></html>
> > </xsl:template>
> >
> > <xsl:template match="*[local-name(.)='MYTAB']">
> > <table border="1">
> > <th>HEAD</th>
> > <th><xsl:value-of select="MYHEAD"/><xsl:value-of
> > select="f:MYHEAD"/></th>
> > <xsl:apply-templates select="*[local-name(.)='MYITEM']"/>
> > </table>
> > </xsl:template>
> >
> > <xsl:template match="*[local-name(.)='MYITEM']">
> > <tr><td>ITEM</td>
> > <td><xsl:value-of select="MYIT"/><xsl:value-of
> > select="f:MYIT"/></td></tr>
> > </xsl:template>
> > </xsl:stylesheet>

____________________________________________________________
Neomezený internet bez jakékoli smlouvy, kdykoli vás napadne. A navíc 30 volných minut na volání! S předplacenou službou Go Data Nonstop vše jen za 850 Kč měsíčně.
http://ad.seznam.cz/clickthru?spotId=75021

Current Thread