Skip to content

Commit

Permalink
Use dcfilename if base is empty
Browse files Browse the repository at this point in the history
* Derive output filename from base and dcfilename
* Introduce new parameter json-ld.ext (".json") that holds the
  filename extension
  • Loading branch information
tomschr committed Feb 12, 2024
1 parent 752a0f7 commit 43264e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 16 additions & 5 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@
<xsl:when test="$node/@xml:base">
<xsl:value-of select="substring-before($node/@xml:base, '.xml')" />
</xsl:when>
<xsl:when
test="($node/@id or $node/@xml:id) and $use.id.as.filename != 0">
<xsl:value-of select="($node/@id | $node/@xml:id)[1]" />
<xsl:when test="$node/@xml:id and $use.id.as.filename != 0">
<xsl:value-of select="$node/@xml:id" />
</xsl:when>
<xsl:otherwise /><!-- TODO: What do we do here, if nothing works? -->
</xsl:choose>
Expand Down Expand Up @@ -190,8 +189,20 @@
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="filename" select="concat($base, '.json')"/>
<xsl:variable name="dcfile" select="concat('DC-', $base)"/>
<xsl:variable name="filename">
<xsl:variable name="dcfile">
<xsl:call-template name="get-dc-filename"/>
</xsl:variable>
<xsl:variable name="file" select="substring-after($dcfile, 'DC-')"/>
<xsl:choose>
<xsl:when test="$base != ''">
<xsl:value-of select="concat($base, $json-ld.ext)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($file, $json-ld.ext)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content">
<xsl:call-template name="generate-json-content">
<xsl:with-param name="node" select="$node"/>
Expand Down
2 changes: 2 additions & 0 deletions suse2022-ns/xhtml/param.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ task before
<xsl:param name="stitchfile"/>
<!-- Should the individual authors be used? 0=no, 1=yes -->
<xsl:param name="json-ld-use-individual-authors" select="1"/>
<!-- File extension -->
<xsl:param name="json-ld.ext">.json</xsl:param>
<!-- Timezone -->
<xsl:param name="json-ld-date-timezone">+02:00</xsl:param>
<xsl:param name="json-ld-fallback-author-name">SUSE Product &amp; Solution Documentation Team</xsl:param>
Expand Down

0 comments on commit 43264e3

Please sign in to comment.