Can script be used to process several files?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
mlcook
Posts: 67
Joined: Thu Jan 24, 2008 4:52 pm

Can script be used to process several files?

Post by mlcook »

I have several files for which I do the same processing with Oxygen periodically.

I do:
1. Schema validation (schema aware) with Oxygen/Saxon
2. Validation with Schematron (some schemas currently have Schematron checks in them)
3. Transformation.

All of these files use the same top-level schema, same Schematron checks, and same transformation.

I currently do all of this manually via the Oxygen GUI, but it gets tedious for even 20 files.

Can one or more scripts be written to run within or externally to Oxygen to do some of this repetive processing? If so, are there any examples to begin with?

We are using Oxygen 11.2 with Saxon EE.

Thanks, Mike
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Can script be used to process several files?

Post by adrian »

Hello,

One solution for this would be to write an XProc script from scratch that performs the necessary validations and transformations. Then you could execute it either in Oxygen or separately in the command line.
A few simple examples can be found in the Oxygen samples project(xproc directory). Or look in the <installation_directory>/samples/xproc

Alternatively, in the Oxygen GUI you could split this into two steps:
- a validation scenario(Document -> Validate -> Configure Validation Scenario) that performs both validations(schema and schematron)
- a transformation scenario

You can apply each of these to multiple files if you add them to the Oxygen project. Either link the entire folders that contain them(Link to External Folders in the popup menu) or create a logical folder in the project and add the individual files there. I recommend the latter if the files are spread to various locations in the file system.

Then you can select the files or folders from the project view and associate them with the corresponding validation(Configure Validation Scenario) and transformation scenario(Configure Transformation Scenario). In each case pick a scenario and press OK.

Then you can simply execute them in the project view in two easy steps:
- validation - In the project view select the files or the directory(either linked or logical) where they are located and from the popup menu choose Validate Selection
- transformation - from the popup menu choose Apply Transformation Scenario
In both cases the associated scenarios will be used, so you only have to set them once.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
mlcook
Posts: 67
Joined: Thu Jan 24, 2008 4:52 pm

Re: Can script be used to process several files?

Post by mlcook »

Thanks, Adrian, for the start.

I've started by modifying the sample "transform.xpl" file supplied with Oxygen. I now call it "transform-to-html.xpl".

The transformation that I want to use with the XProc definition uses ${cfdu} and ${cfn} as its two parameters.

I did some searching in the Oxygen forums, but haven't found an answer yet to my following questions:

How do I specifiy those parameters in the .xpl file (if that's where they go)?

Do I need to specify anything in the XProc transformation scenario besides the defaults?

I'm getting the error message:
SystemID: ...\transformations\xproc\transform-to-html.xpl
Engine name: Calabash XProc
Severity: error
Description: A value must be supplied for parameter $cfdu because there is no default value for the required type


Thanks again,
Mike
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Can script be used to process several files?

Post by adrian »

${cfdu} and ${cfn} are Oxygen specific editor variables(macros). XProc does not interpret them. However you could pass them to the XProc script as values of parameters from the XProc transformation scenario configuration.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
mlcook
Posts: 67
Joined: Thu Jan 24, 2008 4:52 pm

Re: Can script be used to process several files?

Post by mlcook »

Adrian,

Where in the script do I define the equivalent of ${cfdu} and ${cfn}?

How do I define them?

If they need to be defined in the Xproc transformation scenario, how do I do that?

I suppose I really need a tutorial on Xproc programs and transformations. Any suggestions?

Thanks again,
Mike




Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
<!-- Bind on input the personal.xml file to be transformed with personal.xsl stylesheet -->
<p:input port="source">
<p:document href="../../trk/myfile.xml"/>
</p:input>
<!-- Declare the output port. -->
<p:output port="result"/>
<!-- Apply transformation. -->
<p:xslt>
<p:input port="source"/>
<p:input port="stylesheet">
<p:document href="../mytransformation.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
</p:input>
</p:xslt>
</p:declare-step>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Can script be used to process several files?

Post by sorin_ristache »

Hello,

${cfdu} and ${cfn} are built-in Oxygen editor variables which are available in the Oxygen transformation scenarios including the XProc scenarios. You can insert such a variable in the value of a parameter by editing the parameter value in the scenario as in the following screenshot:

Edit XProc scenario


Regards,
Sorin
Post Reply