Skip to content

Commit

Permalink
If no author is found, use a default author
Browse files Browse the repository at this point in the history
  • Loading branch information
tomschr committed Feb 15, 2024
1 parent 84725ae commit 8e92982
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
- Depending on if we have one element or many, we deal accordingly. If we don't have any element
at all, we fallback to the default author.
-->
<xsl:variable name="authors">
<xsl:variable name="tmp-authors">
<d:authorgroup>
<xsl:choose>
<xsl:when test="$type = 'contributor'">
Expand All @@ -466,7 +466,7 @@
</xsl:choose>
</d:authorgroup>
</xsl:variable>
<xsl:variable name="rtf-authors" select="exsl:node-set($authors)/*"/>
<xsl:variable name="rtf-authors" select="exsl:node-set($tmp-authors)/*"/>

<!-- <xsl:message>INFO: json-ld-authors-and-authorgroups
authors = <xsl:value-of select="count($authors)"/>
Expand All @@ -475,7 +475,17 @@
name(rtf-authors/*[1]) = <xsl:value-of select="local-name($rtf-authors/*[1])"/>
</xsl:message>-->

<xsl:if test="count($rtf-authors/*) > 0">
<xsl:choose>
<!-- If we don't find any authors, create a default one -->
<xsl:when test="$type = 'author' and count($rtf-authors/*) = 0">
"author": [
{
"@type": "Organization",
"name": "<xsl:value-of select="$json-ld-fallback-author-name"/>"
}
],
</xsl:when>
<xsl:when test="count($rtf-authors/*) > 0">
"<xsl:value-of select="$type"/>": [
<xsl:for-each select="$rtf-authors/*">
<xsl:variable name="person">
Expand Down Expand Up @@ -509,7 +519,9 @@
}<xsl:if test="position() != last()">,&#10; </xsl:if>
</xsl:for-each>
],
</xsl:if>
</xsl:when>
<!-- Do we need an xsl:otherwise? -->
</xsl:choose>
</xsl:template>

<xsl:template name="json-ld-datePublished">
Expand All @@ -532,7 +544,7 @@
<xsl:value-of select="normalize-space(string($node/d:info/d:pubdate))"/>
</xsl:when>
<xsl:when test="normalize-space($node/d:info/d:date) != ''">
<xsl:value-of select="normalize-space(string($node/d:info/d:pubdate))"/>
<xsl:value-of select="normalize-space(string($node/d:info/d:date))"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
Expand All @@ -544,8 +556,6 @@
</xsl:if>
</xsl:variable>

<xsl:message>### <xsl:value-of select="$date"/></xsl:message>

<xsl:choose>
<xsl:when test="$date != ''">
"datePublished": "<xsl:value-of select="$date"/>",
Expand Down Expand Up @@ -744,7 +754,7 @@
"name": "<xsl:value-of select="normalize-space(.)"/>",
<xsl:if test="normalize-space(@version) != ''">"softwareVersion": "<xsl:value-of select="@version"/>",</xsl:if>
"applicationCategory": {"name": "Operating System"},
"operatingSystem": {"name": "Linux"}<xsl:if test="$candidate-arch">,
"operatingSystem": {"name": "Linux"}<xsl:if test="normalize-space($candidate-arch) != ''">,
"processorRequirements": "<xsl:value-of select="$candidate-arch"/>"
</xsl:if>
}
Expand Down

0 comments on commit 8e92982

Please sign in to comment.