Skip to content

Commit

Permalink
Introduce json-ld-software
Browse files Browse the repository at this point in the history
* Use of "mentions": List
* Remove json-ld-version (included in json-ld-software)
  • Loading branch information
tomschr committed Feb 12, 2024
1 parent 43264e3 commit 3ffbac5
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
<xsl:message>Going to write external JSON-LD structure to "<xsl:value-of
select="$filename"/>" for <xsl:value-of select="local-name($node)"/>
Found <xsl:value-of select="count($stitchxml)"/> node(s) (=<xsl:value-of select="local-name($stitchxml)"/>).
<xsl:if test="$dcfilename">Found DC filename "<xsl:value-of select="$dcfilename"/>"</xsl:if>
</xsl:message>
<xsl:call-template name="write.chunk">
<xsl:with-param name="filename" select="$filename"/>
Expand Down Expand Up @@ -246,12 +247,11 @@
<xsl:call-template name="json-ld-keywords">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>

<!-- Later --><!--<xsl:call-template name="json-ld-license">
<!-- Later -->
<!--<xsl:call-template name="json-ld-license">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
-->

<xsl:call-template name="json-ld-authors-and-authorgroups">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
Expand All @@ -268,12 +268,13 @@
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<!-- Belongs to type "SoftwareApplication" -->
<xsl:call-template name="json-ld-version">
<xsl:call-template name="json-ld-software">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<!--
<xsl:call-template name="json-ld-productname">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
</xsl:call-template>-->

<!-- This is the last entry. Don't add further additions due to the
trailing comma missing.
Expand Down Expand Up @@ -309,7 +310,6 @@
</xsl:template>



<xsl:template name="json-ld-headline">
<xsl:param name="node" select="."/>
<xsl:variable name="headline"
Expand Down Expand Up @@ -640,17 +640,6 @@
</xsl:template>

<!-- The following templates access the Docserv config -->
<xsl:template name="json-ld-version">
<xsl:param name="node" select="."/>
<xsl:variable name="productnumber" select="($node/d:info/d:productnumber)"/>
<xsl:variable name="meta" select="$node/d:info/d:meta[@name='productname']/d:productname/@version"/>
<xsl:variable name="version" select="($productnumber | $meta)[last()]"/>

<xsl:if test="$version != ''">
"softwareVersion": "<xsl:value-of select="$version"/>",
</xsl:if>
</xsl:template>

<xsl:template name="json-ld-productname">
<xsl:param name="node" select="."/>
<xsl:variable name="info-productname" select="$node/d:info/d:productname"/>
Expand Down Expand Up @@ -740,4 +729,34 @@
</xsl:if>
</xsl:template>

<xsl:template name="json-ld-software">
<xsl:param name="node" select="."/>
<xsl:variable name="info-productnumber" select="normalize-space($node/d:info/d:productnumber)"/>
<xsl:variable name="info-productname" select="normalize-space($node/d:info/d:productname)"/>
<!-- <xsl:variable name="meta-productnumber" select="$node/d:info/d:meta[@name='productname']/d:productname/@version"/>-->
<xsl:variable name="meta-productname" select="$node/d:info/d:meta[@name='productname']/d:productname"/>
<xsl:variable name="tmp-productname-with-version">
<xsl:if test="$info-productname">
<productname xmlns="http://docbook.org/ns/docbook" version="{$info-productnumber}"
><xsl:value-of select="$info-productname"/></productname>
</xsl:if>
</xsl:variable>
<xsl:variable name="productname-with-version" select="exsl:node-set($tmp-productname-with-version)/*"/>
<!-- <xsl:variable name="productnumber" select="($info-productnumber | $meta-productnumber)[last()]"/>-->
<xsl:variable name="productname" select="($productname-with-version | $meta-productname)"/>

<xsl:if test="$productname">
"mentions": [
<xsl:for-each select="$productname">
{ "@type": "SoftwareApplication",
"name": "<xsl:value-of select="."/>",
"softwareVersion": "<xsl:value-of select="@version"/>",
"applicationCategory": "Operating System",
"operatingSystem": "Linux"
}
<xsl:if test="position() != last()">,&#10; </xsl:if>
</xsl:for-each>
],
</xsl:if>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 3ffbac5

Please sign in to comment.