Subject: Re: [xsl] complex positioning problem From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx> Date: Tue, 2 Nov 2004 19:23:14 -0500 |
Here's the second issue I've no clue how to solve (beyond Wendell's suggestion about using temporary trees). I assume I may want to somehow create a virtual element in the temporary tree that indicates the position of the unique linkend value in the document (and between citations), but I'm not really sure.
The traffic on this list is quite high, but I believe your question is still open.
Wendell noted correctly that your input document doesn't cover all situations. Even more, I think it is just not complex enough for the general problem of numbering citations.
Some considerations:
- the bibliographic information is presumably unordered and is often sorted and numbered in the order that the biblio_refs_ occur.
- the id's in your sample give an impression of the position, but this impression is false
Puzzling on the problem, I came up with some steps to tackle this. I'll try to explain...
Consider the following scenario (the dots represent ordinary text): ...........ref b, ref a....... .......ref a, ref b........... a) author xx, book yy b) author zz, website blabla
I think this should be presented like: ...........[1,2]....... .......[2,1]........... 1] author zz, website blabla 2] author xx, book yy
Or prehaps one would like the [2,1] to be presented like [1,2] as well..
First of all, the bibliorefs have to be gathered. I did this with an index (xsl:key). After that, the bibliorefs have to be uniquefied to be able to get the position of the first of each distinct biblioref. I gather the unique list in a global variable, which has to be accessed through a node-set function in XSLT 1 (other solutions would be too complex to explain, putting aside maintenance). The detemination of the position is done in a template.
It is probably not the most efficient code, but it works.
Note also that I didn't solve the ordering of the bibliorefs within one citation. That can be done, by gathering the positions in a variable again and doing the sorting magic as you like.
<xsl:key name="bibrefs" match="d:biblioref" use="'all'" /> <xsl:key name="bibrefs" match="d:biblioref" use="@linkend" /> <xsl:key name="biblio" match="d:mods" use="@ID" />
<xsl:variable name="unique-bibrefs">
<xsl:for-each select="key('bibrefs', 'all')">
<xsl:if test="generate-id(.) = generate-id(key('bibrefs', @linkend)[1])">
<xsl:copy-of select="." /> </xsl:if> </xsl:for-each> </xsl:variable>
<!--+ ============================================================== | default templates +-->
<xsl:template match="/"> <bibrefs> <xsl:for-each select="key('bibrefs', 'all')"> <xsl:copy-of select="." /> </xsl:for-each> </bibrefs> <unique-bibrefs> <xsl:copy-of select="$unique-bibrefs" /> </unique-bibrefs> <xsl:apply-templates select="node()"/> </xsl:template>
<xsl:template match="d:biblioref" mode="get-bibref-position"> <xsl:variable name="linkend" select="@linkend" /> <xsl:for-each select="msxsl:node-set($unique-bibrefs)/*"> <xsl:if test="@linkend = $linkend"> <xsl:value-of select="position()" /> </xsl:if> </xsl:for-each> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] complex positioning probl, Geert Josten | Thread | Re: [xsl] complex positioning probl, Bruce D'Arcus |
Re: [xsl] Collapsing run-on tag cha, David Carlisle | Date | Re: [xsl] complex positioning probl, Bruce D'Arcus |
Month |