xsl-list
[Top] [All Lists]

RE: [xsl] error testing id() in external document

2007-10-19 10:22:10
In XSLT 1.0 you can't use a function call on the rhs of "/". You need to use
xsl:for-each to set the context node for id():

<xsl:for-each select="document(..)">
   <xsl:if test="id($jid) = 'footnote'>...

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

-----Original Message-----
From: Trevor Nicholls [mailto:trevor(_at_)castingthevoid(_dot_)com] 
Sent: 19 October 2007 17:56
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] error testing id() in external document


Using xsltproc (libxml), and thus inside an <xsl:stylesheet 
version="1.0">, the following template generates an error:

  <xsl:template match="jump[(_at_)srcfile]">
   <xsl:variable name="jfil" 
select="substring-before(@srcfile,'#')" />
   <xsl:variable name="jid" select="substring-after(@srcfile,'#')" />
   <!-- footnotes are an invalid external reference -->
   <xsl:if test="local-name(document($jfil,/)/id($jid)) = 'footnote'">
    <xsl:message terminate="yes">
     <xsl:text>Footnote reference to external document (</xsl:text>
     <xsl:value-of select="@srcfile" />
     <xsl:text> found in </xsl:text>
     <xsl:value-of select="$myfullself" />
    </xsl:message>
   </xsl:if>
  </xsl:template>

The error is:

  XPath error : Invalid expression
  xsl:if : could not compile test expression 'local-name(.. etc.

Is that really an invalid expression? Is there a valid 
expression that will achieve the same thing?

Thanks
Trevor



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