xsl-list
[Top] [All Lists]

Handling "IDL" Inheritence

2003-11-13 11:13:40
Hi, 
 I'm generating TTCN-3 output from IDL(Interface Definition Language)
input.
For that I need to handle inheritence in IDL. For an IDL input like this:

      module Snake {
        interface Adder {
           string accumulate(inout long a);
        };
        interface a:Adder {
           void success(in string cool);
        };
        interface b:a {
           long reset(in string c);
        };
     };

  The output should look like:
       
     module Snake{
        group AdderInterface {                  
                signature Adder_accumulate (inout long a)
                                    return iso8859string;       
        }
        group aInterface {                                      
                        
                signature a_success (in iso8859string cool);            

                signature a_accumulate (
                inout long a) return iso8859string;
        }
        group bInterface {                                              
                        
                signature b_reset (in iso8859string c)                  
                                return long;            

                signature b_accumulate (inout long a)           
                                return iso8859string;
           
                signature b_success (in iso8859string cool);
        }
     }

     I've parsed the IDL file with ANTLR tool and xml serialized it. The
xml file after the conceptual mapping with I need to generate the TTCN-3
text output is shown below.

<?xml version="1.0" encoding="UTF-8"?>
<formatted-xml>
 <module>module<identifier>Snake</identifier><identifier>{</identifier>
  <group>group<identifier>Adder</identifier><identifier>{</identifier>
    <returntype>
      <iso8859string>iso8859string                                 
         <operation><identifier>accumulate</identifier>                   
                                  
                         <identifier>(</identifier>                             
           
<inout>inout<returntype><long>long</long></returntype>
                                        <identifier>a</identifier>
            </inout><identifier>)</identifier>
         </operation>
      </iso8859string>
    </returntype>
                <identifier>, </identifier>
                <identifier>}</identifier>
   </group>
                   
   <group>group<identifier>a</identifier><identifier>Adder</identifier>
                                          <identifier>{</identifier>
     <returntype>
        <void>void
          <operation><identifier>success</identifier>
                           <identifier>(</identifier>                           
            
<in>in<returntype><iso8859string>iso8859string</iso8859string>
                   </returntype><identifier>cool</identifier>
             </in><identifier>)</identifier>
          </operation>
        </void>
     </returntype>
                <identifier>, </identifier>
                <identifier>}</identifier>
   </group>
                 
 <group>group<identifier>b</identifier><identifier>a</identifier> 
                                       <identifier>{</identifier>
   <returntype>
       <long>long                                 
         <operation><identifier>reset</identifier>
                                      <identifier>(</identifier>
            <in>in<returntype><iso8859string>iso8859string</iso8859string>
                  </returntype><identifier>c</identifier>
            </in><identifier>)</identifier>
         </operation>
       </long>
    </returntype>
                <identifier>, </identifier>
                <identifier>}</identifier>
   </group>
   <identifier>}</identifier>
 </module>
</formatted-xml>

   I could handle generate all stuffs except the inhertence.
The XSL I wrote to generate the inheritence output was:

<xsl:choose>
   <xsl:when test="identifier[2]!='{' and   
                   identifier[2]=preceding::group/identifier">
   signature <xsl:value-of select="$interfaceID"/>_<xsl:value-of  
              select="preceding::returntype/*/operation/identifier"/> (
     <xsl:choose>
        <xsl:when test ="preceding::returntype/*/operation/in">
          <xsl:value-of select="preceding::returntype/*/operation/in"/>
        </xsl:when>
        <xsl:when test ="preceding::returntype/*/operation/inout">
          <xsl:value-of select="preceding::returntype/*/operation/inout"/>
        </xsl:when>
        <xsl:when test ="preceding::returntype/*/operation/out">
          <xsl:value-of select="preceding::returntype/*/operation/out"/>
        </xsl:when>
    </xsl:choose>)
    <xsl:choose>
        <xsl:when test="preceding::returntype/*/text()">
           return <xsl:value-of select="preceding::returntype/*/text()"/>
        </xsl:when>
    </xsl:choose>
    <xsl:choose>
        <xsl:when test="preceding::returntype/*/operation/exception">
           exception (<xsl:value-of select=
           
"preceding::returntype/*/*/exception/identifier[2]"/>Exception)
        </xsl:when>
    </xsl:choose><xsl:text>;</xsl:text>
                </xsl:when>
</xsl:choose>

   And the output I get is:

  module Snake{
     group AdderInterface {                     
        signature Adder_accumulate (inout long a)
                                return iso8859string;           

     }
     group aInterface { 
        signature a_success (in iso8859string cool);    
        signature a_accumulate (inout long a)           
                                return iso8859string ;
     }
     group bInterface { 
        signature b_reset (in iso8859string c)                  
                                return long;
        // here i've the real problem. It mixes the preceding group
        // operations. it should be 
        //signature b_accumulate (inout long a)         
        //                      return iso8859string ;
        // And the third signature is missing
          
        signature b_success (in iso8859string cool)             
                                return iso8859string ;
        }
}

  Someone please help me.
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



<Prev in Thread] Current Thread [Next in Thread>
  • Handling "IDL" Inheritence, Ram <=