- From: Jostein Austvik Jacobsen <josteinaj@gmail.com>
- Date: Fri, 22 Mar 2013 12:08:16 +0100
- To: James Fuller <jim@webcomposite.com>
- Cc: XProc Dev <xproc-dev@w3.org>
- Message-ID: <CAOCxfQd=Kk+vqiVSjFLp_9MP+99tWBRpJrYFVNEfWyEfoQuE9A@mail.gmail.com>
Thanks for the detailed response. I tried output-base-uri now, but
unfortunately it didn't help:
<p:with-option name="output-base-uri" select="base-uri(/*)"/>
Yes, I am indeed using calabash version 1.0.8.94 (in oXygen 14.2).
So a workaround for now can be something like this:
<p:group>
<p:variable name="base" select="base-uri(/*)"/>
<p:xslt>
...
</p:xslt>
<p:choose>
<p:when test="/*[@xml:base]">
<p:identity/>
</p:when>
<p:otherwise>
<p:add-attribute match="/*" attribute-name="xml:base">
<p:with-option name="attribute-value" select="$base"/>
</p:add-attribute>
<p:delete match="/*/@xml:base"/>
</p:otherwise>
</p:choose>
</p:group>
Thanks!
Jostein
On 22 March 2013 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 11:09:07 UTC