Skip to content

Commit

Permalink
more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Apr 16, 2024
1 parent 414edde commit 1e3fb40
Showing 1 changed file with 49 additions and 34 deletions.
83 changes: 49 additions & 34 deletions tools/resolve-paths.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -317,52 +317,67 @@
<xsl:with-param name="p" select="." />
</xsl:apply-templates>
</xsl:variable>
<xsl:if test="string($path)">
<xsl:variable name="non-final-segments">
<xsl:call-template name="namespace">
<xsl:with-param name="qname" select="$path" />
<xsl:with-param name="sep" select="' '" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="final-segment">
<xsl:call-template name="name">
<xsl:with-param name="qname" select="$path" />
<xsl:with-param name="sep" select="' '" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="self::*">
<xsl:copy>
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="string($path)">
<xsl:variable name="non-final-segments">
<xsl:call-template name="namespace">
<xsl:with-param name="qname" select="$path" />
<xsl:with-param name="sep" select="' '" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="final-segment">
<xsl:call-template name="name">
<xsl:with-param name="qname" select="$path" />
<xsl:with-param name="sep" select="' '" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="self::*">
<xsl:copy>
<xsl:attribute name="id">
<xsl:value-of select="generate-id()" />
</xsl:attribute>
<xsl:if test="string($non-final-segments)">
<xsl:attribute name="p0:{name()}">
<xsl:if test="string($non-final-segments)">
<xsl:attribute name="p0:{name()}">
<xsl:value-of select="$non-final-segments" />
</xsl:attribute>
</xsl:if>
<xsl:attribute name="p1:{name()}">
</xsl:if>
<xsl:attribute name="p1:{name()}">
<xsl:value-of select="$final-segment" />
</xsl:attribute>
<xsl:apply-templates select="@*|node()"
mode="ids" />
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
<xsl:if test="string($non-final-segments)">
<xsl:attribute name="p0:{name()}">
<xsl:apply-templates select="@*|node()"
mode="ids" />
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
<xsl:if test="string($non-final-segments)">
<xsl:attribute name="p0:{name()}">
<xsl:value-of select="$non-final-segments" />
</xsl:attribute>
</xsl:if>
<xsl:attribute name="p1:{name()}">
</xsl:if>
<xsl:attribute name="p1:{name()}">
<xsl:value-of select="$final-segment" />
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:if test="edm:*">
<xsl:attribute name="id">
<xsl:value-of select="generate-id()" />
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@*|node()"
mode="ids" />
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="@*" mode="path" />

<xsl:template match="*" mode="path">
<xsl:param name="p" />
<xsl:variable name="q"
Expand Down

0 comments on commit 1e3fb40

Please sign in to comment.