RE: [xsl] Newline problems

Subject: RE: [xsl] Newline problems
From: "Lars Huttar" <lars_huttar@xxxxxxx>
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">&lt;!DOCTYPE 
> Order&gt;</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...

Lars



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread