RE: [xsl] Newline problems

Subject: RE: [xsl] Newline problems
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sat, 3 May 2003 16:06:29 +0100
The info element does not appear to have any text node children, so
applying templates to them is not going to do much good.

You are only outputting the content of atomicValue if it has a ../name
whose value is "ponumber". But in your example, the name is
"[NL]ponumber". You haven't attempted to remove the newline before doing
the comparison.

You might be better off doing a separate pass to clean up this data
before you attempt to transform it. Either that, or tell the people who
generated it to mend their ways...

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Vishwajit Pantvaidya
> Sent: 03 May 2003 05:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Newline problems
> 
> 
> 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>
> 
> ----------------------------------------------------------------
> 
> Thanks,
> 
> Vishwajit.
> 
> 
> 
> 
> >From: Mike Brown <mike@xxxxxxxx>
> >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> >Subject: Re: [xsl] Newline problems
> >Date: Thu, 1 May 2003 18:46:59 -0600 (MDT)
> >
> >Vishwajit Pantvaidya wrote:
> > > Since I have no way of knowing which elements in the source xml 
> > > would
> >have
> > > newlines, would it mean that I will need to have the 
> normalize-space 
> > > function all over my xsl sheet?
> >
> >Not necessarily. Whereas you might be used to doing things like 
> ><xsl:value-of select="/path/to/some/element"/> and are shuddering at 
> >the thought of changing this to <xsl:value-of 
> >select="normalize-space(/path/to/some/element)"/>,
> >you could utilize the power of XSLT a bit more and do 
> so-called "push" 
> >processing like <xsl:apply-templates 
> select="/path/to/some/element"/> 
> >and have the template that matches that type of element do
> ><xsl:apply-templates select="text()"/>
> >or you could go straight to the text node itself like
> ><xsl:apply-templates select="/path/to/some/element/text()"/>
> >.. in either case you could then override the
> >built-in template for text nodes by making it do normalize-space()
> >instead of <xsl:copy/>.
> >
> ><xsl:template match="text()">
> >   <xsl:value-of select="normalize-space(.)"/>
> ></xsl:template>
> >
> >  XSL-List info and archive:  
> http://www.mulberrytech.com/xsl/xsl-list
> >
> 
> 
> 
> _________________________________________________________________
> Tired of spam? Get advanced junk mail protection with MSN 8. 
> http://join.msn.com/?page=features/junkmail
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread