Re: Preserving the base URI through a p:xslt transformation

> I think the
> problem is that the p:xslt step then goes and implies a base-uri on
> its own and its probably a bug but (assuming you are using calabash)
> will let impl comment further.

I don't think it's a bug: the previous steps in the pipeline touch the base URI of the *root element*, not the *document*. In other words, the base URI of the 'doc' document that is created inline is always the base URI of the XProc document throughout the pipeline.

This is one of the reasons why I once suggested a step to set a document's base URI. It seems that an XSLT identity with a output-base-uri option would do the job (albeit less readable) – but it doesn't seem to work in Calabash.

Romain.


On 22 mars 2013, at 11:28, James Fuller <jim@webcomposite.com> wrote:

> On Fri, Mar 22, 2013 at 10:50 AM, Jostein Austvik Jacobsen
> <josteinaj@gmail.com> wrote:
>> So this pipeline:
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
>>    <p:input port="source">
>>        <p:inline>
>>            <doc xml:base="file:/tmp/"/>
>>       </p:inline>
>>    </p:input>
>>    <p:output port="result"/>
>>    <p:delete match="/*/@xml:base"/>
>>    <p:add-attribute match="/*" attribute-name="base-before">
>>        <p:with-option name="attribute-value" select="base-uri(/*)"/>
>>    </p:add-attribute>
>>    <p:xslt>
>>        <p:input port="parameters">
>>            <p:empty/>
>>        </p:input>
>>        <p:input port="stylesheet">
>>            <p:inline>
>>                <xsl:stylesheet
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
>>                    <xsl:template match="/">
>>                        <xsl:copy-of select="/"/>
>>                    </xsl:template>
>>                </xsl:stylesheet>
>>            </p:inline>
>>        </p:input>
>>    </p:xslt>
>>    <p:add-attribute match="/*" attribute-name="base-after">
>>        <p:with-option name="attribute-value" select="base-uri(/*)"/>
>>    </p:add-attribute>
>> </p:declare-step>
>> 
>> Gives me this on the output port:
>> 
>> <doc base-after="file:/home/jostein/preserve-base-test.xpl"
>> base-before="file:/tmp/"/>
>> 
>> I would like to get this:
>> 
>> <doc base-after="file:/tmp/" base-before="file:/tmp/"/>
>> 
>> How can I make an XSLT transformation preserve the base URI of the document
>> without using the xml:base attribute?
> 
> note that p:xslt has a output-base-uri option
> 
> verbatim from the spec
> 
> 'The output-base-uri option sets the context's output base URI per the
> XSLT 2.0 specification, otherwise the base URI of the result document
> is the base URI of the first document in the source port's sequence.
> If the value of the output-base-uri option is not absolute, it will be
> resolved using the base URI of its p:option element. An XSLT 1.0 step
> should use the value of the output-base-uri as the base URI of its
> output, if the option is specified.'
> 
> so you first set the base uri explicitly,
> then you delete the attribute
> then you dowse it back,
> finally pushing it through xslt meat grinder….
> 
> the statement from the spec
> 
> 'otherwise the base URI of the result document is the base URI of the
> first document in the source port's sequence'
> 
> when you delete the attribute, this does not affect base-uri (because
> delete attribute is not deleting its actual base-uri) … I think the
> problem is that the p:xslt step then goes and implies a base-uri on
> its own and its probably a bug but (assuming you are using calabash)
> will let impl comment further.
> 
> if it helps, I think your expectation is valid and your example a good
> candidate for a new unit test which I will try to fold into the w3c
> xproc unit test suite.
> 
> hth, Jim Fuller
> 

Received on Friday, 22 March 2013 12:08:23 UTC