Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] complex positioning problem

From: Bruce D'Arcus <bdarcus@------------->
To:
Date: 11/3/2004 12:23:00 AM
Hi Geert,



On Nov 2, 2004, at 6:02 PM, Geert Josten wrote:



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.

Yup, 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.

I'm afraid it's going to have to be.



BTW, I'm using XSLT 2.0 (I should have stated that again), and my 
strategy has been to create a temporary tree with enhanced data that I 
use for subsequent processing.



Current code is here:



	http://www.users.muohio.edu/darcusb/files/xbiblio.tar.gz



Some considerations:

- the bibliographic information is presumably unordered and is often 
sorted and numbered in the order that the biblio_refs_ occur.

Yes.



- the id's in your sample give an impression of the position, but this 
impression is false

How so?



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..

There are two ways to order numbered citations.  One is based on 
occurrence within the document (e.g. the biblioref elements), and the 
other is to sort the bibliography as you would in an author-year style, 
number those, and then use them in the citation.  This is an absolutely 
silly style that results in markers like [34, 2] and [1, 23], but it 
should be that hard I guess because I already the author-year style 
working fine.



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.

This is what I wondered about; particularly whether there are some new 
functions in XSLT 2.0 that would get me the functionality I need, as 
well as decent performance.



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.

XSLT 2.0 grouping can handle that.



Anyway, let me see if I understand what you've done conceptually....



  <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" />

OK, use keys to index the biblioref elements.  I don't really have 
experience with using keys, so wasn't sure if I needed them, or how to 
use them here.  One thing to note is that the biblioref elements can be 
all over the document: at various levels of section depth, or in 
footnotes, for example.



  <xsl:variable name="unique-bibrefs">

    <xsl:for-each select="key('bibrefs', 'all')">

      <xsl:if test="generate-id(.) = generate-id(key('bibrefs', 
@linkend)[1])">

What is the above doing?



        <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>

And the above?



  <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>

I'm not quite following this either.



Bruce


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent