XSLT Transformation: Output XML with variable file name

Oxygen general issues.
patrick
Posts: 96
Joined: Mon May 09, 2011 11:54 am

XSLT Transformation: Output XML with variable file name

Post by patrick »

Hi,

I need to set an custom filename to the xml output document of my transformation. I cannot use result-document because the output xml should open after the transformation in oxygen.

So i tried the new xpath_eval variable for the xml output filename, but it is not recognized (I think there is an error somewhere...).

This expression should get a defined value from the xsl script and use a part of it as filename. The regex works in the xpath builder..

${cfd}\${cfn}-kis${xpath_eval(replace(doc('${frameworkDir}\transformations\kisupgrade.xsl')/xsl:stylesheet/xsl:param[@name='doctype.public'],'^.+V(\d+)\.(\d+).+$','$1$2'))}.xml

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

Re: XSLT Transformation: Output XML with variable file name

Post by adrian »

Hi,

I tested without ${frameworkDir} in the doc path and that worked fine for me.
Did you create this scenario within a framework (document type)?
Have you tried using '${frameworksDir}/frameworkName'?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
patrick
Posts: 96
Joined: Mon May 09, 2011 11:54 am

Re: XSLT Transformation: Output XML with variable file name

Post by patrick »

Hi Adrian,

also with '${frameworksDir}/frameworkName' it does not work.

The Scenario is defined in that framework but also in a second framework which links to the first framework theoretically using your line above with frameworksDir.

Thanks,
Patrick
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSLT Transformation: Output XML with variable file name

Post by Radu »

Hi Patrick,

What Oxygen version are you using? The xpath_eval variable was added in Oxygen 16.0.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
patrick
Posts: 96
Joined: Mon May 09, 2011 11:54 am

Re: XSLT Transformation: Output XML with variable file name

Post by patrick »

Hi Radu,

I am using the 16.0 Build 2014070913.

Best regards,
Patrick
patrick
Posts: 96
Joined: Mon May 09, 2011 11:54 am

Re: XSLT Transformation: Output XML with variable file name

Post by patrick »

OS: Win 8.1x64
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: XSLT Transformation: Output XML with variable file name

Post by adrian »

Hi,

Apologies for the late reply.
I finally got the opportunity to test this thoroughly and the problem is that the doc() XPath function needs a URL/URI as argument, but you're passing a file path (${frameworkDir}).
Note that the list of editor variables from the GUI doesn't actually include the corresponding URL editor variables (it would be misleading) because the output XML must indicate a local file path. However, even though the URL editor variables are not listed in the GUI, they are still expanded correctly: Oxygen XML Editor - Editor Variables


Anyway, to keep a long story short, for doc() you have to use ${framework} instead of ${frameworkDir} and ${frameworks} instead of ${frameworksDir} and use forward slashes (/) for the remaining path.
e.g.

Code: Select all

doc('${framework}/transformations/kisupgrade.xsl')
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
patrick
Posts: 96
Joined: Mon May 09, 2011 11:54 am

Re: XSLT Transformation: Output XML with variable file name

Post by patrick »

Thank you! It works now, here is the working string:

Code: Select all

${cfd}\${cfn}-kis${xpath_eval(replace(doc('${frameworks}&#x2f;thiemekis&#x2f;transformations&#x2f;kisupgrade.xsl')&#x2f;xsl:stylesheet&#x2f;xsl:param[@name='doctype.public'],'^.+V(\d+)\.(\d+).+$','$1$2'))}.xml
Post Reply