xsl-list
[Top] [All Lists]

RE: how to call extension function for side-effect, portably?

2005-01-18 17:21:12
saxon:discard-document is deliberately designed to return the document being
discarded, so you can wrap it round a call of document(), or any other
reference to the document is actually being used. (It's effect isn't
immediate, it merely marks the document as being available for garbage
collection when no longer referenced).

In general, if you're not using the result of a function but still want it
called, then you should try to hoodwink the optimizer into thinking that you
are using it. If it's a Java method that returns void, call it as

<xsl:sequence select="my:call(xyz)"/>

or call it as

<xsl:if test="my:call(xyz) = -1"><a/></xsl:if>

when you know the result will never be -1.

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

-----Original Message-----
From: Kevin Rodgers [mailto:kevin(_dot_)rodgers(_at_)ihs(_dot_)com] 
Sent: 18 January 2005 20:46
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] how to call extension function for 
side-effect, portably?

What is the appropriate XSL instruction to call an extension for
side-effect only?  Currently I've got this in my stylesheet:

  <xsl:variable name="foo"
     select="document('file:///tmp/foo.xml')"/>
  <xsl:if test="function-available('saxon:discard-document')"
     xmlns:saxon="http://saxon.sf.net/";>
    <xsl:variable name="dummy"
       select="saxon:discard-document($foo)"
       xmlns:saxon="http://saxon.sf.net/"/>
  </xsl:if>

Which not surprisingly generates a warning (from Saxon):

Warning: at xsl:variable on line 11 of file:/tmp/foo.xsl:
  A variable with no following sibling instructions has no effect

-- 
Kevin Rodgers


--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>