xlst query to have grouping to only show 1 header for each value of select instead of multiple headers



I have an xlst query thats returning all the correct information i want from the xml raw data however because it has multiple objects it is returninf each result with its own headers but i only want 1 at the very start and not the others can anyone help me with the grouping. this is the xlst query:



<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="CMDBSet">
<table border="1">
<tr bgcolor="">
<th>display label</th>
<th>root class</th>
<th>host servertype</th>
<th>host osreleasetype</th>
<th>host osinstalltype</th>
</tr>
<xsl:for-each select="CMDBObject/Properties">
<tr>
<td><xsl:value-of select="display_label"/></td>
<td><xsl:value-of select="root_class"/></td>
<td><xsl:value-of select="host_servertype"/></td>
<td><xsl:value-of select="host_osrelease"/></td>
<td><xsl:value-of select="host_osinstalltype"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


and a snippet of the xml raw data:



<?xml version="1.0" encoding="UTF-8"?>
<CMDBTopology>
<Objects>
<CMDBSet>
<name>80df0b42de8f31ac4cb7a30d325ff0c1</name>
<CMDBObject>
<identifier type="nt">80df0b42de8f31ac4cb7a30d325ff0c1</identifier>
<Properties>
<root_class type="STRING">nt</root_class>
<host_servertype type="STRING"></host_servertype>
<host_osrelease type="STRING"></host_osrelease>
<display_label type="STRING">pharsm-s3004</display_label>
<host_osinstalltype type="STRING"></host_osinstalltype>
</Properties>
</CMDBObject>
</CMDBSet>
<CMDBSet>
<name>8305e305bdaf613b50deab1da4ae469c</name>
<CMDBObject>
<identifier type="nt">8305e305bdaf613b50deab1da4ae469c</identifier>
<Properties>
<root_class type="STRING">nt</root_class>
<host_servertype type="STRING"></host_servertype>
<host_osrelease type="STRING">3790</host_osrelease>
<display_label type="STRING">phchbs-si442</display_label>
<host_osinstalltype type="STRING">Server Standard Edition</host_osinstalltype>
</Properties>
</CMDBObject>


I came across some possible way i could possibly achieve this like using a grouping like:



<xsl:key name="keyrootclass" match="diplaylabel" use="rootclass" />
<xsl:key name="keyhostservertype" match="displaylabel" use="hostservertype" />
<xsl:key name="keyhostosreleasetype" match="displaylabel" use="hostosreleasetype" />
<xsl:key name="keyhostservertype" match="displaylabel" use="hostservertype" />


but i am stuck on how to proceed as if i add these lines it wont output anything but without these keyname lines i get the output but with multiple header for each cmdbobject


No comments:

Post a Comment