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

Re: numbering and sorting compatibility issue

Subject: Re: numbering and sorting compatibility issue
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sat, 22 Mar 2003 14:52:40 +0000
numbering equipment
Hi Andrew,

> OK I'll be more concrete,
> I've following structure
> <Report>
> <Manufacturing m_no="1">
>     <Order code="x">
>         <Equipment name="y">
>             <Element part="z" qty="3"/>
>             <Element part="z" qty="4"/>
>             ...
>         </Equipment>
>         <Equip...
>     </Order>
>     <Order...
> </Manufacturing>
> <Manufact...
> </Report>
> I think self describing...
[snip]
> so I need to sort Elements by "part" AND number through all "Report"
> but I do numbering in "Equipment" context/template so...

I think from your description that you want the following. The
numbering is generated by taking the position() in the *sorted* list
within a particular <Equipment> element, and adding it to the number
of <Element> elements that appeared before the particular <Equipment>
element.

<xsl:template match="Manufacturing">
  <tr><td>Manufacturing No <xsl:value-of select="@m_no" /></td></tr>
  <xsl:apply-templates select="Order" />
</xsl:template>

<xsl:template match="Order">
  <tr><td>Order <xsl:value-of select="@code" /></td></tr>
  <xsl:apply-templates select="Equipment" />
</xsl:template>

<xsl:template match="Equipment">
  <tr><td>Equipment <xsl:value-of select="@name" /></td></tr>
  <xsl:for-each select="Element">
    <xsl:sort select="@part" />
    <tr>
      <td>
        <xsl:value-of
          select="position() +
                  count(../Equipment/preceding::Element)" />
      </td>
      <td>Element </td>
      <td><xsl:value-of select="@qty" /></td>
    </tr>
  </xsl:for-each>
</xsl:template>

but it's hard to tell. If this isn't what you want, I suggest you
provide a longer sample XML document (including several <Element>
elements with different part attributes, in different <Equipment>
elements) and some sample output that you want generated from it.
Providing the XSLT that you've tried and that isn't working would help
as well.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.