Skip to content

Commit

Permalink
Compatibility with Saxon 10 and 11 (#1685)
Browse files Browse the repository at this point in the history
Replace document-uri with base-uri. Saxon 10 and 11 can
return different values from document-uri() function. For
compatibility and to avoid errors when document-uri() returns
empty with Saxon 11, use base-uri() instead.
  • Loading branch information
galtm authored and aj-stein-nist committed Jul 10, 2023
1 parent b267c6a commit 59ef15d
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/utils/util/resolver-pipeline/oscal-profile-RESOLVE.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
Each represents a stage in processing.
The result of each processing step is passed to the next step as its input, until no steps are left. -->
<xsl:call-template name="alert">
<xsl:with-param name="msg" expand-text="yes"> RESOLVING PROFILE { document-uri($source) } </xsl:with-param>
<xsl:with-param name="msg" expand-text="yes"> RESOLVING PROFILE { base-uri($source) } </xsl:with-param>
</xsl:call-template>
<xsl:iterate select="$transformation-sequence/*">
<xsl:param name="doc" select="$source" as="document-node()"/>
Expand Down Expand Up @@ -98,9 +98,9 @@
<xsl:variable name="xslt-spec" select="."/>
<xsl:variable name="runtime-params" as="map(xs:QName,item()*)">
<xsl:map>
<xsl:map-entry key="QName('','profile-origin-uri')" select="document-uri($home)"/>
<xsl:map-entry key="QName('','profile-origin-uri')" select="base-uri($home)"/>
<xsl:map-entry key="QName('','path-to-source')" select="$path-to-source"/>
<xsl:map-entry key="QName('','uri-stack-in')" select="($uri-stack, document-uri($home))"/>
<xsl:map-entry key="QName('','uri-stack-in')" select="($uri-stack, base-uri($home))"/>
<xsl:apply-templates select="." mode="opr:provide-parameters"/>
</xsl:map>
</xsl:variable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
</xsl:if>
</xsl:for-each>
<!-- Return the version from the source parameter. -->
<xsl:value-of select="$source"/>
<xsl:sequence select="$source"/>
</xsl:function>

<!--<xsl:template match="selection" mode="imported-metadata">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<!-- condition not(@by-id != $id) includes any addition without an @by-id, or whose @by-id is the control id -->
<xsl:variable name="implicit-patches-to-id" select="$modifications/key('alteration-for-control-id',$id,.)/add[not(@by-id != $id)]" as="element(add)*"/>

<xsl:copy-of select="$patches-to-id-targeting-ancestor[@position = 'before']/*"/><xsl:message>got here! removable is <xsl:sequence select="oscal:removable(./*[1],$modifications)"/></xsl:message>
<xsl:copy-of select="$patches-to-id-targeting-ancestor[@position = 'before']/*"/>
<xsl:if test="not(ancestor::control and oscal:removable(.,$modifications))">
<xsl:copy>
<xsl:copy-of select="@*"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@
</xsl:template>

<xsl:template match="catalog" mode="o:select">
<selection opr:src="{document-uri(root())}">
<selection opr:src="{base-uri(root())}">
<xsl:copy-of select="@* except @xsi:*" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<!--<xsl:attribute name="opr:base" select="document-uri(root())"/>-->
<xsl:apply-templates mode="#current"/>
</selection>
</xsl:template>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/util/resolver-pipeline/random-util.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ v4 UUID
<!-- Set $germ to a string for reproducible outputs of r:make-uuid.
Pass in a blind value - and don't save it - for irreproducible outputs. -->

<xsl:param name="germ" select="current-dateTime() || document-uri(/)"/>
<xsl:param name="germ" select="current-dateTime() || base-uri(/)"/>

<!-- for testing random number features -->
<xsl:template match="/" name="xsl:initial-template" expand-text="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

<xsl:function name="opr:catalog-identifier" as="xs:string">
<xsl:param name="catalog" as="element(o:catalog)"/>
<xsl:sequence select="$catalog/(@uuid,document-uri(root(.)))[1]"/>
<xsl:sequence select="$catalog/(@uuid,base-uri(root(.)))[1]"/>
</xsl:function>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@
<x:call function="opr:catalog-identifier">
<x:param href="catalog-no-uuid.xml" select="/o:catalog"/>
</x:call>
<x:expect label="Returns document URI of catalog" test="ends-with($x:result,'/catalog-no-uuid.xml')"/>
<x:expect label="Returns base URI of catalog" test="ends-with($x:result,'/catalog-no-uuid.xml')"/>
</x:scenario>
</x:scenario>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xslt-version="3.0">

<!-- For repeatable testing, use a fixed germ. Also, XSpec
cannot evaluate document-uri(/) in the default parameter
cannot evaluate base-uri(/) in the default parameter
value from the XSLT. -->
<x:param name="germ">x</x:param>

Expand Down

0 comments on commit 59ef15d

Please sign in to comment.