[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: Wed, 22 Sep 2004 18:33:12 +0200
triest family
Hi Stefano,

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

xsl:apply-elements without select attribute will apply to all children:
if there is no matching template, the builtin default template will be 
applied. The default template then outputs the text contents of the 
elements.

A good remedy would be to select the field you want, 
rather than matching it:

    <xsl:template match="xdm:fields">
        <map font-family="Courier" ...>
            <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>

Salute,
Anton


Chizzolini Stefano wrote:
>

> Hi all,
> 
> I tried to render this xml:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <documents xmlns="http://www.aaa.it/consulta/xdmModel">
>  <document id="2003722011924">
>   <header>
>    <caption>Fattura 1924/2003 di AAAAAA SpA</caption>
>   </header>
>   <body format="pdf" base="fatture/">
>    <pages>
>     <page template="FTNORM.pdf">
>      <fields>
>       <field name="CSBFT242">FATTURA DI VENDITA</field>
>       <field name="CSBFT009">1</field>
>       <field name="CSBFT010">2003-12-18</field>
>      </fields>
>     </page>
>    </pages>
>   </body>
>  </document>
> </documents>
> 
> transforming it with this ridiculous XSLT stylesheet:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <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/>
>   </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>
> 
> but the result was quite horrific:
> 
> <?xml version="1.0"?>
> Fattura 1924/2003 di AAAAAA SpA
> <map font-family="Courier" font-size="10pt" height="1" x-unit="in/10"
> y-unit="in/6" xmlns:xdm="http://www.aaa.it/consulta/xdmModel">
>  <label x="20" y="56" width="12">FATTURA DI VENDITA</label>
>  1
>  2003-12-18
> </map>
> 
> As you can see, the core transformation is right, but the XSLT processor
> inserted also all the unwanted text node values!
> I checked all the above code, but I'm really puzzled.
> 
> What's wrong in my stylesheet?
> 
> Many thanks
> 
> Stefano

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.