Style a document in-place

Oxygen general issues.
reinierk
Posts: 36
Joined: Tue Feb 21, 2012 8:22 pm
Location: Rotterdam, the Netherlands
Contact:

Style a document in-place

Post by reinierk »

I would like to apply a XSLT stylesheet to a document and replace it with the output.
In a transformation scenario you can save the output to a new name. But, how to write a transformation scenario for file "xxx" that renames the original file xxx.bak and then applies the transformation and save the output as "xxx" replacing the original file?
Kind Regards,
Reinier Kleipool,
Course Materials editor,
Open Source Academy
http://www.OpenSourceAcademy.eu
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Style a document in-place

Post by adrian »

Hi,

XSLT is not exactly fit for this kind of operation and Oxygen cannot help you with this. In theory, if you use Saxon, you could use Java extensions to rename files, but I can't really see a proper way to do this since the file to be renamed is involved in the transformation.

Code: Select all

    <xsl:function name="ns:renameFile" as="xs:boolean">
<xsl:param name="srcPath" as="xs:string"/>
<xsl:param name="dstPath" as="xs:string"/>
<xsl:value-of xmlns:file="java:java.io.File" select="boolean(file:renameTo(file:new($srcPath), file:new($dstPath)))"/>
</xsl:function>
A proper way to do this would be to use ANT or XProc which are more scripting oriented and allow you perform successive operations.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply