You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Erik Ogan <er...@change.org> on 2018/04/27 19:28:40 UTC

dyn:evaluate() and document('')

I am trying to build a dynamic query that extracts a value from a node
in the stylesheet, using dyn:evaluate(). This technique works fine to
extract values from the input XML, and the query I’m running works as
a static XPath query.

In short, I’m wondering if this is a bug in my understanding,
implementation, or possibly Xalan (2.7.2) itself, and how I might fix
/ work around it.

I’ve extracted a simpler reproduction case for illustration:
Stylesheet:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:dyn="http://exslt.org/dynamic"
                extension-element-prefixes="dyn">

  <xsl:variable name="from-stylesheet">
    <bug type="xalan">from stylesheet</bug>
  </xsl:variable>

  <xsl:template match="data">
    <result>
      <xsl:call-template name="eval">
        <xsl:with-param name="path">//data[@type = '<xsl:value-of
select="@type"/>']</xsl:with-param>
      </xsl:call-template>
      <xsl:call-template name="eval">
        <xsl:with-param
name="path">document('')//xsl:variable[@name='from-stylesheet']/bug[@type
= '<xsl:value-of select="@type"/>']</xsl:with-param>
      </xsl:call-template>
      static: <xsl:value-of
select="document('')//xsl:variable[@name='from-stylesheet']/bug[@type
= 'xalan']" />
    </result>
  </xsl:template>

  <xsl:template name="eval">
    <xsl:param name="path"/>
    <xsl:value-of select="dyn:evaluate($path)"/>
  </xsl:template>
</xsl:stylesheet>


Input XML:

<data type="xalan">
  <from-doc xalan="true">From document</from-doc>
</data>

Expected Result (with whitespace normalized):

<?xml version="1.0" encoding="UTF-8"?>
<result>
  From document
  from stylesheet
  static: from stylesheet
</result>

Actual Result (with whitespace normalized):
<?xml version="1.0" encoding="UTF-8"?>
<result>
  From document

  static: from stylesheet
</result>

Obviously, the "From document" example could be achieved more simply,
but I added it to prove to myself that dyn:evaluate() WAS actually
working at all. I left it in for the same reason.

Any help on this would be greatly appreciated!

-e

-- 
Erik Ogan
erik@change.org
415.BE.MESSY