You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/09/29 05:26:30 UTC

DO NOT REPLY [Bug 23470] New: - extension function fail if it's inside another extension element with xsl variable

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23470>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23470

extension function fail if it's inside another extension element with xsl variable

           Summary: extension function fail if it's inside another extension
                    element with xsl variable
           Product: XalanJ2
           Version: 2.4
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.extensions
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: chingju@lion.syscom.com.tw


I have a simple java class with one extension element and one extension 
function. They are working ok seperately with xsl variable. They are also 
working ok together if no xsl variable. However, extension element + extension 
function+ xsl variable, it fails with xsl variable not found.

the extension java class xyz.java

package xml.abc;
import org.apache.xalan.extensions.*;
import org.apache.xalan.templates.*;
import javax.xml.transform.*;
import org.w3c.dom.traversal.*;
import org.apache.xpath.*;
import org.apache.xpath.objects.*;

public class xyz
{

  public xyz()
  {
    super();
  }
  public String element(XSLProcessorContext context, ElemExtensionCall elem)
    throws TransformerException
  {
    try
    {
      String select = elem.getAttribute("select");
      org.apache.xpath.XPathContext xctxt
        = context.getTransformer().getXPathContext();

      XPath myxpath = new XPath(select, elem, xctxt.getNamespaceContext(), 
XPath.SELECT);
      XObject xobj = myxpath.execute(xctxt, context.getContextNode(), elem);
      return xobj.str();
    }
    catch( Exception e )
    {
      throw new TransformerException(e);
    }
  }

  public static NodeIterator function( ExpressionContext context, NodeIterator 
iterator)
    throws TransformerException
  {
    return iterator;
  }
}

the xml file as

<?xml version="1.0" ?>
  <root>
    <TB>
      <C1>abc</C1>
    </TB>
    <TB>
      <C1>xyz</C1>
    </TB>
  </root>

the xsl file as

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0" 
xmlns:xyz="xml.abc.xyz" 
extension-element-prefixes="xyz" >
<xsl:template match="/">
<xsl:for-each select="/root/TB">
<xsl:variable name="myC1" select="C1"/>
output of xyz:element <xyz:element select="$myC1" />
output of xyz:function <xsl:value-of select="xyz:function($myC1)" />
output of xyz:element/xyz:function <xyz:element select="xyz:function(C1)" />
output of xyz:element/xyz:function with xsl:variable <xyz:element 
select="xyz:function($myC1)" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

the output xml result as
<?xml version="1.0" encoding="UTF-8"?>

output of xyz:element abc
output of xyz:function abc
output of xyz:element/xyz:function abc
output of xyz:element/xyz:function with xsl:variable 
output of xyz:element xyz
output of xyz:function xyz
output of xyz:element/xyz:function xyz
output of xyz:element/xyz:function with xsl:variable 

and with exception messages 
file:///d:/temp/xyz.xsl; Line #12; Column #98; 
javax.xml.transform.TransformerException: Variable not resolvable: myC1

file:///d:/temp/xyz.xsl; Line #12; Column #98; 
javax.xml.transform.TransformerException: Variable not resolvable: myC1