[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: [text nodes] Unmatching text nodes wrongly inserte
Hi Stefano, The stylesheet you posted: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xdm="http://www.aaa.it/consulta/xdmModel"> <xsl:template match="xdm:fields"> <map font-family="Courier" font-size="10pt" height="1" x-unit="in/10" y-unit="in/6"> <xsl:apply-templates select="xdm:field[@name='CSBFT242']"/> </map> </xsl:template> <xsl:template match="xdm:field[@name='CSBFT242']"> <label x="20" y="56" width="12"> <xsl:value-of select="."/> </label> </xsl:template> </xsl:stylesheet> does not contain a <xsl:template match="/"> (matching the document root node). In such case, the default templates are applied. If you add a match="/" template, you can just select the elements you need, and no default templates will be called: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xdm="http://www.aaa.it/consulta/xdmModel"> <xsl:template match="/"> <xsl:apply-templates select="//xdm:fields"/> </xsl:template> <xsl:template match="xdm:fields"> <map font-family="Courier" font-size="10pt" height="1" x-unit="in/10" y-unit="in/6"> <xsl:apply-templates select="xdm:field[@name='CSBFT242']"/> </map> </xsl:template> <xsl:template match="xdm:field"> <label x="20" y="56" width="12"> <xsl:value-of select="."/> </label> </xsl:template> </xsl:stylesheet> In real situations it might be better not to use "//xdm:fields", but pass a full path like "/xdm:documents/xdm:document/xdm:body/xdm:pages/xdm:page/xdm:fields" because "//" always scans the complete input document. Or even better, use a key: <xsl:key name="fields" match="xdm:field" use="@name"/> <xsl:template match="/"> <xsl:apply-templates select="key('fields', 'CSBFT242')"/> </xsl:template> Salute! Anton
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|