Re: [xsl] Remove Duplicates from Recursive Template Calls

Subject: Re: [xsl] Remove Duplicates from Recursive Template Calls
From: "Patrick Lademan" <plademan@xxxxxxxxxxxxxxxxx>
Date: Wed, 04 May 2005 17:14:20 -0500
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[@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

Current Thread