[oXygen-user] Author : Number of characters

I. Rogie
Mon May 10 10:18:10 CDT 2010

An xml example : 

<?xml version="1.0" encoding="UTF-8"?>
      <OfInterestTo FormalName="WKF"/>
            <p>Par <aut/></p>
            <p>PARIS, 2010 -</p>

With this xsl : 

<?xml version="1.0" encoding="UTF-8"?>
<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" select="//p/text()"/>
               <xsl:text> characters.</xsl:text>

       <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:when>
                        <xsl:call-template name="add">
                          <xsl:with-param name="sum" select="$sum +
                          <xsl:with-param name="nodes"
select="$nodes[position() != 1]"/>

Le 10/05/10 17:06, « George Cristian Bina » <> a écrit :

> Dear Isabelle,
> You can use also the XPath evaluation (see the XPath edit box in the
> toolbar). To get the normalized text from the document you can use
> normalize-space(/*)
> and for the number of characters in this text use
> string-length(normalize-space(/*))
> For understanding the problem you have with the stylesheet please post
> also a sample XML file together with the stylesheet that you use.
> Best Regards,
> George

More information about the oXygen-user mailing list