I have the following XML that needs to be displayed in a table, in this format:
Column 1:
Requirement
REQ-1
REQ-2
REQ-3
REQ-4
Column 2:
Acceptance Test
AT-1
AT-1
AT-1
AT-2
How can I achieve this using XSLT1.0?
<?xml version="1.0" encoding="UTF-8"?> <Item type ="Acceptance Test"> <jav_acc_id>AT-1</jav_acc_id> <Relationships> <Item type ="Acceptance Test Requirements"> <related_id> <Item type ="Requirement" > <item_number>REQ-1</item_number> </Item> </related_id> </Item> <Item type =" Acceptance Test Requirements "> <related_id> <Item type ="Requirement" > <item_number>REQ-2</item_number> </Item> </related_id> </Item> <Item type =" Acceptance Test Requirements "> <related_id> <Item type ="Requirement" > <item_number>REQ-3</item_number> </Item> </related_id> </Relationships> </Item> <Item type ="Acceptance Test"> <jav_acc_id>AT-2</jav_acc_id> <Relationships> <Item type ="Acceptance Test Requirements"> <related_id> <Item type ="Requirement" > <item_number>REQ-4</item_number> </Item> </related_id> </Item> </Relationships> </Item>
This is what I have (which creates an output that is SO wrong but I have no idea how to fix it)
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <table border="1"> <th style="text-align:left">Requirement</th> <th style="text-align:left">Acceptance Test</th> </tr> <xsl:for-each select="descendant::Item"> <tr> <td><xsl:value-of select="item_number"/></td> <td><xsl:value-of select="jav_acc_id"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
No comments:
Post a Comment