Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] exslt tokenize mixed content

From: "Michael Kay" <mike@------------>
To:
Date: 11/1/2006 4:32:00 PM
Try

<xsl:variable name="spaced-out-nodes">
  <xsl:for-each select=".//text()">
    <xsl:text> </xsl:text>
    <xsl:value-of select="."/>
    <xsl:text> </xsl:text>
  </xsl:for-each>
</xsl:variable>
<xsl:variable name="words" select="str:tokenize($spaced-out-nodes)"/>

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Richard Lewis [mailto:richardlewis@xxxxxxxxxxxxxx] 
> Sent: 01 November 2006 16:06
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] exslt tokenize mixed content
> 
> Hi there,
> 
> I'm using libxslt's EXSLT implementation's str:tokenize() 
> function in an attempt to tokenize all the words inside a 
> particular element. What I need to be able to do is to have 
> it generate a list of tokens for /all/ the character content 
> from inside a mixed content element:
> 
> <xsl:template match="section">
>   <xsl:variable name="words" select="str:tokenize(string(.))" 
> /> </xsl:template>
> 
> This almost works except that using string() on a node 
> doesn't give you any white space between the last character 
> in one subelement and the next character following that 
> subelement. e.g.:
> 
> <section>
>   <title>Section the First</title>
>   <p>The content of this section</p>
> </section>
> 
> calling string on this gives you:
> "Section the FirstThe content of this section"
> 
> where I need a space between "First" and "The" so that 
> str:tokenize() will interpret them as separate tokens.
> 
> Any ideas?
> 
> Cheers,
> Richard
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Richard Lewis
> Sonic Arts Research Archive
> http://www.sara.uea.ac.uk/
> JID: ironchicken@xxxxxxxxxxxxxxx
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent