[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Continuing problem

Subject: Continuing problem
From: John Ericson <john@xxxxxxxxxx>
Date: Thu, 1 Nov 2001 16:26:24 +0000
a continuing problem
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.