This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]