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

Re: Generating numbering for cross-references (LONG)

Subject: Re: Generating numbering for cross-references (LONG)
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Thu, 18 Oct 2001 10:33:01 +0200
Re:  Generating numbering for cross-references (LONG)
Peter Flynn <peter@xxxxxxxxxxx> wrote:
[snip]
General comment: I've done something like this.
Other comments:
>    i) how do you combine locating the element with the right ID *and*
>       counting its preceding siblings in the same XPath expression,
Why do you want single a XPath? Use xsl:call-template, you can have
variables there.
   <xsl:template match="ref">
     ...
     <xsl:call-template name="get-number"/>
     ...

   <xsl:template name="get-number">
     <xsl:variable name="target" select="key('id',@id)"/>
     <xsl:number value="count($target/preceding-sibling[name()=name($target)])+1"/>
    ...

You can insert an xsl:choose to check whether the referenced item
exists and is unique by test"count($target)=1" and provide fallbacks or
error messages for other cases.

>   ii) ...you cannot use name() to formulate a dynamic expression as in
>       count(preceding-sibling::name(ID(@to)))
Try count(preceding-sibling::*[name()=current()/name(ID(@to))])

> iii) if this is to work on non-validating parsers, we must use an
>       expression like //*[id=$thisref] instead of ID(@to),...
Unlearn ID/id(). Use xsl:key/key() instead.
  <xsl:key name="table-id" match="table" use="@id"/>

>   iv) / v) 
At this point often a two-stage approach is suggested.
  <xsl:variable name="stage-1-result">
    <xsl:apply-templates select="/" mode="add-numbering"/>
  </xsl:variable>
  <xsl:apply-templates select="xx:node-set($stage-1-result)"/>
...
  <xsl:template match="*" mode="add-numbering">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:attribute name="stage-1-number">
        <xsl:number level="all"/>
      </xsl:attribute>
      <xsl:apply-templates select="node()" mode="add-numbering"/>
    </xsl:copy>
  </xsl:template>

HTH
J.Pietschmann

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


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.