[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
RE: Newline problems
Subject: RE: Newline problems
From: "Vishwajit Pantvaidya" <pantvaidya@xxxxxxxxxxx>
Date: Tue, 06 May 2003 17:27:29 -0700
|
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: "'Vishwajit Pantvaidya'" <pantvaidya@xxxxxxxxxxx>,
<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: 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
|
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
RSS 2.0 |
|
Atom 0.3 |
|
|