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

Re: avoiding repetition - more refined

Subject: Re: avoiding repetition - more refined
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 12 Mar 2002 01:57:24 -0700 (MST)
avoiding repetition
Hi,

Although long lines are sometimes unavoidable, please try to use spaces
instead of tabs in your code samples. Thanks :)

You wrote:

  <xsl:choose>
    <xsl:when test="$SortOrder= '1'">
      <xsl:apply-templates select="calls/DevelopmentJob">
        <xsl:sort select="Priority"/>
      </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="calls/DevelopmentJob">
        <xsl:sort select="Order"/>
      </xsl:apply-templates>
    </xsl:otherwise>
  </xsl:choose>

Your XML doesn't have any 'DevelopmentJob' elements as children of 'calls'
elements, so this will never produce any results.


The way you described your problem, somehow you have decided that you want to
see DevelopmentRequirement with drid="1" first. I don't know how you decided
that... perhaps the rule is that you were looking for the first
DevelopmentRequirement 'with' steve? Is this a more general grouping problem
where you want to iterate over the unique 'with's? The answers to these
questions affect the answer to your problem.

Well, no matter what the answers to those questions are, I can tell you how to
achieve exactly what you asked for (which may not have been what you really
wanted):

  <!-- go process the first DevelopmentRequirement -->
  <xsl:apply-templates select="calls/DevelopmentRequirement[1]"/>


  ...


  <!-- template to process any DevelopmentRequirement -->
  <xsl:template match="DevelopmentRequirement">
    <!-- replicate this node and its contents -->
    <xsl:copy-of select="."/>
    <!-- select this person's other DevReqs for special processing -->
    <xsl:apply-templates select="following-sibling::DevelopmentRequirement[with=current()/with]" mode="contents-only"/>
  </xsl:template>

  <!-- template to process any DevelopmentRequirement specially -->
  <xsl:template match="DevelopmentRequirement" mode="contents-only">
    <xsl:copy-of select="child::node()"/>
  </xsl:template>

Here I have invented the 'contents-only' mode as a way of ensuring that
I process some DevelopmentRequirement elements in a special way during
certain situations.

I hope this helps.


   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  personal: http://hyperreal.org/~mike/

 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.