xsl-list
[Top] [All Lists]

[xsl] id attribution in template match

2009-09-29 03:57:09
Since switching from DTD-based to XSD-based documents, a number of templates
which make use of the id() function have stopped working. It's not a
processor problem because it occurs with Xalan, Saxon and libxslt.

This used to work, outputting the content of whatever element in the
document had the given id:
----
  <xsl:template match="jump[(_at_)idref]">
    <xsl:value-of select="normalize-space(id(@idref))" />
  </xsl:template>
----

Now it does not, and I have had to replace it with
----
  <xsl:template match="jump[(_at_)idref]">
    <xsl:variable name="jid" select="@idref" />
    <xsl:value-of select="normalize-space(//*[(_at_)id=$jid])" />
  </xsl:template>
----

The schema correctly identifies all id attributes as type xs:ID, and all
idref attributes as type xs:IDREF.

So that's question 1, is there a hidden trap with id(@idref) type
expressions here?

Question 2 follows from my using the above workaround, because it isn't
obvious how to apply it in template matches.

For example I have a template declared like so:
----
  <xsl:template match="jump[(_at_)idref][local-name(id(@idref))='footnote']">
  ..
  </xsl:template>
----

This is no longer matching jumps which point to footnotes, so I tried the
same technique as above:
----
  <xsl:template match="jump[(_at_)idref][local-name(//*[(_at_)id =
./@idref])='footnote']">
  ..
  </xsl:template>
----

I know this won't work because the . in the last predicate matches the wrong
element. I can't put the idref in a variable and use that because I would
have to do that outside the template. Is there a particular technique that
would allow me to evaluate this test properly (of course a solution to the
first problem might render this irrelevant).

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

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