Page 1 of 1

Accessing Parameters in XPROC Script

Posted: Sun May 09, 2021 8:00 am
by SixForty
Hello, I'm still quite new to XML in general, so I'm not even sure if I'm asking the right question! But I'm hoping someone can point me in the right direction.

I'm trying to combine multiple steps of XSL stylesheets in an XPROC script for transforming data into multiple outputs. The data is currently in various text files - each text file will go through the same XPROC script, producing multiple outputs for each one. My first step pulls in the data from the text file and runs the first XSL transformation fine. The only problem is, I can't seem to figure out a way to create the XPROC script without hardcoding in the filename of the text file. Here's what I have:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="3.0">
    <p:input port="source"/>
    <p:input port="parameters" kind="parameter"/>
    <p:output port="result"/>

    <p:xslt name="step1">
        <p:input port="source">
            <p:data href="example.txt" wrapper="wrapperElement" wrapper-namespace="http://randomnamespace.org" wrapper-prefix="rns"/>
        </p:input>
        <p:input port="stylesheet">
            <p:document href="step1.xsl"/>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:xslt>

</p:declare-step>
This works great on my 'example.txt' file, but to run it on another file, I have to actually change the 'example.txt' filename in the script. I just can't seem to figure out how to have that created dynamically. I assumed that this would be a good case for a parameter passed into the XPROC script, but I've tried reading everything I can on XPROC parameters, and the OxygenXML XPROC Transformation Scenario configuration, and I simply can't wrap my head around how to make this work.

If anyone can offer any advice at all, I'd greatly appreciate it!

Re: Accessing Parameters in XPROC Script

Posted: Wed May 12, 2021 11:39 am
by SixForty
Feel free to disregard this question. I changed up some workflow concepts, and was actually able to figure out a way to do what I needed entirely within XSL, with no need for XPROC.

Re: Accessing Parameters in XPROC Script

Posted: Wed May 12, 2021 4:27 pm
by Mircea
Hello,

Maybe you can try to use the <p:for-each> step, that lets you perform a series of steps (a subpipeline) to all of the input documents you provide to it.

Unfortunatelly we do not have enough knowledge about this in order to offer you a sollution.
I recommend you to address this question on the XSLT list: xsl-list@lists.mulberrytech.com or at the XProc list: xproc-dev@w3.org

Regards,
Mircea.

Re: Accessing Parameters in XPROC Script

Posted: Sun May 16, 2021 2:02 am
by SixForty
Thanks for the advice, Mircea. If I come across this problem again in the future, I shall give this a try.

Re: Accessing Parameters in XPROC Script

Posted: Fri May 21, 2021 2:48 pm
by crawford47
Yes, <p:for-each> step is definitelly working.