[XSL-LIST Mailing List Archive Home]
[xsl] id attribution in template match
Subject: [xsl] id attribution in template match|
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Sep 2009 20:56:20 +1300
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:value-of select="normalize-space(id(@idref))" />
Now it does not, and I have had to replace it with
<xsl:variable name="jid" select="@idref" />
<xsl:value-of select="normalize-space(//*[@id=$jid])" />
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
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:
This is no longer matching jumps which point to footnotes, so I tried the
same technique as above:
<xsl:template match="jump[@idref][local-name(//*[@id =
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).