Subject: Re: [xsl] complex positioning problem From: Geert Josten <Geert.Josten@xxxxxxxxxxx> Date: Wed, 03 Nov 2004 00:02:34 +0100 |
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.
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
Grtz, Geert
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl" >
<!--+ ============================================================== | output +-->
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
<!--+ ============================================================== | indices +-->
<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" />
<!--+ ============================================================== | parameters +-->
<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="@*|node()"> <xsl:copy-of select="." /> </xsl:template>
<xsl:template match="*"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template>
<!--+ ============================================================== | custom template +-->
<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:citation"> <xsl:text>[</xsl:text> <xsl:for-each select="d:biblioref"> <xsl:apply-templates select="." /> <xsl:if test="not(position() = last())"> <xsl:text>, </xsl:text> </xsl:if> </xsl:for-each> <xsl:text>]</xsl:text> </xsl:template>
<xsl:template match="d:biblioref"> <xsl:apply-templates select="." mode="get-bibref-position" /> </xsl:template>
<!--+ ============================================================== | group get-bibref-position +-->
<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 -> |
---|---|---|
[xsl] complex positioning problem, Bruce D'Arcus | Thread | Re: [xsl] complex positioning probl, Bruce D'Arcus |
RE: [xsl] inserting HTML comments, Pieter Reint Siegers | Date | Re: [xsl] Collapsing run-on tag cha, David Carlisle |
Month |