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 18:06 17-10-2001, 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. I'm having
>a problem instatiating three classes of numeric cross-reference in
>XSLT, namely:
>
>a. Tables and figures, as in `See <ref to="foo"/>' where
>    you have <table id="foo"> or <figure id="foo">
>
>In normal processing of the document text, you use <xsl:number> to
>assign counters to tables, figures, chapters, sections, bib entries,
>etc. At serialization, these numbers get values in the normal way,
>but those values are not available or accessible to other places
>in the stylesheet because the language is side-effect free. 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.
>
>********************************************************************
>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?
>********************************************************************

Does this *need* to happen in a single XPath?  The way I usually handle 
this is:

<xsl:template match="ref">
   <xsl:apply-templates select="id(@to)" mode="ref"/>
</xsl:template>

<xsl:template match="table" mode="ref">
   <xsl:text>Table </xsl:text>
   <xsl:number/>
</xsl:template>

If you *have* to do it in XPath, well... you're headed in the right 
direction, but I'm not entirely sure it's possible.

-Chris
-- 
Christopher R. Maden, Principal Consultant, HMM Consulting Int'l, Inc.
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://www.hmmci.com/ > <URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA


 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]