Skip to content

Instantly share code, notes, and snippets.

@prabhu
Created June 4, 2020 02:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prabhu/b81188264748572a4a7134a907686176 to your computer and use it in GitHub Desktop.
Save prabhu/b81188264748572a4a7134a907686176 to your computer and use it in GitHub Desktop.
XSLT to transform CycloneDX SBoM xml to Markdown
<xsl:stylesheet version="1.0" xmlns:bom="http://cyclonedx.org/schema/bom/1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:text>## Project dependencies</xsl:text>
<xsl:text>&#xa;&#xa;</xsl:text>
<xsl:text>| Vendor | Name | Version | License Id | </xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>| -------|------|---------|------------|</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:for-each select="/bom:bom/bom:components/bom:component">
<xsl:text>| </xsl:text>
<xsl:value-of select="bom:group"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="bom:name"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="bom:version"/>
<xsl:text> | </xsl:text>
<xsl:value-of select="bom:licenses/bom:license/bom:id"/>
<xsl:text> |</xsl:text>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
@prabhu
Copy link
Author

prabhu commented Jun 4, 2020

#!/usr/bin/env bash
# Script to convert Software Bill-of-Materials (SBoM) to markdown

xsltproc bom.xslt bom.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment