[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

id attribution in template match

Subject: id attribution in template match
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Sep 2009 20:56:20 +1300
 id attribution in template match
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[@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[@idref]">
    <xsl:variable name="jid" select="@idref" />
    <xsl:value-of select="normalize-space(//*[@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[@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[@idref][local-name(//*[@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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.