xsl-list
[Top] [All Lists]

Re: Re: Re: Recursive calls to a named template

2003-11-21 03:27:27

On Friday 21 November 2003 08:43, Ram wrote:
Exactly Charles! That z what I need...

Ram

Ok. That ones a bit easier, this should do it. Sorry for 
confusing the issue.

xsl:key name="GroupByIdentifier" match="group" 
use="identifier[1]"/>

<xsl:template match="signature">
 <xsl:copy-of select="."/>
 <xsl:if test="count(../identifier[2])>0">
  <xsl:apply-templates 
select="key('GroupByIdentifier',../identifier[2])/signature"/>
  </xsl:if>
 </xsl:template>

 <xsl:template match="node()|@*">
  <xsl:copy>
   <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
 </xsl:template>

Kev.


--- cknell(_at_)onebox(_dot_)com wrote:
-----Original Message-----
From:     Kevin Jones <kjones(_at_)sarvega(_dot_)com>
Subject:  Re: Re: [xsl] Recursive calls to a named
template

Maybe I misunderstood what Ram was trying to achieve. In
the output below the signature elements have been replaced
by following the identifier mapping in the XML. In this
example they all end up with the signature from the first
group. The output shown is consistent with my
interpretation of the problem he was trying to solve. Was
something different required?

[Ram, if you want to jump in here to clarify this, it will
make it easier to help.]

My understanding was that he wanted to include all component
signatures. For example, in the input document the last
<group> contains <identifier>b</identifier> and
<identifier>c</identifier>. The next-to-last <group>
contains <identifier>b</identifier> and
<identifier>a</identifier>. Therefor, I believe that in the
last group in the output, he wants to include the
<signature> elements from the first and second groups in
addition to its own <signature> element and the next-to-last
<group> should contain the <signature> element from the
first <group> in addition to its own <signature> element.
That would make the output look like this:

<?xml version = '1.0' encoding = 'UTF-8'?>
<formatted-xml>
   <group>
      <identifier>a</identifier>
      <signature>signature
      <identifier>DNSQuery1</identifier>
      <in>in
        <long>long</long>
        <identifier>ant</identifier>
      </in>
   </signature>
   </group>
   <group>
      <identifier>b</identifier>
      <identifier>a</identifier>
      <signature>signature
      <identifier>DNSQuery2</identifier>
      <inout>inout
        <string>string</string>
        <identifier>grass</identifier>
      </inout>
    </signature>
      <signature>signature
      <identifier>DNSQuery1</identifier>
      <in>in
        <long>long</long>
        <identifier>ant</identifier>
      </in>
   </signature>
   </group>
   <group>
      <identifier>c</identifier>
      <identifier>b</identifier>
      <signature>signature
      <identifier>DNSQuery3</identifier>
      <out>out
        <boolean>boolean</boolean>
        <identifier>fish</identifier>
      </out>
     </signature>
      <signature>signature
      <identifier>DNSQuery2</identifier>
      <inout>inout
        <string>string</string>
        <identifier>grass</identifier>
      </inout>
    </signature>
      <signature>signature
      <identifier>DNSQuery1</identifier>
      <in>in
        <long>long</long>
        <identifier>ant</identifier>
      </in>
   </signature>
   </group>
</formatted-xml>
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email


 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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