From: "Lars Huttar" <lars_huttar(_at_)sil(_dot_)org>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: "'Vishwajit Pantvaidya'" <pantvaidya(_at_)hotmail(_dot_)com>,
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: RE: [xsl] Newline problems
Date: Tue, 6 May 2003 16:52:27 -0500
> I added these changes, resultant xsl sheet is as:
>
> <?xml version = "1.0" encoding = "UTF-8"?>
> <xsl:transform xmlns:xsl =
> "http://www.w3.org/1999/XSL/Transform" version =
> "1.0">
> <xsl:template match = "Quote">
> <xsl:text disable-output-escaping="yes"><!DOCTYPE
> Order></xsl:text>
> <xsl:element name = "Order">
> <xsl:element name ="Info">
> <xsl:apply-templates mode = "Attribs"
> select = "/Quote/Info/attribute"/>
> </xsl:element>
> </xsl:element>
> </xsl:template>
> <xsl:template mode = "Attribs" match = "attribute">
> <xsl:call-template name="atomicValue">
> <xsl:with-param name="AVname" select="'BILL_TO_ADDRESS2'" />
> </xsl:call-template>
> <xsl:call-template name="atomicValue">
> <xsl:with-param name="AVname" select="'PO_NUMBER'" />
> </xsl:call-template>
> </xsl:template>
> <xsl:template name="atomicValue">
> <xsl:param name="AVname" select="''" />
> <xsl:element name="{$AVname}">
> <xsl:value-of
> select="attribute/atomicValue[normalize-space(../name)=$AVname]"/>
> </xsl:element>
> </xsl:template>
> </xsl:transform>
>
>
> Output I get is as:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE
> Order><Order><Info><BILL_TO_ADDRESS2/><PO_NUMBER/><BILL_TO_ADDRESS2/>
> <PO_NUMBER/><BILL_TO_ADDRESS2/><PO_NUMBER/></Info></Order>
OK, as David Carlisle pointed out, in the second template the context
node is an <attribute>, and we're trying to select its <attribute>
children.
Oops.
So make your first apply-templates select "Info" instead of
"/Quote/Info/attribute", and change the second template's match
to match="Info".
Now it should work...
Changed xsl accordingly. Worked.
Now just one question out of curiosity. Mike Brown, Michael Kay, and others
have talked about an approach of using a template that matches text()
thereby overriding the default template for that, and doing the
normalization in that template. Is it feasible to use that to improve the
logic in this sheet in any manner?
Lars
Thanks,
Vish.
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list