Subject: Re: [xsl] Newline problems From: "Vishwajit Pantvaidya" <pantvaidya@xxxxxxxxxxx> Date: Mon, 05 May 2003 16:40:57 -0700 |
From: Mike Brown <mike@xxxxxxxx> Date: Fri, 2 May 2003 22:54:31 -0600 (MDT)
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"><!DOCTYPE
> OrderProcessing></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>?
',''). However this
> </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(.,'
will result in other whitespace (such as spaces or tabs used for indenting) being left intact.
Mike
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Newline problems, Lars Huttar | Thread | Re: [xsl] Newline problems, Mike Brown |
RE: [xsl] Question about predicate, Didier PH Martin | Date | RE: [xsl] Newline problems, Vishwajit Pantvaidya |
Month |