[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Continuing problem
Subject: [xsl] Continuing problem From: John Ericson <john@xxxxxxxxxx> Date: Thu, 1 Nov 2001 16:26:24 +0000 |
On Nov 01 09:59, Jeni Tennison wrote: > > file.xml: > > <info> > > <link url="231243342">SpazeIRC</link> blablablabla bla . bldse > > dfseld s3242. 43 <link url="2342342">har</link>. > > </info> > > > > text.xsl: > > <xsl:template match="text()"> > > <xsl:value-of select="normalize-space(.)"/> > > </xsl:template> > > > > The output I get: > > SpazeIRCblablablabla bla . bldse dfseld s3242. 43har. > > > > I want it to look like this: > > SpazeIRC blablablabla bla . bldse dfseld s3242. 43 har. > > ^ ^ [snip] > > The problem is actually coming from the fact that you're looking at > the individual text nodes when actually you're interested in the > complete string value of the info element. The string value of the > link element is the concatenation of all its descendant text nodes, > which works out as: > > "\n SpazeIRC blablablabla bla . bldse dfseld s3242. 43 har.\n" > > When you normalize that, you get the string that you are after. So > rather than having a template that matches individual text nodes, have > a template that matches the info element and gives you its normalized > string value: > > <xsl:template match=="info"> > <xsl:value-of select="normalize-space()" /> > </xsl:template> > [snip] Thanks for the answer. I can admit that I havnt read the theory on how xsl works =) I try to learn by reading source. Anyway I rearranged my template to look like the above and it works fine. But In my larger work I need to have an template that matches "link". It looks like this: <xsl:template match="link"> <xsl:apply-templates/><xsl:text>[</xsl:text><xsl:value-of select="count(preceding::link)+1"/><xsl:text>]</xsl:text> </xsl:template> What it does is to put [n] after the text in the element like this: "SpazeIRC[1] blablablabla bla . bldse dfseld s3242. 43 har[2]." But now this template wont be applied. Is there a way I can temporary save the result from normalize-space() in the "info" template, so I can process it with my "link" template and have it outputed? -- * John Ericson john@xxxxxxxxxx * ICQ: 7325429 JID: high@xxxxxxxxxx * web: http://john.pp.se XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Jeni Tennisons XSLT/XPATH Boo, cutlass | Thread | Re: [xsl] Continuing problem, Jeni Tennison |
Re: [xsl] Continuing problem, Jeni Tennison | Date | Re: [xsl] XSL Java Extension proble, Jeni Tennison |
Month |
Keywords