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

Re: sequence of filtered documents as input of p:xslt

From: Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr>
Date: Tue, 18 Oct 2011 10:53:06 +0200
Message-ID: <4E9D3E72.7090808@igs-cp.fr>
To: Romain Deltour <rdeltour@gmail.com>
CC: xproc-dev@w3.org
Hi Romain,

And also sorry for my late reply.

I have tested with */@data and it works !

The context node is actually the document itself, that means I have to 
select the document root element with "*" just like I would do in xslt 
with :
<xsl:template match="/*">
which is not the same as <xsl:template match="/"> which matches the root 
node (cf. http://www.dpawson.co.uk/xsl/sect2/root.html)

I actually used a variable to store the @data attribute and make the 
xpath explicit  :
<p:variable name="svgSrc" select="/h:object/@data"/>

Everithing's fine !
Thanks for helping,

Best Regards,
Matthieu.

Le 14/10/2011 19:22, Romain Deltour a écrit :
>> With <p:with-option name="href" select="concat('PAGES_SVG_0/', 
>> @data)"/> I get an error : GRAVE: err:XC0011:Could not load PAGES_SVG_0/
>> It seems @data is empty at this point.
>
> Right. The XPath context at this point is a *document* (with 'object' 
> as its root element), @data returns the empty sequence.
>
> I suppose it would work with:
>
> <p:with-option name="href" select="concat('PAGES_SVG_0/', */@data)"/>
>
> Romain.
>
> Le 14 oct. 11 à 16:58, Matthieu Ricaud-Dussarget a écrit :
>
>> Hi Romain,
>>
>> Thanks for your suggest !
>>
>> It almost works but I still have problem to store the load the good 
>> svg file.
>>
>> This is the code i've tested :
>> <p:for-each name="for-each-html-object">
>> <p:iteration-source select="//h:object">
>> <p:pipe step="generateECF" port="result"/>
>> </p:iteration-source>
>> <!--<p:output port="load-svg"/>-->
>> <p:load name="load-svg">
>> <p:with-option name="href" select="concat('PAGES_SVG_0/', @data)"/>
>> <!--<p:with-option name="href" select="concat('PAGES_SVG_0/', 
>> 'epub0001.svg')"/>-->
>> </p:load>
>> <p:xslt name="PDFTronSVG2epubFixedSVG">
>> <p:input port="stylesheet">
>> <p:document href="../xslt/PDFTronSVG2epubFixedSVG.xsl"/>
>> </p:input>
>> <p:input port="parameters"><p:empty/></p:input>
>> </p:xslt>
>> <p:store encoding="UTF-8" omit-xml-declaration="false" indent="true">
>> <p:with-option name="href" select="concat('PAGES_SVG_01/', 
>> tokenize(document-uri(/),'/')[last()])"></p:with-option>
>> </p:store>
>> </p:for-each>
>>
>> With <p:with-option name="href" select="concat('PAGES_SVG_0/', 
>> 'epub0001.svg')"/>, it works, but it's always the same document that 
>> is processed.
>> But it is processed 3 times, which proof the iteration on object 
>> works fine (there a 3 object in my document)
>>
>> With <p:with-option name="href" select="concat('PAGES_SVG_0/', 
>> @data)"/> I get an error : GRAVE: err:XC0011:Could not load PAGES_SVG_0/
>> It seems @data is empty at this point.
>> I have tried @h:data (prefix "h" binded to xhtml namespace), but I 
>> get the same error.
>>
>> The spec indicate the xpath context inside an iteration is "the 
>> sequence of documents that will be processed by the p:for-each", that 
>> means each document is here <object data="..."/>, so I should be able 
>> to get the data attribute, no?
>>
>> Any ideas ?
>>
>> Regards,
>> Matthieu.
>>
>>
>>
>>
>> Le 13/10/2011 14:13, Romain Deltour a écrit :
>>>> - should I iterate the <object> elements within the XHTML doc and 
>>>> then getting the svg document as input
>>>
>>> That's what I would do.
>>>
>>>> (...)
>>>> <p:input port="source" select="document(concat('PAGES_SVG_0', 
>>>> tokenize(@data,'/')[last()] ))">
>>>> (...)
>>>
>>> The select expression is applied to the document connected on the 
>>> input port. What you rather want here is to load the SVG documents 
>>> using a dynamically computed URI, which is then connected to the 
>>> primary input port of the XSLT. You can do that with p:load, e.g.:
>>>
>>> <p:load>
>>> <p:with-option name="href" select="concat('PAGES_SVG_0', 
>>> tokenize(@data,'/')[last()])"/>
>>> </p:load>
>>>
>>>
>>> To summarize, the workflow would be:
>>>
>>> p:for-each (iterate the objects)
>>>  p:load (load the document after having computed the URI)
>>>  p:xslt
>>>
>>> Hope this helps,
>>> Romain.
>>>
>>> Le 13 oct. 11 à 13:31, Matthieu Ricaud-Dussarget a écrit :
>>>
>>>> Hi all,
>>>>
>>>> Continuing discovering xproc, I have a new problem today :
>>>>
>>>> One of the steps of my pipeline gives for result an XHTML document 
>>>> that contains many
>>>> <object data="fileA.svg">, <object data="fileB.svg"> elements.
>>>>
>>>> Of course each referenced "file{?}.svg" exists in a specific 
>>>> directory, let's call it "SVGdir".
>>>>
>>>> I'd like to iterate on those file{?}.svg and apply an XSLT 
>>>> transformation to each one (and store the result in separate 
>>>> directoty).
>>>>
>>>> I don't want to iterate the "SVGdir" directly cause it can contains 
>>>> some svg files which I don't want to transform cause they are not 
>>>> referenced in the XHTML document.
>>>>
>>>> I think there are 2 options :
>>>> - filtering the directory files according to the XHTML
>>>> - starting from the XHTML to iterate on the good SVG files in the 
>>>> directory
>>>> I thought the 2nd option is better.
>>>>
>>>> (remind : I don't want the XSLT to be applied on the XHTML document 
>>>> itself, cause I'd like it to be independant : it takes one SVG in 
>>>> input and get one SVG in output.)
>>>>
>>>> The spec says that <p:xslt> can have a sequence of documents as input.
>>>> But I don't find a way to make that work :
>>>> - should I give an xpath collection() for p:xslt/p:input/@select => 
>>>> xproc error
>>>> - should I iterate the <object> elements within the XHTML doc and 
>>>> then getting the svg document as input :
>>>> <p:for-each name="for-each-html-object">
>>>> <p:iteration-source select="//h:object">
>>>> <p:pipe step="generateECF" port="result"/>
>>>> </p:iteration-source>
>>>> <p:xslt name="PDFTronSVG2epubFixedSVG">
>>>> <p:input port="source" select="document(concat('PAGES_SVG_0', 
>>>> tokenize(@data,'/')[last()] ))">
>>>> <p:pipe step="for-each-html-object" port="current"/>
>>>> </p:input>
>>>>         [...]
>>>> </p:for-each>
>>>> => xproc err:XD0023:Invalid XPath expression
>>>>
>>>> I will continue to investigate for other solutions, but if you have 
>>>> any advices, they are welcome !
>>>>
>>>> Kind Regards,
>>>>
>>>> Matthieu.
>>>>
>>>> -- 
>>>> Matthieu Ricaud
>>>> IGS-CP
>>>> Service Livre numérique
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>> -- 
>> Matthieu Ricaud
>> IGS-CP
>> Service Livre numérique
>>
>>
>
>


-- 
Matthieu Ricaud
IGS-CP
Service Livre numérique
Received on Tuesday, 18 October 2011 08:53:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 18 October 2011 08:53:45 GMT