Re: question on p:directory-list and base-uri()

Norm Tovey-Walsh <ndw@nwalsh.com> writes:
> Heidi Vanparys <hevan@kds.dk> writes:
>> 2: base-uri(/) =                           file:/H:/test/sub1/
>> 2: base-uri(/c:directory) =                file:/H:/test/sub1/sub1/
>
> That really looks wrong.

There’s something ugly going on here. The observations below are based on my implementation, but I wonder if it’s systemic given that Morgana seems to produce the same results.

I created

  /tmp/y
  /tmp/y/file
  /tmp/y/z
  /tmp/y/z/file

If I do a recursive directory list over /tmp/y and then run the result through this stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="xs"
                version="3.0">

<xsl:output method="xml" encoding="utf-8" indent="no"/>

<xsl:template match="*">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:attribute name="b" select="base-uri(.)"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

The result is:

<c:directory xmlns:c="http://www.w3.org/ns/xproc-step"
             xml:base="file:/tmp/y/"
             name="y"
             b="file:/tmp/y/">
   <c:file xml:base="file" name="file" b="file:/tmp/y/file"/>
   <c:directory xml:base="z/" name="z" b="file:/tmp/y/z/">
      <c:file xml:base="file" name="file" b="file:/tmp/y/z/file"/>
   </c:directory>
</c:directory>

Those are the correct base URIs, so we feel like all is well. Then we do:

<p:for-each name="base-uris-directories">
  <p:with-input select="//c:directory/c:directory" />
  <p:xslt>
    <p:with-input port="stylesheet" href="test.xsl"/>
  </p:xslt>
</p:for-each>

And we get this mess:

<c:directory xmlns:c="http://www.w3.org/ns/xproc-step"
             xml:base="z/"
             name="z"
             b="file:/tmp/y/z/z/">
   <c:file xml:base="file" name="file" b="file:/tmp/y/z/z/file"/>
</c:directory>

It’s pretty easy to see *what* has happened: the xml:base attribute has been applied on top of the current base URI. From one perspective, that’s not wrong. That’s ow a relative xml:base attribute is supposed to be resolved.

What I can’t see is *why* this has happened. In order to satisfy the select attribute on p:for-each, a new document had to be created for the inner c:directory element. That appears to have started with the correct base URI and then “re-applied” the xml:base attribute to it.
And I can’t quite persuade myself that that’s incorrect behavior.

I think that the p:directory-list step is perhaps being too clever here. Or maybe I’m just not being clever enough at the moment…

                                        Be seeing you,
                                          norm

--
Norm Tovey-Walsh <ndw@nwalsh.com>
https://norm.tovey-walsh.com/

> I think age is a very high price to pay for maturity.--Tom Stoppard

Received on Tuesday, 25 February 2025 17:57:04 UTC