[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: Mon, 05 May 2003 16:47:57 -0700
newlines in xml values
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE:  Newline problems
Date: Mon, 5 May 2003 13:32:50 -0500

> I made changes to apply normalize-space to text nodes as
> suggested but
> output again has no data. Do you see any obvious mistakes?
> Simplified src
> xml and xsl are as shown below:
> ----------------------------------------------XML------------------
> <!DOCTYPE ABC [
> ...
> ]><ABC>
> ...
> <info>
> <attr>
> <name>
> ponumber</name>
> <atomicValue>
> 12345</atomicValue>
> </attr>
> ...
> </info>
> ...
> </ABC>
>
> ----------------------------------------------XSL------------------
>
> <?xml version = "1.0" encoding = "UTF-8"?>
> <xsl:transform xmlns:xsl =
> "http://www.w3.org/1999/XSL/Transform" version =
> "1.0">
>   <xsl:template match = "ABC">
>     <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE
> OrderProcessing&gt;</xsl:text>
>     <xsl:element name = "Order">
>       <xsl:element name ="Info">
>         <xsl:apply-templates mode = "Attribs" select = "/ABC/info"/>
>       </xsl:element>
>     </xsl:element>
>   </xsl:template>
>   ...
>   <xsl:template mode = "Attribs" match = "info">
>     <xsl:apply-templates mode = "stripNewline" select="text()"/>
>     <xsl:element name = "PO_NUMBER">
>       <xsl:value-of select="attr/atomicValue[../name='ponumber']"/>
>     </xsl:element>
>   ...
>   </xsl:template>
>
>   <xsl:template mode = "stripNewline" match="text()">
>     <xsl:value-of select="normalize-space(.)"/>
>   </xsl:template>
>   ...
> </xsl:transform>

Vishwajit, it sounds like you are expecting the stripNewline template
to modify the source document, actually removing the newlines from
it so that the following xsl:value-of will be able to recognize the
node you're looking for.  That approach will not work, because in XSL
you're not able to modify the source document.  (That would be a side-
effect, which you're not supposed to be able to do.)

I believe what you want to do here is

<xsl:template mode = "Attribs" match = "info">
<xsl:element name = "PO_NUMBER">
<xsl:value-of select="attr/atomicValue[normalize-space(../name)='ponumber']"/>
</xsl:element>
...
</xsl:template>


Lars


Wouldn't that require me to put normalize-space calls all over my xsl, since most of the input xml values has newlines? I was just trying to follow the suggestions made by Mike Brown, Michael Kay and others of using templates to avoid this.




Vish.

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



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



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.