xsl-list
[Top] [All Lists]

RE: [xsl] Alternate syntax

2007-05-18 13:04:12

Anyway, I have the following snippet:

From the error message I guess this is an XSLT 1.0 processor, yes?

<xsl:variable name="warning">
      <warning>New contacts may only be added to active
consumers.</warning> 
  </xsl:variable> 

This variable is a result tree fragment. In XSLT 1.0 you aren't allowed to
probe inside a result tree fragment using path expressions such as
$warning/warning.

<xsl:call-template name="warning">
        <xsl:with-param name="warning" select="$warning" />
      <xsl:with-param name="level">3</xsl:with-param> 
</xsl:call-template>

I don't like it. I'd rather do it in one fell swoop, a la:

<xsl:call-template name="warning">
      <xsl:with-param name="warning">
              <warning>New contacts may only be added to active
consumers.</warning>
    </xsl:with-param>
    <xsl:with-param name="level">3</xsl:with-param> 
</xsl:call-template>

This code is completely equivalent to what you had before.

But my template complains: Reference to variable or parameter 
'warning' must evaluate to a node list.

It's right to complain. You can't use a result tree fragment as an operand
of "/".

It was wrong not to complain before, when you used the xsl:variable.

What processor are you using?

Michael Kay
http://www.saxonica.com/



Also, I'm all about syntax efficiency. Are there any other 
shortcuts I could take besides the one I'm looking for?


Well, if you want to make full use of result tree fragments / temporary
trees, your best bet is to move to XSLT 2.0.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>