xsl-list
[Top] [All Lists]

Re: Remove Duplicates from Recursive Template Calls

2005-05-04 15:14:20
Thanks again for your suggestions.  I found an Identity Transformation sample 
at http://www.dpawson.co.uk/xsl/sect2/identity.html#d5391e43

I created a simple example using my existing estimate attribute.  Although 
everything looks correct to the website example, I am unable to modify the time 
estimate attribute.  What am I missing?

----- Identity Transformation Stylesheet -----
<!-- The Identity Transformation -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <!-- Whenever you match any node or any attribute -->
  <xsl:template match="node()|@*">
    <!-- Copy the current node -->
    <xsl:copy>
      <!-- Including any attributes it has and any child nodes -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

----- My Stylesheet -----
<?xml version="1.0"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
  xmlns:xalan="http://xml.apache.org/xslt"; 
  version="1.0" >
<xsl:import href="Identity.xsl"/>
<xsl:output method="html" encoding="UTF-8" indent="yes" xalan:indent-amount="2" 
/>

<xsl:template match="/project">
  <xsl:call-template name="Deliverables" />
</xsl:template>

<xsl:template name="Deliverables">
  <xsl:for-each select="/project/componentGroup">
  <xsl:if test="@type='Deliverable'">
    <xsl:for-each select="component">
      Deliverables: <xsl:value-of select="@id"/><br/>
      <xsl:call-template name="DeliverableReferences"/>
      <br/>
    </xsl:for-each>
  </xsl:if>
  </xsl:for-each>
</xsl:template>

<xsl:template name="DeliverableReferences">
  <xsl:param name="indent" select="''"/>
  <xsl:for-each select="componentReference">
  <xsl:sort select="@idRef" />
  <xsl:variable name="idRef" select="@idRef" />
      <xsl:for-each select="//component[(_at_)id=$idRef]">
          <xsl:value-of select="$indent"/>
          (<xsl:value-of select="@estimate"/>)
          <xsl:attribute name="estimate">XXX</xsl:attribute>
          <xsl:value-of select="@estimate"/>&#160;
          <xsl:value-of select="@id"/>
          <br/>
          <xsl:call-template name="DeliverableReferences">
              <xsl:with-param name="indent" 
select="concat($indent,'&#160;&#160;&#160;&#160;')"/>
          </xsl:call-template>
      </xsl:for-each>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

----- Output Results -----
Deliverables: Phase1
(6) 6  AllocationReport
     (4) 4  Markets
         (1) 1  Market
             (6) 6  SelectBox
     (4) 4  ModelYear
         (6) 6  SelectBox
(6) 6  CheckOut
     (1) 1  Market
         (6) 6  SelectBox

Deliverables: Phase2
(6) 6  SchedulingReport
     (1) 1  Market
         (6) 6  SelectBox
     (4) 4  ModelYear
         (6) 6  SelectBox

Please Note that the second @estimate printed should have XXX per the attribute 
tag.

Thanks again,

Pat

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>