[oXygen-user] Author : Number of characters

Rogie Isabelle
Mon May 10 09:56:11 CDT 2010


Thanks for this idea!
I just add the function normalize-space to suppress space on this line:
<xsl:with-param name='sum' select='$sum + string-length(normalize-space($nodes[1]))'/>

I wanted only the number of characters in element p. So I change the selection: 
	<xsl:with-param name='nodes' select='//p/text()'/>
But it doesn't work. The number of characters is 0

Isabelle Rogie

-----Message d'origine-----
De : Radu Coravu [mailto:] 
Envoyé : lundi 10 mai 2010 11:18
À : 
Objet : Re: [oXygen-user] Author : Number of characters

Hi Isabelle,

We have some plans to add actions in Oxygen for counting words and 
In the meantime you can create an XSLT stylesheet with the following 

<xsl:stylesheet version='1.0'

<xsl:template match='/'>
<xsl:text>The document contains </xsl:text>
<xsl:call-template name='add'>
<xsl:with-param name='nodes'
<xsl:text> characters.

<xsl:template name='add'>
<xsl:param name='sum' select='0'/>
<xsl:param name='nodes' select='/..'/>

<xsl:when test='not($nodes)'>
<xsl:value-of select='$sum'/>
<xsl:call-template name='add'>
<xsl:with-param name='sum'
                         select='$sum + string-length($nodes[1])'/>
<xsl:with-param name='nodes'
                         select='$nodes[position() != 1]'/>

and apply it on the XML file.
If you need to count words, there is an XSLT stylesheet available here:


Radu Coravu
<oXygen/>   XML Editor, Schema Editor and XSLT Editor/Debugger

On 5/7/2010 5:19 PM, Rogie Isabelle wrote:
> Hi,
> Is it possible to know simply the number of characters in a xml file?
> I use Author version 10.2 on Mac OS X.
> Best Regards,
> _______________________________________
> **Isabelle Rogie**
> Database Chief project
> Wolters Kluwer France
> _______________________________________________
> oXygen-user mailing list
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user

More information about the oXygen-user mailing list