Project

Profile

Help

Base URI {urn:from-string} is a non-hierarchic URI

Added by Martin Honnen almost 2 years ago

When running XSLT and XML input through my fiddles I set the base URI to urn:from-string. Today I have tried to run such a stylesheet doing an xsl:import href="some-HTTP-URL" (where the URL is one like <xsl:import href="https://cdn.docbook.org/release/xsltng/current/xslt/docbook.xsl" />) and then my fiddle fails to run the stylesheet with the error Base URI {urn:from-string} is a non-hierarchic URI (in "Error executing XSLT at line 539").

I wonder whether Saxon (the fiddle runs Saxon 10 HE .NET) or whether DocBook stylesheets give that error message.

I will try to debug that further but usually Mike is good at telling whether a certain error message comes from Saxon itself.

And Norm might know whether his xsltng stylesheets give such an error, I have let oXygen search through the sources for non-hierarchic and Base URI but it hasn't found anything.


Replies (10)

Please register to reply

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Michael Kay almost 2 years ago

Well, it looks like we're invoking relative URI resolution even though the href is absolute, and it's failing because the base URI isn't heirarchic. Sounds off-hand like something that's probably conformant but a bit unfriendly.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Martin Honnen almost 2 years ago

Thanks, I have now identified the stylesheet code as doing <xsl:sequence select="resolve-uri($chunk-output-base-uri, base-uri(root($node)/*))"/>, will need to check further where the variables are set and try to understand what resolve-uri is supposed to do.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Martin Honnen almost 2 years ago

The spec has the paragraph

A dynamic error is raised [err:FORG0002] if $base is not a valid IRI according to the rules of RFC3987, extended with an implementation-defined subset of the extensions permitted in LEIRI, or if it is not a suitable IRI to use as input to the chosen resolution algorithm (for example, if it is a relative IRI reference, if it is a non-hierarchic URI, or if it contains a fragment identifier).

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Martin Honnen almost 2 years ago

Hmm, seems some Docbook oddity, it looks like it does e.g. resolve-uri('', 'urn:from-string') , based on

<xsl:param name="chunk-output-base-uri" as="xs:string">
  <xsl:choose>
    <xsl:when test="not($v:chunk)">
      <!-- it doesn't actually matter -->
      <xsl:sequence select="''"/>
    </xsl:when>
    <xsl:when use-when="function-available('ext:cwd')"
              test="true()">
      <xsl:message select="'Default output base uri:',
                           resolve-uri(ext:cwd(), static-base-uri())"/>
      <xsl:sequence select="resolve-uri(ext:cwd(), static-base-uri())"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:message terminate="yes"
                   select="'You must specify the $chunk-output-base-uri'"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:param>

I guess most people will not run Docbook through that fiddle, I will see whether I can improve the error message of the fiddle to include the stylesheet module.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Michael Kay almost 2 years ago

And the question is whether that rule takes precedence over the rule

If $relative is an absolute IRI (as defined above), then it is returned unchanged.

Section 1.4 says:

The next section in the proforma defines the semantics of the function as a set of rules. The order in which the rules appear is significant; they are to be applied in the order in which they are written. Error conditions, however, are generally listed in a separate section that follows the main rules, and take precedence over non-error rules except where otherwise stated.

which suggests that the error rule takes precedence here.

However 1.4 also says

The principles outlined in Section 2.3.4 Errors and Optimization XP31 apply by default: to paraphrase, if the result of the function can be determined without evaluating all its arguments, then it is not necessary to evaluate the remaining arguments merely in order to determine whether any error conditions apply.

which suggests that if the href argument is absolute, we can return a result without evaluating the base argument. So I think we have discretion.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Norm Tovey-Walsh almost 2 years ago

Hmm, seems some Docbook oddity, it looks like it does e.g.
resolve-uri('', 'urn:from-string') , based on

I’ll see if I can improve the DocBook stylesheets. Getting the output
URIs correct is a bit fiddly (don’t even get me started about getting
the “input URIs” of images correct relative to the “output URI” of the
chunk in which they appear!).

Be seeing you,
norm

--
Norm Tovey-Walsh
Saxonica

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Michael Kay almost 2 years ago

I added test case fn-resolve-uri-33 which does

resolve-uri("http://www.example.com/books.xml", "urn:doi:234567")

and allowing both "http://www.example.com/books.xml" and FORG0002 as allowed outcomes.

SaxonJ 11.3 is returning "http://www.example.com/books.xml". It tests whether the URI is absolute before looking at $base.

This is an explicit call on fn:resolve-uri(), and it's possible that URI resolution for xsl:include (say) is taking a different path.

UseWhenFilter.processIncludeImport() passes both href and base to DocumentFn.computeDocumentKey(), which calls ResolveURI.makeAbsolute(href, baseURI). I'll put together a test for this path.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Michael Kay almost 2 years ago

I found that

<xsl:import href="file:///Users/mike/Desktop/temp/test-fa.xsl" xml:base="urn:doi:1234"/>

works fine, so I think we're consistent. The error complaining that the base URI is non-hierarchic should only occur if $relative is not an absolute URI.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Martin Honnen almost 2 years ago

Yes, Mike, thanks for your effort, it seems, as I commented somewhere, that the Docbook stylesheet (as at some point it does not care about a real base output uri as it is not "chunking") assigns the empty string '' as the base output uri and does resolve-uri('', 'urn:from-string') in a code path that then correctly causes the error by Saxon. I had never run into that message so I couldn't quite figure what was causing it or what is was related to. But Saxon is not at fault here.

RE: Base URI {urn:from-string} is a non-hierarchic URI - Added by Norm Tovey-Walsh almost 2 years ago

I've updated the DocBook xslTNG stylesheets so that they won't raise this exception when chunking isn't in use. Clearly, I never tested the stylesheets with an input document that had a non-hierarchical URI.

    (1-10/10)

    Please register to reply