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

Re: [text nodes] Unmatching text nodes wrongly inserte

Subject: Re: [text nodes] Unmatching text nodes wrongly inserted
From: "Anton Triest" <anton@xxxxxxxx>
Date: Fri, 24 Sep 2004 10:33:53 +0200
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

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.