This stylesheet shows the essential parts. You can adapt it to produce
the HTML that you want. I have assumed that your xml is contained in a
"root" element.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding='iso-8859-1'/>
<xsl:variable name='types'
select='/root/member[contains(@name,"T:")]'/>
<xsl:variable name='methods'
select='/root/member[contains(@name,"M:")]'/>
<xsl:template match="/root">
<results>
<xsl:apply-templates select='$types' mode='type'/>
</results>
</xsl:template>
<xsl:template match='member' mode='type'>
<xsl:variable name='type-name'
select='substring-after(@name,"T:")'/>
<!-- Display type-specific information here -->
<xsl:variable name='method-name'
select='concat("M:",$type-name,".")'/>
<xsl:apply-templates
select='$methods[contains(@name,$method-name)]'
mode='method'/>
</xsl:template>
<xsl:template match='member' mode='method'>
<!-- Display method-specific information here -->
</xsl:template>
</xsl:stylesheet>
[Aparna Konduri]
I need help in parsing an xml file generated for java classes
and interfaces. Suppose I have a class like Car, and say Car
implements Vehicle interface.
interface Vehicle{
getIdentification();
}
class Car implements Vehicle
{
getName();
getIdenitifcation();
}
XML is of the form :
<member name="T:Car">
<summary>
It's a car class.
</summary>
</member>
<member name="T:Vehicle">
<summary>
It's a vehicle interface.
</summary>
</member>
<member name="M:Vehicle.getIdentification">
<summary>
Identification of the vehicle.
</summary>
</member>
<member name="M:Car.getName">
<summary>
Name of the Car.
</summary>
</member>
<member name="M:Car.getIdentification">
<summary>
Name of the Car.
</summary>
</member>
Note that in xml M: stands for method, and T: stands for Type.
Do you see that interface Vehicle information comes in
between Car? Because of this html is messed up.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list