Prompt for XSLT file

Are you missing a feature? Request its implementation here.
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Prompt for XSLT file

Post by ra0543 »

Currently it is possible to choose 'Prompt for file' to determine where the output of a transformation goes. Would it possible likewise to have either an option or editor variable with the value 'prompt for file' so that one could set up a transformation scenario that prompts the user for either or both of the input XML and XSLT files?

I use the same basic settings for transformation a lot, just changing the XSLT file, and it is annoying to have to set up a whole different transformation scenario for each just to be able to make a transformation (and yes, I do use the 'Duplicate' option to speed this up). I also often don't want or need to have that scenario added to and kept in my list.

In fact, it would be really useful to have a kind of 'quick transform' wizard command that just prompts for the XML, XSLT, transformer and output without necessarily creating another scenario. If this is not possible and we continue to have to make a new scenario for every different XSLT file, as well as prompting for input files, can we at least have a structurable list of scenarios in the 'Configure transformation scenario' dialogue that we can organise into groups rather than just an amorphous list (columns showing the defined input XML, XSLT and output files would be a good addition to the list too)?
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Prompt for XSLT file

Post by adrian »

Hello,

If you have one fixed XML file that you need to transform with several XSLT files, just create one scenario for an XSLT file(Scenario type: XSLT transformation), specify the fixed XML file URL and for the XSLT file leave it ${currentFileURL}.
Add the XSLT files to the Oxygen project(in Project view from the contextual menu, either Add files or Link to External Folders) and you will be able to select several of them there and from the contextual menu choose Transform with... and select the scenario.
Does this help in any way?

I'll see what we can do about modifying the transformation scenarios capabilities. It will have to be discussed since they have just received a make over in v11.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Re: Prompt for XSLT file

Post by ra0543 »

Thanks - I didn't notice any makeover in v11, but maybe it was very subtle.

Your suggestion is interesting and might be useful in some circumstances, but it doesn't really do what I have in mind, which is to have an easy way to do one-off transformations variously on different files. It seems somewhat over the top to create a 'scenario' for these when I know I won't want to reuse them.

Perhaps the answer is to make available a separate transformation tool so that the full Oxygen program doesn't have to be opened just to be able to take some XML file and transform it according to some XSL.

(In fact, - not that this is what I want - I note that at present even though you can specify input, XSL and output in a scenario thus not needing any files open to carry it out, you still can't open the 'Configure transformation scenario' dialogue or carry out the 'Transform now' commands unless and until some file - indeed any file - is open. And that seems a pretty strange ?unintended restriction too.)
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Prompt for XSLT file

Post by adrian »

Hi,

I understand that creating a scenario seems pointless when you only want to execute a transformation once but the transformations support wasn't designed to be used on the fly. Most users have a few files that they modify and transform repeatedly so scenarios make sense for most of them. I will add this to our issue tracking tool for this.

You can actually do these transformations with Saxon 6.5 for example from the command line or the ant tool.

saxon.bat (in the Oxygen installation directory)

Code: Select all

@echo off
set OXYGEN_JAVA=java.exe
if exist "%JAVA_HOME%\bin\java.exe" set OXYGEN_JAVA="%JAVA_HOME%\bin\java.exe"
if exist "%~dp0\jre\bin\java.exe" set OXYGEN_JAVA="%~dp0\jre\bin\java.exe"
%OXYGEN_JAVA% -Xmx256m -cp "lib\saxon.jar" com.icl.saxon.StyleSheet %1 %2 %3 %4 %5 %6 %7 %8 %9
Create it and execute it in the oxygen installation dir, it will show you the required arguments.

build.xml (for ant)

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="transform" name="Transform">
<target name="transform">
<echo message="Transform ${xmlSource} with stylesheet ${stylesheet}: "/>
<java classname="com.icl.saxon.StyleSheet" fork="yes" failonerror="true" classpath="lib/saxon.jar">
<arg value="${xmlSource}"/>
<arg value="${stylesheet}"/>
<arg value="-o"/>
<arg value="${output}"/>
</java>
</target>
</project>
You can develop the script to execute what you need but ant is generally used for frequently processing large amounts of known files(no user input).

Regarding the "makeover", it consists of a Transformation Scenarios view and the possibility to choose any type of scenario(XSLT/XQuery) in the configuration dialog. Previously you were confined to the type of the current file. But it's true that for some reason it remains disabled when no file is open. I've added this to our issue tracking tool.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Re: Prompt for XSLT file

Post by ra0543 »

That's really helpful, though a GUI is a lot less hassle. Still, I am happy to live with using the command line. Is there a batch file I could create to do the same using an XSLT 2.0 transformer such as one of the various Saxon 9.2.0.3 ones? If so how?
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Prompt for XSLT file

Post by adrian »

Here's a batch for Saxon 9:

Code: Select all

@echo off
set OXYGEN_JAVA=java.exe
if exist "%JAVA_HOME%\bin\java.exe" set OXYGEN_JAVA="%JAVA_HOME%\bin\java.exe"
if exist "%~dp0\jre\bin\java.exe" set OXYGEN_JAVA="%~dp0\jre\bin\java.exe"
%OXYGEN_JAVA% -Xmx256m -cp "lib\saxon9ee.jar" net.sf.saxon.Transform %1 %2 %3 %4 %5 %6 %7 %8 %9
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply