2005/7/27, Joerg Heinicke <[EMAIL PROTECTED]>:
On 27.07.2005 15:54, Antonio Fiol Bonnín wrote:

> I have been changing my transforms to execute with XSLTC instead of
> interpreted Xalan. However, some of them did not work properly, showing
> erratic behaviour, or even throwing NullPointerException.
>
> In most cases (if not all), I have tracked the problem to usage of the
> document() function to get information from another source document. When
> this function is used, the context node is lost, and thus strange things
> happen.
>
> When I say "the context node is lost", I mean that AFTER the call to
> document():
> - any xpath expressions I've tried lead to erratic behaviour AND
> - in some cases, the "flow" of pattern applying gets wrong (usually aborting
> an apply-templates before applying to all the selected elements, and
> possibly adding spurious non-empty text nodes on the output).
>
> Has anyone also found this problem? If so, is there another solution apart
> from not using document() or not using xsltc? Is it a xsltc bug, a cocoon
> bug or not a bug at all?

Are you sure you have only retrieved a node using document() and not
switched the context to the other document?


Well, I think so...

This is one of the failing templates:

<xsl:template match="*" mode="cell">
  <xsl:variable name="nombre">html:<xsl:value-of select="name()"/></xsl:variable>
  <xsl:choose>
    <xsl:when test="document('')/xsl:stylesheet/xsl:template[contains(@match,$nombre) and @mode='inline']">
      <xsl:apply-templates select="." mode="inline"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="." mode="block"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

The intention of this template is doing a sort of reflection upon the stylesheet. Adding e.g. an <xsl:comment> before both <xsl:apply-templates> shows that the right <xsl:apply-templates> is executed. However, it is executed against the <xsl:apply-templates> element itself!! which is not the intended behaviour.

In a particular case (which I have not been able to track down to a simple example), it even leads to a NullPointerException.



--
Antonio

Reply via email to