Need help with XSLT sort
Hi all, well I am fairly new to XSLT but I managed to write a stylesheet that takes in some proprietary XML code and converts it to cleaner, DITA-compliant code. Below I have pasted in a sample of the source, as well as my XSLT. Everything is working great, except my XSLT simply outputs code in the same order as it appears in the source code. I need to sort the ouput based on the <category> tag. For example, all "beans" in the Feeds category should be grouped together, all beans in the misc category should be grouped together, all beans without a value for category should be grouped together, etc. Any tips would be greatly appreciated!
Source Code:
<bean id="com.j2fe.feeds.activities.FileSplitBase">
<displayName>FileSplitBase</displayName>
<shortDescription id="com.j2fe.feeds.activities.FileSplitBase#shortD escription"/>
<implements>java.beans.BeanInfo</implements>
<category>Feeds</category> (need to sort on this value)
<properties>
<property id="com.j2fe.feeds.activities.FileSplitBase#proper ty#businessFeed">
<displayName>Business Feed</displayName>
<shortDescription id="com.j2fe.feeds.activities.FileSplitBase#proper ty#businessFeed#shortDescription"/>
<output>no</output>
<input>yes</input>
<required>yes</required>
<type>java.lang.String</type>
</property>
</bean>
My XSLT:
<xsl:template match="documentation">
<topic>
<xsl:attribute name="id">JavaBeans</xsl:attribute>
<title>JavaBeans Documentation</title>
<xsl:apply-templates select="bean"/>
</topic>
</xsl:template>
<xsl:template match="bean">
<bean>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<title><xsl:value-of select="displayName"/></title>
<shortdesc><xsl:value-of select="shortDescription"/></shortdesc>
<beanbody>
<properties>
<xsl:attribute name="id"><xsl:value-of select="@id"/>Props</xsl:attribute>
<prophead>
<propdisplaynamehd>Display Name</propdisplaynamehd>
<propdeschd>Description</propdeschd>
<proptypehd>Type</proptypehd>
<propinputhd>Input</propinputhd>
<propdependsonhd>Dependencies</propdependsonhd>
</prophead>
<property>
<propdisplayname><xsl:value-of select="displayName"/></propdisplayname>
<propdesc><xsl:value-of select="shortDescription"/></propdesc>
<proptype><xsl:value-of select="type"/></proptype>
<propinput><xsl:value-of select="input"/></propinput>
<propdependson><xsl:value-of select="dependsOn"/></propdependson>
</property>
</properties>
</beanbody>
</bean>
</xsl:template>
|