[xslt] Namespace wilderness with functions



Hi

Looks like a bug in name-space handling in func:result elements:

% cp lib1.xsl.ok lib1.xsl
% xsltproc screen.xsl screen.xsl
In function lib1
In function lib2
===]200[===

// - valid result

% cp lib1.xsl.fail lib1.xsl
% xsltproc screen.xsl screen.xsl
In function lib1
xmlXPathCompOpEval: function myfunc bound to undefined prefix tmpl
xmlXPathCompiledEval: evaluation failed
exsltFuncResultElem: ret == NULL
===][===

// - unexpected error

% diff -u lib1.xsl.ok lib1.xsl.fail 
--- lib1.xsl.ok Mon Oct 11 17:39:13 2004
+++ lib1.xsl.fail       Mon Oct 11 17:39:13 2004
@@ -7,9 +7,9 @@
 
  <func:function name="cred:myfunc">
        <xsl:message>In function lib1</xsl:message>
-       <xsl:variable name="func-dbg" select="tmpl:myfunc()"/> 
 
-       <func:result select="$func-dbg"/> 
+       <func:result select="tmpl:myfunc()"/>
+
 
  </func:function>
   

// diff looks Ok - same expression, but in .ok variant firstly was put
into variable


When function's result compute some XPath expression it does computation
with name-space list from top document (screen.xsl in my example) not
with name-space of current document as should be (I guess).

Adding "xmlns:tmpl=..." into screen.xsl fix situation, but it is not
option, because top stylesheet does not know anything and do not want to
know about name-spaces used in below computations.

-- 
Vladimir B. Grebenschikov
SWsoft Inc. vova sw-soft com
<xsl:stylesheet version="1.0" extension-element-prefixes=""
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  >

  <xsl:include href="lib1.xsl"/>  
  <xsl:include href="lib2.xsl"/>  
</xsl:stylesheet>
<xsl:stylesheet version="1.0" extension-element-prefixes="func cred tmpl"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:func  ="http://exslt.org/functions";
  xmlns:cred  ="http://www.some.com/xsl/cred";
  xmlns:tmpl  ="http://www.some.com/xsl/tmpl";
  >

 <func:function name="cred:myfunc">
	<xsl:message>In function lib1</xsl:message>

	<func:result select="tmpl:myfunc()"/>


 </func:function>
  
</xsl:stylesheet>
<xsl:stylesheet version="1.0" extension-element-prefixes="func cred tmpl"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:func  ="http://exslt.org/functions";
  xmlns:cred  ="http://www.some.com/xsl/cred";
  xmlns:tmpl  ="http://www.some.com/xsl/tmpl";
  >

 <func:function name="cred:myfunc">
	<xsl:message>In function lib1</xsl:message>
	<xsl:variable name="func-dbg" select="tmpl:myfunc()"/> 

	<func:result select="$func-dbg"/> 

 </func:function>
  
</xsl:stylesheet>
<xsl:stylesheet version="1.0" extension-element-prefixes="func tmpl"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:func  ="http://exslt.org/functions";
  xmlns:tmpl  ="http://www.some.com/xsl/tmpl";
  >

 <func:function name="tmpl:myfunc">
	<xsl:message>In function lib2</xsl:message>
	<xsl:variable name="func-dbg2" select="200"/>
	<func:result select="$func-dbg2"/>
 </func:function>
  
</xsl:stylesheet>
<xsl:stylesheet version="1.0" extension-element-prefixes="cred"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:cred  ="http://www.some.com/xsl/cred";
  >

  <xsl:output method="html"/>

  <xsl:template match="/">
	<xsl:variable name="dbg1" select="cred:myfunc()"/>
	<xsl:value-of select="concat('===]',$dbg1,'[===')"/>
  </xsl:template>

  <xsl:include href="layout.xsl"/>  
</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]