I’ve updated my SQL client from MySQL Query Browser to MySQL Workbench.
With that upgrade my XML format changed and my XSLT don’t work anymore. It will only show the first item.
Here is a simplify version of the XML and XSLT, it’s Nessus output send to a MySQL database.
XML
<?xml version="1.0" encoding="UTF-8"?>
<DATA>
<ROW>
<Niveau>Haute</Niveau>
<Nom>Some vulnerability</Nom>
<Solution>Some Solution</Solution>
<cve>CVE-2006-1234, CVE-2006-5615</cve>
<bid>11263, 11291</bid>
<Number>5</Number>
</ROW>
<ROW>
<Niveau>Haute</Niveau>
<Nom>Some Other Vulnerability</Nom>
<Solution>Apply the security patch.</Solution>
<cve>CVE-2006-1742, CVE-2006-1743</cve>
<bid>20584, 20585</bid>
<Number>23</Number>
</ROW>
<ROW>
<Niveau>Moyenne</Niveau>
<Nom>Yet another vulnerability</Nom>
<Solution>Do this and that</Solution>
<cve></cve>
<bid></bid>
<Number>2</Number>
</ROW>
</DATA>
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:processing-instruction name="mso-application">
<xsl:text>progid="Word.Document"</xsl:text>
</xsl:processing-instruction>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<w:body>
<xsl:for-each select="DATA/ROW">
<w:p>
<w:r>
<w:t><xsl:value-of select="Nom"/></w:t>
</w:r>
</w:p>
</xsl:for-each>
</w:body>
</w:wordDocument>
</xsl:template>
</xsl:stylesheet>
I then parse that in a script that merge the two in a Word document. It use to create as many table as I had entries. But now I only get the first line.
I’m pretty sure it has to do with either <xsl:template match="/"> or <xsl:for-each select="DATA/ROW"> but I can’t seem to find the correct combination.
If one could also tell me how to add a sequential number before the Nom like so 1- Nom I’d be a very happy camper.
Current output
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<w:body>
<w:p>
<w:r>
<w:t>Some vulnerability</w:t>
</w:r>
</w:p>
</w:body>
</w:wordDocument>
Desired output
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<w:body>
<w:p>
<w:r>
<w:t>1- Some vulnerability</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>2- Some Other Vulnerability</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>3- Yet another vulnerability</w:t>
</w:r>
</w:p>
</w:body>
</w:wordDocument>
Thank you.
This should do what you want:
A “more XSLT” solution would be:
Output for both is: