This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Generating numbering for cross-references (LONG)


At 01/10/18 02:06 +0100, Peter Flynn wrote:
>In a typical research document, an author needs to make many
>cross-references.  XML provides ID and IDREF attributes for this
>purpose, and lots of DTDs are written to make use of them.
>...
>You
>cannot reach over to the relevant part of the tree (by ID) and
>pluck a copy of a number which has not yet been generated.

But you can temporarily place yourself *at* the relevant part of the tree 
and calculate the number the same way you are going to when you eventually 
get around to the normal serialization.

>At the point where a reference is made, what is the XPath expression
>you need to generate the number which will be the value which will
>eventually get assigned to the target?
>...
>What I find unbelievable is that no-one has yet done this. It must be
>one of the most common requirements in document processing, and
>without it, XSLT simply cannot be used to reproduce simple numeric
>cross-references like "see Figure 16" or <plug>bibliographic
>references like Kay[23]</plug> :-)
>
>What have I missed?

I must have missed something in your description.  When I need to do this, 
I do the following kind of coding:

At the point of reference:

    ...
    <xsl:text>See Construct </xsl:text>
    <xsl:for-each select="id(@idref)">
       <xsl:call-template name="construct-number"/>
    </xsl:for-each>
    ...

At the point of definition:
    ...
    <xsl:text>Construct </xsl:text>
    <xsl:call-template name="construct-number"/>
    ...

And elsewhere for maintenance:

    <xsl:template name="construct-number">
      ...
      <xsl:number ...>
    </xsl:template>

By using the named template I'm sure it is always consistent.

I hope this helps.

.................. Ken


--
G. Ken Holman                      mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.               http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0     +1(613)489-0999   (Fax:-0995)
Web site:     XSL/XML/DSSSL/SGML/OmniMark services, training, products.
Book:  Practical Transformation Using XSLT and XPath ISBN 1-894049-06-3
Article: What is XSLT? http://www.xml.com/pub/2000/08/holman/index.html
Next public training (instructor-live, Internet-live, and web-based):
-2001-10-22,11-01,11-02,11-05,11-19,11-21,12-03,12-05,12-09,12-10,12-19


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]