This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Removing Newlines
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 12 Jun 2002 10:02:13 +0100
- Subject: RE: [xsl] Removing Newlines
- Reply-to: xsl-list at lists dot mulberrytech dot com
>
> My XSLT has a strip-space declaration for all of the Synopsis
> element, which I'm assuming covers child elements too?
No it doesn't, but this is irrelevant to your problem. strip-space only
affects text nodes that consist *entirely* of whitespace.
>
> Yes or no, I then tried a normalize-space function on the <o>
> element, but this made the transformed text ignore the <var>
> child element translation instructions.
If you use string functions like normalize-space or translate on the <o>
element, then they will operate on its string value, which is obtained
by concatenating all the descendant text nodes. If you want to
manipulate the text while preserving the structure, then you must
process each descendant text node independently. Use xsl:apply-templates
to walk the tree, and write a template rule for text nodes that does the
newline stripping.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
>
> My next step was to try to use translate function to
> translate newlines into whitespace. I did it like this:
>
> ><!-- o template -->
> ><xsl:template match="o">
> ><xsl:text /><xsl:value-of select="translate(.,' ','')"
> /><xsl:text
> >/> </xsl:template>
>
> But again, this misses the var elements (they're not translated).
>
> So what I need is a way to strip out newline characters that
> appear in the
> source
> XML, but for source that has child elements that will be transformed.
>
> Thanks for any help,
>
> --gk
>
> Greg Kushmerek
> Sr. Technical Writer
> IA/Tools
> The MathWorks
> (+1) 508-647-7136
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list