Hi,
Can anyone help me out in trimming my xsl code to get the deisred output?
The input xml is:
<output-xml>
<group>
<identifier>a</identifier>
group a_Interface {
// Signature definition
signature a_<signature>DNSQuery1(in long ant)
return iso8859string;
</signature>
}
</group>
<group>
<identifier>b</identifier>
<identifier>a</identifier>
group b_Interface {
// Signature definition
signature b_<signature>DNSQuery2(inout string grass)
return long;
</signature>
}
</group>
<group>
<identifier>c</identifier>
<identifier>b</identifier>
group c_Interface {
// Signature definition
signature c_<signature>DNSQuery3(out boolean fish)
return boolean;
</signature>
}
</group>
<group>
<identifier>d</identifier>
<identifier>c</identifier>
group d_Interface {
// Signature definition
signature d_<signature>DNSQuery3(out long cricket)
return short;
</signature>
}
</group>
</output-xml>
The xsl:
<xsl:output method="text" indent="yes"/>
<xsl:key name="GroupByIdentifier" match="group" use="identifier[1]"/>
<xsl:template match="signature">
<xsl:variable name="CurrentGroupID" select="../identifier[1]"/>
<xsl:copy-of select="."/><xsl:text>
</xsl:text>
<xsl:if test="count(../identifier[2])>0">
signature <xsl:value-of select="$CurrentGroupID"/>_<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>
</xsl:stylesheet>
gives the output:
a
group a_Interface {
// Signature definition
signature a_DNSQuery1(in long ant)
return iso8859string;
}
b
a
group b_Interface {
// Signature definition
signature b_DNSQuery2(inout string grass)
return long;
signature b_DNSQuery1(in long ant)
return iso8859string;
}
c
b
group c_Interface {
// Signature definition
signature c_DNSQuery3(out boolean fish)
return boolean;
signature c_DNSQuery2(inout string grass)
return long;
signature b_DNSQuery1(in long ant)
return iso8859string;
}
d
c
group d_Interface {
// Signature definition
signature d_DNSQuery3(out long cricket)
return short;
signature d_DNSQuery3(out boolean fish)
return boolean;
signature c_DNSQuery2(inout string grass)
return long;
signature b_DNSQuery1(in long ant)
return iso8859string;
}
What I need to do is, I should remove the identifiers a, ba, cb and dc
which are generated before the group "X_Interface". And, I've to get the
current group's identifier[1]_<xsl:apply-templates
select="key('GroupByIdentifier',../identifier2])/signature"/>
for all the signatures that belong to the same group. For example, in the
last group the output should be,
group d_Interface {
// Signature definition
signature d_DNSQuery3(out long cricket)
return short;
signature d_DNSQuery3(out boolean fish)
return boolean;
signature d_DNSQuery2(inout string grass)
return long;
signature d_DNSQuery1(in long ant)
return iso8859string;
}
Can anyone find what is wrong with the xsl?
Thanks and regards,
Ram
__________________________________
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