[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Newline problems

Subject: Re: Newline problems
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 2 May 2003 22:54:31 -0600 (MDT)
xsl insert newline
Vishwajit Pantvaidya wrote:
> 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"/>

I think here you just want to select "info", not "/ABC/info", because you are
currently processing an ABC element and you just want *its* info child, not
the set of all info children, no?

>       </xsl:element>
>     </xsl:element>
>   </xsl:template>
>   ...
>   <xsl:template mode = "Attribs" match = "info">
>     <xsl:apply-templates mode = "stripNewline" select="text()"/>

Look at your XML. The only text node *children* of the info element
are whitespace. There are some other child nodes that are elements
and *those* have text node children. But you are not selecting any
of those.

Specifically what text from the source are you trying to insert before the
PO_NUMBER element you create?

>     <xsl:element name = "PO_NUMBER">
>       <xsl:value-of select="attr/atomicValue[../name='ponumber']"/>
>     </xsl:element>
>   ...

Is there any reason why you use xsl:element instead of just
<PO_NUMBER>...</PO_NUMBER>?

>   </xsl:template>
> 
>   <xsl:template mode = "stripNewline" match="text()">
>     <xsl:value-of select="normalize-space(.)"/>
>   </xsl:template>
>   ...
> </xsl:transform>

I meant to mention, normalize-space might be overkill; if you want
to remove *just* LF chars, use translate(.,'&#10;',''). However this
will result in other whitespace (such as spaces or tabs used for
indenting) being left intact.

Mike

 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.