Subject: Re: [xsl] Newline problems From: Mike Brown <mike@xxxxxxxx> Date: Mon, 5 May 2003 18:31:43 -0600 (MDT) |
Vishwajit Pantvaidya wrote: > >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. > > Does this mean that I have to reply the xsl:value-of for ponumber with > apply-templates and then do the normalize-space in that template processing. Yes, if I understand your question correctly. xsl:apply-templates means "process these nodes, using the best matching template for each one"... the built-in template for element nodes just calls <xsl:apply-templates/> which means to process the children of the element.. the built-in template for text nodes just does <xsl:copy/> which copies the node. You'll override that template for text nodes with a template that does <xsl:value-of select="normalize-space(.)"/>, which creates a new text node with the normalized string. > But apart from ponumber, I am reading other data similarly, (which also has > newlines) and does this mean that I have to have a template for each of such > data attributes? If the data is in a text node, then no. You just have to make sure to use xsl:apply-templates to get to the text nodes instead of using xsl:value-of on their parent element. > Is there an optimal way of not only removing newlines from > all such data items but also copying them into the output xml? You are not modifying the source tree in XSLT. You are only creating the result tree from which the output XML is automatically derived after the stylesheet is processed. > >I meant to mention, normalize-space might be overkill; if you want > >to remove *just* LF chars, use translate(.,' > ',''). However this > >will result in other whitespace (such as spaces or tabs used for > >indenting) being left intact. > > To use the above, do I have to type an actual newline into the xsl sheet or > can I specify it in any other way? Yes, you can write it as & # 1 0 ; or & # x A ; but without the spaces in between. That's what I wrote in my email. Despite the fact that my email goes out as text/plain, your email client apparently thinks it is being smart by interpreting that as markup. Who knows how much markup you are missing when you read the posts on this list! Use some other client :) XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Newline problems, Vishwajit Pantvaidya | Thread | RE: [xsl] Newline problems, Vishwajit Pantvaidya |
RE: [xsl] Newline problems, me | Date | RE: [xsl] Numbered Elements, Jack Cane |
Month |