W3C home > Mailing lists > Public > xproc-dev@w3.org > November 2011

RE: The file name for the output of an xsl:result-document

From: Geert Josten <geert.josten@dayon.nl>
Date: Thu, 3 Nov 2011 22:58:47 +0100
Message-ID: <b9b9b63d0a3f46eeea4773f1f097beda@mail.gmail.com>
To: David Cramer <david@thingbag.net>, xproc-dev@w3.org
You don't really need the replace on $input-base. Resolve-uri will chop
off the filename part if there is any. But it may be convenient to have
the path-without-filename around.. ;-)

Kind regards,

-----Oorspronkelijk bericht-----
Van: David Cramer [mailto:david@thingbag.net]
Verzonden: donderdag 3 november 2011 22:44
Aan: xproc-dev@w3.org
Onderwerp: Re: The file name for the output of an xsl:result-document

Hash: SHA1

Ah, I'm starting to get it. Now I"ve got it doing exactly what I want.

I've pasted the pipeline I ended up with below in case anybody else
happens on this thread and wants to know how make the output file land
in a directory relative to the input file and also make the files
produced by xsl:result-document land in the same place.

In my case, the pipeline/xslt takes a single wadl file as input and
produces a flattened wadl file and a number of flattened xsds. It also
validates the input and output wadls against a schema, though it just
occurred to me that I still need to add a step so that it validates
the output schemas as well.

Thanks so much for all your help!


<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
    <p:input port="source"/>
    <p:output port="secondary" primary="false" sequence="true"/>

    <p:variable name="input-base" select="replace(base-uri(/*),
'^(.*/)?([^/]+)$', '$1')"/>
    <p:variable name="input-name" select="replace(base-uri(/*),
'^(.*/)?([^/]+)$', '$2')"/>
    <p:variable name="output-wadl"
select="resolve-uri(concat('normalized/',$input-name), $input-base)"/>

    <p:validate-with-xml-schema assert-valid="true" mode="strict"
        <p:input port="schema">
            <p:document  href="xsd/wadl.xsd"/>

    <p:xslt name="style" version="2.0">
        <p:input port="source">
            <p:pipe step="validate" port="result"/>
        <p:input port="stylesheet">
            <p:document href="xsl/normalizeWadl.xsl"/>
        <p:input port="parameters">

    <p:validate-with-xml-schema assert-valid="true" mode="strict"
        <p:input port="schema">
            <p:document  href="xsd/wadl.xsd"/>

        <p:with-option name="href" select="$output-wadl"/>
        <p:log port="result" href="xproc1.log"/>

            <p:pipe step="style" port="secondary"/>
        <p:store encoding="utf-8" indent="true"
            <p:with-option name="href"
'^(.*/)?([^/]+)$', '$2')),$input-base)"/>


On 11/03/2011 10:34 AM, Geert Josten wrote:
> Hi David,
> AVTs are indeed not supported, unfortunately. You will have to use
>  p:with-output for passing in a variable as well.
> <p:store> <p:with-option name="href" select="$output-wadl"/>
> </p:store>
> The second store doesn't work, because resolve-uri only prepends a
> base if the first argument represents a relative path. By
> supplying base-uri(/*) you are passing in an absolute path, so
> resolve-uri won't work. You can grab the last part of the path
> using a replace:
> replace(base-uri(/*), '^(.*/)?([^/]+)$', '$2')
> Kind regards, Geert
> -----Oorspronkelijk bericht----- Van: David Cramer
> [mailto:david@thingbag.net] Verzonden: donderdag 3 november 2011
> 15:43 Aan: XProc Dev Onderwerp: Re: The file name for the output
> of an xsl:result-document
> Thanks Geert and Vojtech,
> At the top of the file I've tried various versions of:
> <p:variable name="input-base" select="p:base-uri(/*)"/>
> <p:variable name="output-wadl"
> select="p:resolve-uri('foo.xml',$input-base)"/>
> Then to store the main result document, I want to use the value of
>  variable, but clearly AVTs aren't the way to do it:
> <p:store href="{$output-wadl}"/>
> Likewise, for the documents on the secondary port, using
> resolve-uri (or p:resolve-uri) doesn't have any effect:
> <p:with-option name="href"
> select="resolve-uri(base-uri(/*),$input-base)"/>
> I've put the whole listing here:
> http://pastebin.com/3dQzsQ2b
> What am I doing wrong?
> I feel like I'm struggling with very basic things. Aside from the
> spec, is there a good xproc reference or tutorial that would help
> with these questions? I've googled up a few things, but nothing
> that that seems comprehensive. The best thing I've found so far is:
> http://www.xfront.com/xproc/
> Thanks, David
> On 11/03/2011 06:09 AM, Geert Josten wrote:
>> Hi David,
>> Sounds like you want to put a p:variable at the top of your
>> pipeline/declare-step, do the base-uri(/) or base-uri(/*) there.
>>  That takes the base-uri of the input, instead of the generated
>> output. Then use resolve-uri('foo.xml', $input-base-uri) to get a
>> path for foo.xml in the input folder..
>> Kind regards, Geert
>> -----Oorspronkelijk bericht----- Van: David Cramer
>> [mailto:david@thingbag.net] Verzonden: donderdag 3 november 2011
>>  3:06 Aan: Geert Josten CC: XProc Dev Onderwerp: Re: The file
>> name for the output of an xsl:result-document
>> Thanks Geert. That helped. Using p:log, I learned that
>> base-uri(/*) causes the files land in my home directory with
>> their appropriate file names.
>> Now I just need to figure out how to say in xproc "In the same
>> directory as the source document" (or in some dir passed in from
>>  Oxygen anyway). E.g. here:
>> <p:store href="concat(???, '/', 'foo.xml')"/>
>> and here:
>> <p:with-option name="href" select="concat( ???, '/',
>> p:base-uri(/*))"/>
>> Though I could be going about it all wrong.
>> Thanks, David
>> On 11/01/2011 04:10 PM, Geert Josten wrote:
>>> Hi David,
>>> Bit of a guess here, but have you tried base-uri(/*) ?
>>> Kind regards, Geert

Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

Received on Thursday, 3 November 2011 21:59:27 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:09 UTC