[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: "stevenson" <stevenson@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Mar 2002 12:26:17 +0300
xml repetition exactly 1
What happens is that, if a development requirement is assigned to somebody;
it has its development jobs. But one person can have many development
requirements i.e. <developmentrequirement drid='1'> with it's DJ's i.e.
<developmentjob djdrid="1">, <developmentrequirement drid='2'> with it's
DJ's i.e. < developmentjob djdrid="2">, <developmentrequirement drid='3'>
with it's DJ's i.e. < developmentjob djdrid="3">

What I want to achieve is that once you choose the person with a DR let's
say <developmentrequirement drid='1'>, on the display I get:

<Developmentrequirement drid='1'> with it's <developmentjob djdrid='1''>,
then it gives me the rest of the DJ's

<Developmentjob djdrid='2''>, <developmentjob djdrid='3''> without there
DR's



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Mike Brown
Sent: 12 March 2002 11:57
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  avoiding repetition - more refined

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



 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.