[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Pick up generated numbering for cross reference us

Subject: Re: Pick up generated numbering for cross reference using key?
From: Cas Tuyn <Cas.Tuyn@xxxxxxxx>
Date: Tue, 22 Mar 2005 15:05:24 +0100
cas number
It can be calculated I think. I had great dificulty writing:

'Count the number of tables in the current section only, before the 
table with <table id="csrh026a.dia-6"> , and add 1', from within the 
xref xslt declaration. Should that be something like:

<xsl:value-of select="count(preceding::table[@id='$linkend'])+1" />
or
<xsl:value-of 
select="count(parent::section//table[@id='$linkend']/preceding::table[@id='$linkend'])+1" 
/>

condensed XML source:

<procedure>
    <section>
       <step><table id="1234-3"><!--lines removed--></table></step>
       <step><step><table id="1234-1"><!--lines 
removed--></table></step></step>
    </section>
    <section>
       <table id="1234-2"><!--lines removed--></table></step>
       <step><ptxt>Refer to <xref role="table" linkend="1234-1"/> for 
more info.</ptxt></step>
    </section>
<procedure>

should return:
... Refer to table 1.2 for more info. ...

Cas


> Keys apply to any document, including a temporary document created in a
> variable. You don't need to indicate in the xsl:key declaration which
> document they are intended to be used with, they automatically apply to the
> document that contains the context node at the time you call the key()
> function.
> 
> What you are essentially suggesting here is doing a two-phase transformation
> in which the section numbers are generated during the first phase, and the
> cross-references are filled in during the second phase. That's a perfectly
> reasonable design approach, but you haven't convinced me that it's
> necessary. If the number of a table can be computed by examining where the
> table is in the source document, then you can use the approach of
> recalculating the number each time you process a cross-reference.
> 
> Michael Kay
> http://www.saxonica.com/ 
> 
> 
>>-----Original Message-----
>>From: Cas Tuyn [mailto:Cas.Tuyn@xxxxxxxx] 
>>Sent: 22 March 2005 13:14
>>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>Subject:  Pick up generated numbering for cross 
>>reference using key?
>>
>>Hi,
>>
>>My tables have double-digit numbering generated from the 
>>section number
>>as a variable, and the calculated sequence inside the section:
>>
>><xsl:template match="table">
>>	<xsl:param name="secnum" />
>>	<xsl:variable name="tabnum">
>>		<xsl:value-of select="count(preceding::table)+1" />
>>	</xsl:variable>
>>... lines left out ...
>>	<caption>
>>		Table <xsl:value-of select="$secnum" />.<xsl:value-of
>>select="$tabnum" /> <xsl:value-of select="title" />
>>	</caption>
>></xsl:template>
>>
>>This works good. Now I'm trying to make cross references to those
>>tables. I've searched the xsl archives and found a 2001 
>>thread where it
>>was suggested to either calculate it again (impossible because of the
>>section-part being a variable), or store it in a key value. The latter
>>method reminds me of arrays in other languages, so I thought 
>>it was the
>>right direction.
>>
>>Using the 'XSLT programmers reference' it appears that:
>>1. you can only use xsl:key immediately under the root of the 
>>document,
>>2. put existing text or attribute values (not generated) in there.
>>
>>I was hoping to insert:
>>	<xsl:key name="table-number" match="@id" use="$secnum . $tabnum"
>>/>
>>immediately below the variable definition shown above, but 
>>that returned
>>"Unexpected child" due to rule #1 not observed.
>>
>>The XML code for origin and target of the link:
>>	<xref role="table" linkend="csrh026a.dia-6"/>
>>	<table id="csrh026a.dia-6">
>>
>>The XSLT for the origin of the link:
>>	<xsl:template match="xref">
>>		<xsl:for-each select="@linkend">
>>			<xsl:variable name="linkend" select="."/>
>>			<xsl:element name="a">
>>				<xsl:attribute
>>name="href">#<xsl:value-of select="."/></xsl:attribute>
>>				<xsl:for-each select="../@role">
>>					<xsl:choose>
>>						<xsl:when
>>test="(.='table')">
>>							table x.x
>>						</xsl:when>
>>					</xsl:choose>
>>				</xsl:for-each>
>>			</xsl:element>
>>		</xsl:for-each>
>>	</xsl:template>
>>
>>The "x.x" should be the number of the table where I refer too.
>>
>>Questions:
>> 1. Is this a good way of doing this?
>> 2. Is there a better way using XSLT 1.0
>>
>>Regards,
>>
>>Cas
>>
>>
>>
>>
>>-- 
>>The information contained in this communication and any 
>>attachments is confidential and may be privileged, and is for 
>>the sole use of the intended recipient(s). Any unauthorized 
>>review, use, disclosure or distribution is prohibited. If you 
>>are not the intended recipient, please notify the sender 
>>immediately by replying to this message and destroy all 
>>copies of this message and any attachments. ASML is neither 
>>liable for the proper and complete transmission of the 
>>information contained in this communication, nor for any 
>>delay in its receipt.
> 
> 



-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.