xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henry Zongaro <zong...@ca.ibm.com>
Subject Re: Content Check fails
Date Mon, 01 Sep 2008 03:13:24 GMT
Hi, Thomas.

Thomas Steur <thomas.steur@xqueue.de> wrote on 2008-08-23 06:23:53 PM:
> <?xml version="1.0" encoding="UTF-8"?> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0"> 
> <xsl:template match="/"> 
>    <xsl:variable name="content"><xsl:call-template 
> name="test"/></xsl:variable> 
>    <xsl:value-of select="string-length($content)"/> 
> </xsl:template> 
> <xsl:template name="test"> 
>    <img src="http://path-to-img" width="" height=""/> 
> </xsl:template> 
> </xsl:stylesheet> 
> Why do I get the result "0" at <xsl:value-of select="string-
> length($content)"/> ? 
> If I use <xsl:copy-of select="$content"/> it has content alternatively 

The value of the "content" variable is a node - a root node, in this case. 
 Applying the string-length function to a node causes the node to be 
converted to a string, which is done by returning the string value of the 
node.  The string value of a root node or of an element node is equal to 
the string values of all the text node descendants of the node 
concatenated in document order.  The root node that is the value of the 
"content" variable has no text node descendants, so it's string value is a 
zero-length string.  Thus, the string-length function returns zero.

I hope that helps.


Henry Zongaro
XML Transformation & Query Development
IBM Toronto Lab   T/L 313-6044;  Phone +1 905 413-6044

View raw message