xsl-list
[Top] [All Lists]

RE: How to copy the previous operations?

2003-11-20 01:49:46
Charles,
 Actually, the input xml file is a dynamic one and the number of 'group'
is arbitrary. 
 "If a group identifier is followed by an identifier which was already
defined before, then the signature part of that group identifier should be
added to this signature part".
 I understand that I should use some recursive structure to fix this.
But, I don't know how.

What I tried was:

<xsl:template match="group">
        <xsl:variable name="groupID" select="identifier"/>
        group<xsl:text> </xsl:text><xsl:value-of  
                 select="$groupID"/>Interface {
        <xsl:call-template name="generation"/>  
        <xsl:apply-templates select="generation"/>
        <xsl:apply-templates select="group"/>
        }
</xsl:template>
<xsl:template name="generation" match="signature">
   <!--How the signature part output should look like goes here-->
   <!--Copying the previous group identifier signature part-->
   <xsl:if test="identifier[2]= preceding::group/identifier">
     <xsl:copy>
         <xsl:apply-templates select="preceding::group/signature"/>
      </xsl:copy>
   </xsl:if>
</xsl:template>

 But, couldn't get the desired output.
BR,
Ram





--- cknell(_at_)onebox(_dot_)com wrote:
You've got a misconception about the process of creating a new tree of
nodes that is tipped by this statement " (which should have already
copied the first group identifier a's signature part)".

A stylesheet refers only to the input tree and itself. I does not have
read access to the output tree. Therefor the notion that your stylesheet
can refer to a tree fragment that has been "already copied" is fatally
flawed.

I think this problem can be resolved by recursive calls to a named
template, but there isn't enough information to decide exactly how it
should be structured. Is there a set number of <group> elements in a
document, or is this arbitrary?
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Ram <sram_30(_at_)yahoo(_dot_)com>
Sent:     Wed, 19 Nov 2003 08:21:57 -0800 (PST)
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] How to copy the previous operations?

Hi,
 Can anyone help me out how to copy the previous operations?
The xml source would look like this:

<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>
  </group>
  <group><identifier>c</identifier><identifier>b</identifier>
     <signature>signature<identifier>DNSQuery3</identifier>             
 
        
       <out>out<boolean>boolean</boolean>
<identifier>fish</identifier></out>
     </signature>
  </group>
</formatted-xml>

    What I have to do is, I should copy the signature part the first
group
identifier 'a' to the signature part in group identifier 'b', because it
is followed by the group identifier 'a'.
    Similarly, the third group identifier 'c' is followed by the second
group identifier 'b' (which should have already copied the 
first group identifier a's signature part) and so the second group
identifier's signature part should be copied to the third group
identifier
signature part.

I tried the following xsl.

<xsl:template match="group">
  <xsl:if test="identifier[2]= preceding::group/identifier">
     <xsl:copy>
        <xsl:apply-templates select="preceding::group/signature"/>
     </xsl:copy>
  </xsl:if>
</xsl:template>
 
  But it didn't work.

Thanks and regards,
Ram


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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




 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



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