W3C home > Mailing lists > Public > xproc-dev@w3.org > August 2015

Re: Newbie question

From: Conal Tuohy <conal.tuohy@gmail.com>
Date: Tue, 11 Aug 2015 10:32:34 +1000
Message-ID: <CAErBQuTnQSuU=4Va6onMDDckQrVeMkS+S2nTtFWJM7Ei65ksDw@mail.gmail.com>
To: Dan Vint <dvint@dvint.com>
Cc: XProc Dev <xproc-dev@w3.org>
Good morning Dan!

It seems to me that you should be able to run all that in Oxygen's XProc
interpreter (which is XMLCalabash).

You can iterate over a directory of files, copy files, zip files, and apply
stylesheets.

Depending on what your batch file does, you may be able to port it to XProc
as well, otherwise you can at least run it using p:exec though you will
still have the issue that your batch file is platform-specific.

Depending on what your Ant script does, you may be able to port it to XProc
as well. Certainly if (as the comment suggests) it is just removing XML
processing instructions, then that can be replaced with a single XProc step:

<p:delete match="processing-instruction()"/>

Regards

Conal

On 11 August 2015 at 09:32, Dan Vint <dvint@dvint.com> wrote:

> Ok, moving the serialization information to the store makes better sense
> to me. I was also able to work around  my issue with generating text
> instead of XML. I setup the stylesheet to wrap the text output in a dummy
> element. Then setting the store output to be text then strips out the new
> element, so I get the text the way I want it.
>
> In working through these issues I think I may not be using the correct
> tools. Is XPROC just meant for passing XML from one task to another and not
> a more general scripting tool that understands typical XML processes?
>
> Here is what I'm trying to do overall:
>
> 1) Take a DITA Map file and  process  the  structure and links to make a
> new flattened single file map.
> 2) I want to store that flattened map to an XML file that I will keep
> around, but I also want to pass it to another stylesheet that creates a
> batch file based upon the information in the XML. I don't want to process
> this result anymore.
> 3) I want to execute the batch file.
> 4) I also want to process all the XML files in a given directory with the
> following:
>   4a) Run an ant script against all of the files.
>    4b) Run the resulting files through an additional stylesheet to process
> the XML file further
> 5) Zip all the resulting files together.
>
> Below is the XPROC file I have. It works properly now for step 1 and 2.
> When I add the processing for step 3 I start getting new errors. I've also
> noticed that it appears that XPROC wants the file to exist before it
> executes, so I can't pass the file that I store to the second stylesheet.
> Looks like I have to some how allow the pipeline of the XML generation just
> work and somehow fork an additional store/file create operation.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>     name="Preprocess-translations"  version="1.0"
>     >
>
>     <p:documentation>
>         This XPROC script runs all the steps required to take an Ixiasoft
> Localization kit
>         and modify the source files and organize them into a directory
> structure and zip
>         that content to be sent on for localization.
>     </p:documentation>
>
>
>
>     <p:input port="source">
>         <p:document
> href="file:/C:/Users/dan.vint/Desktop/DITAsource/fr-fr-loc-v1-source-maptesting/_mobile-dan1370798002064.ditamap"/>
>     </p:input>
>     <p:output port="result" sequence="true">
>             <!-- Write the result to "store-flat" -->
>         <p:pipe port="result" step="store-flat"/>
>         <p:pipe port="result" step="store-batchfile"/>
>     </p:output>
>
>
>
>         <!-- Process the DITAMAP file source to travel all the included
> maps and topics
>             with stylesheet to flatten the structure and gather
> information for later processing. -->
>     <p:xslt name="flatten-map">
>         <p:input port="source"/>
>         <p:input port="stylesheet">
>             <p:document
> href="file:/C:/work/svn/scripts/translations/make-translations-map.xsl"/>
>         </p:input>
>         <p:input port="parameters" sequence="true">
>             <p:empty/>
>         </p:input>
>
>     </p:xslt>
>
>     <p:store
> href="file:/C:/Users/dan.vint/Desktop/DITAsource/fr-fr-loc-v1-source-maptesting/_flatmap2.xml"
>
>         name="store-flat"
>               encoding="utf-8"
>         method="xml"
>         indent="true"
>         omit-xml-declaration="false"/>
>
>         <!-- Process the flattend map file to create a batch file the
> copies topics/maps/images into a
>              new file structure for zipping to send to translators
>            -->
>
>             <!-- XPROC seems to check for the existence of the imput file
> before the prvious step creates it -->
>     <p:xslt name="build-batfile">
>         <p:input port="source">
> <!--            <p:document
> href="file:/C:/Users/dan.vint/Desktop/DITAsource/fr-fr-loc-v1-source-maptesting/_flatmap2.xml"/>
> -->        </p:input>
>
>
>         <p:input port="stylesheet">
>             <p:document
> href="file:/C:/work/svn/scripts/translations/fileorg.xsl"/>
>         </p:input>
>         <p:input port="parameters" sequence="true">
>             <p:empty/>
>         </p:input>
>
>     </p:xslt>
>
>     <p:store
> href="file:/C:/Users/dan.vint/Desktop/DITAsource/fr-fr-loc-v1-source-maptesting/_copy-files.bat"
>
>         name="store-batchfile"
>         method="text"/>
>
>          <!-- Run Ant script to remove the oXy_delete processing
> instructions -->
>
>          <!-- Process all the topics and maps in the source folder and
> write to a new folder -->
>
>          <!-- Run the copy.bat file against processed files -->
>         <p:exec name="execute-batchfile"
> command="C:\Users\dan.vint\Desktop\DITAsource\fr-fr-loc-v1-source-maptesting\_copy-files.bat">
>         <p:input port="source">
>             <p:empty/>
>         </p:input>
>     </p:exec>
>
>     <p:sink/>
>
>
>
>          <!-- Zip the files for translation -->
>
>
>
> </p:declare-step>
>
> I'm thinking I need to switch to some other scripting language and then
> possibly call a few steps in XPROC. I started down this path because the
> people using what I build will have oXygen already installed. I was trying
> to avoid having to configure a lot of other tools to make this process
> work. So this is why I'm trying to stay in XPROC.
>
> ..dan
>
>
>
>
> At 10:44 AM 8/9/2015, Imsieke, Gerrit, le-tex wrote:
>
>> Serialization options in p:serialization refer to a port with the given
>> name. In your pipeline, there is a commented-out step that your
>> serialization settings should probably pertain to. You can add the same
>> serialization options (indent, etc.) to p:store as to p:serialization.
>> Instead of p:storing XML, you could output it on a named port with
>> individual p:serialization settings and store it to the respective files
>> in your invocation, e.g., -o flat=/path/to/flatmap2.xml
>>
>> Gerrit
>>
>> On 09.08.2015 19:35, Dan Vint wrote:
>> > thanks.
>> >
>> > The error I get in oXygen is:
>> >
>> > err:XS0039 : A p:serialization specifies a non-existant port. It is a
>> > static error if the port specified on the p:serialization is not the
>> > name of an output port on the pipeline in which it appears or if more
>> > than one p:serialization element is applied to the same port.
>> >
>> > Here is the code:
>> >
>> > <?xml version="1.0" encoding="UTF-8"?>
>> > <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>> >     name="Preprocess-translations"  version="1.0"
>> >     >
>> >
>> >     <p:documentation>
>> >         This XPROC script runs all the steps required to take an
>> > Ixiasoft Localization kit
>> >         and modify the source files and organize them into a directory
>> > structure and zip
>> >         that content to be sent on for localization.
>> >     </p:documentation>
>> >
>> >     <p:serialization
>> >         port="store-flat"
>> >         encoding="utf-8"
>> >         method="xml"
>> >         indent="true"
>> >         omit-xml-declaration="false"/>
>> >
>> >     <p:input port="source">
>> >         <p:document
>> >
>> href="file:/C:/Users/dan.vint/Desktop/DITAsource/fr-fr-loc-v1-source-maptesting/_mobile-dan1370798002064.ditamap"/>
>> >
>> >     </p:input>
>> >     <p:output port="result ">
>> >             <!-- Write the result to "store-flat" -->
>> > <!--        <p:pipe port="result" step="store-flat"></p:pipe>
>> > -->    </p:output>
>> >
>> >
>> >
>> >         <!-- Process the DITAMAP file source to travel all the included
>> > maps and topics
>> >             with stylesheet to flatten the structure and gather
>> > information for later processing. -->
>> >     <p:xslt name="flatten-map">
>> >         <p:input port="source"/>
>> >         <p:input port="stylesheet">
>> >             <p:document
>> >
>> href="file:/C:/work/svn/scripts/translations/make-translations-map.xsl"/>
>> >         </p:input>
>> >         <p:input port="parameters" sequence="true">
>> >             <p:empty/>
>> >         </p:input>
>> >
>> >     </p:xslt>
>> >
>> >  <!--   <p:store
>> >
>> href="file:/C:/Users/dan.vint/Desktop/DITAsource/fr-fr-loc-v1-source-maptesting/_flatmap2.xml"
>> > name="store-flat" /> -->
>> >
>> >
>> > </p:declare-step>
>> >
>> > Ultimately I want to write the output to a specific file. I took out the
>> > store information as I thought it might be contributing to the problem
>> >
>> >
>> >
>> >
>> > At 04:46 PM 8/7/2015, Imsieke, Gerrit, le-tex wrote:
>> >> I think it would help us help you if we saw the actual pipeline.
>> >>
>> >> On 08.08.2015 01:42, Dan Vint wrote:
>> >> > Thanks for the pointer. So I tried to make se of this based upon some
>> >> > examples I found and I'm getting a message about the port not being
>> >> > bound. I'm using the result port, but nothing seems to be making this
>> >> > work. I need to do more digging, thanks.
>> >> >
>> >> > .dan
>> >
>> >
>> ---------------------------------------------------------------------------
>> > Danny Vint
>> >
>> > Panoramic Photography
>> > http://www.dvint.com
>> >
>> > voice: 619-647-5780
>> >
>> >
>>
>> --
>> Gerrit Imsieke
>> Geschäftsführer / Managing Director
>> le-tex publishing services GmbH
>> Weissenfelser Str. 84, 04229 Leipzig, Germany
>> Phone +49 341 355356 110, Fax +49 341 355356 510
>> gerrit.imsieke@le-tex.de, http://www.le-tex.de
>>
>> Registergericht / Commercial Register: Amtsgericht Leipzig
>> Registernummer / Registration Number: HRB 24930
>>
>> Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
>> Thomas Schmidt, Dr. Reinhard Vöckler
>>
>
> ---------------------------------------------------------------------------
> Danny Vint
>
> Panoramic Photography
> http://www.dvint.com
>
> voice: 619-647-5780
>
>
>


-- 
Conal Tuohy
http://conaltuohy.com/
@conal_tuohy
Received on Tuesday, 11 August 2015 00:33:23 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:17:25 UTC