GNOME Bugzilla – Bug 340503
substring-after exits, if space is provided as an argument in nested call
Last modified: 2006-05-03 11:48:45 UTC
Most of the string related functions fail if space is provided as an argument, when these functions themselves are parameter to another function. i.e. <xsl:element name="{normalize-space(substring-before(.,' '))}"/> works fine but, <xsl:element name="{normalize-space(substring-before(substring-after(.,'pandey'),' '))}"/> fails, and returns with error. [root@localhost xslttest]# xsltproc -v xslfile.xsl daniel.xml creating dictionary for stylesheet reusing dictionary from xslfile.xsl for stylesheet Added namespace: xsl mapped to http://www.w3.org/1999/XSL/Transform Added namespace: str mapped to http://exslt.org/strings exclude result prefix str xsltParseStylesheetProcess : found stylesheet exclude result prefix str xsltPrecomputeStylesheet: removing ignorable blank node xsltCompilePattern : parsing '/' xsltCompilePattern : parsed /, default priority 0.500000 added pattern : '/' priority 0.500000 parsed 1 templates Resolving attribute sets references Creating sub-dictionary from stylesheet for transformation Registered 0 modules reusing transformation dict for output Registering global variables Registering global variables from xslfile.xsl xsltProcessOneNode: applying template '/' for / xsltApplyOneTemplate: copy node crypto xsltApplyOneTemplate: copy node ike xsltApplyOneTemplate: copy node key xsltForEach: select /precli/param/param-parent xsltForEach: select evaluates to 1 nodes xsltEvalXPathString: returns xsltEvalAttrValueTemplate: {normalize-space(substring-before(substring-after(.,'pandey'),' '))} returns runtime error: file xslfile.xsl line 9 element element xsl:element : invalid name freeing transformation dictionnary no result for daniel.xml freeing dictionary from stylesheet [root@localhost xslttest]# xsltproc --version Using libxml 20624, libxslt 10115 and libexslt 812 xsltproc was compiled against libxml 20624, libxslt 10115 and libexslt 812 libxslt 10115 was compiled against libxml 20624 libexslt 812 was compiled against libxml 20624 xslfile.xsl <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" exclude-result-prefixes="str"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <crypto> <ike> <key> <xsl:for-each select="/precli/param/param-parent"> <xsl:element name="{normalize-space(substring-before(substring-after(.,'pandey'),' '))}"/> <!-- <xsl:element name="{normalize-space(substring-before(.,' '))}"/> --> </xsl:for-each> </key> </ike> </crypto> </xsl:template> </xsl:stylesheet> daniel.xml <?xml version="1.0"?> <precli> <param> <param-parent> rahul anil pandey tiwari sharma babu </param-parent> </param> </precli>
Not a bug, the string starts with a space so the substring-before( , ' ') operation returns an empty string, perfectly normal. Daniel