Subject: [xsl] A tricksy XSL question: key(name,match,use="contains()") From: David Priest <priest@xxxxxx> Date: Sun, 28 Aug 2005 13:53:53 -0700 |
However, as shown above, some sections have two ids (one from the actual title as written, and an abbreviated one that will continue to work even if someone were to change the title). Thus, I need to modify the XSL so that if @ids *contains* the refid, it is a match.
As you've found, you can only use keys to locate nodes whose key value *exactly equals* a value you're searching for: you can't use contains() semantics.
All that means is that, in general, you need to use normal XPath expressions to get at the relevant section, as in something like:
<fo:page-number-citation ref-id="{//section[contains(@ids, $refid)]}" />
(though probably not that, since you don't want all the content of the <section> element within the ref-id attribute).
However, what you have is a more specialised situation, where a <section> can either have one or two ids in the ids attribute, and if there are two then they are space-separated. That being the case, you can construct a sectionkey key that indexes each of the sections by the appropriate ID using string manipulation functions. For example:
<!-- sections that only have one id are indexed by that id --> <xsl:key name="sectionkey" match="section[not(contains(@ids, ' '))]" use="@ids" />
<!-- sections that have two ids are indexed by the first and the second --> <xsl:key name="sectionkey" match="section[contains(@ids, ' ')]" use="substring-before(@ids, ' ')" /> <xsl:key name="sectionkey" match="section[contains(@ids, ' ')]" use="substring-after(@ids, ' ')" />
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Handle Session-Parameter in S, Dariusz Borowski | Thread | Re: [xsl] A tricksy XSL question: , Dimitre Novatchev |
Re: [xsl] Re: Lightweight XSLT base, stephan | Date | Re: [xsl] A tricksy XSL question: , Dimitre Novatchev |
Month |