Skip to content

Commit

Permalink
Compatibility with Saxon 10 and 11
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 committed Feb 4, 2023
1 parent 0898883 commit 3c96945
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 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 @@ -75,7 +75,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 @@ -119,9 +119,9 @@
</xsl:call-template>
<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 @@ -101,9 +101,8 @@

<xsl:template match="catalog" mode="o:select">
<xsl:param name="uri-stack" tunnel="yes" as="xs:anyURI*" select="()"/>
<selection opr:src="{if (exists($uri-stack)) then $uri-stack[last()] else document-uri(root())}">
<selection opr:src="{if (exists($uri-stack)) then $uri-stack[last()] else 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-or-profile" as="element()"/>
<xsl:sequence select="$catalog-or-profile/(@uuid,document-uri(root(.)))[1]"/>
<xsl:sequence select="$catalog-or-profile/(@uuid,base-uri(root(.)))[1]"/>
</xsl:function>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,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 3c96945

Please sign in to comment.