Custom Output File Name in XSLT Transformation Scenarios
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 45
- Joined: Mon Aug 24, 2009 11:42 pm
Custom Output File Name in XSLT Transformation Scenarios
There must be a way to do this, but after spending almost an hour reviewing the docs and this forum, I cannot find it.
I would like to define the output file name in an XSLT Transformation Scenario using content from within the XML document currently being transformed. I've carefully reviewed all of the Editor Variables available, but they all seem to reference information external to the XML document, mostly file paths and file system information. I've also looked at Custom Editor variables, but insofar as I can tell this functionality only allows the definition of static values. There are ways to reference environment and Java system variables, but, again, these are all external to the file being transformed.
Ideally, I would like to access a processing instruction or provide an XPath to an element within the file that I could use to construct the output file name.
Is this sort of thing possible?
Thank you in advance.
I would like to define the output file name in an XSLT Transformation Scenario using content from within the XML document currently being transformed. I've carefully reviewed all of the Editor Variables available, but they all seem to reference information external to the XML document, mostly file paths and file system information. I've also looked at Custom Editor variables, but insofar as I can tell this functionality only allows the definition of static values. There are ways to reference environment and Java system variables, but, again, these are all external to the file being transformed.
Ideally, I would like to access a processing instruction or provide an XPath to an element within the file that I could use to construct the output file name.
Is this sort of thing possible?
Thank you in advance.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Custom Output File Name in XSLT Transformation Scenarios
Hello,
I'm afraid that's not possible, at least not for the main output file specified in the transformation scenario. The output is specified for the transformer/engine at the moment the transformation starts, so you can't make it dynamic depending on the content.
However, assuming you're using XSLT 2.0, why not use xsl:result-document in your stylesheet?
e.g. This xsl:result-document block will output to a file named: fileN.xml where N is has the value of the XPath expression element/id.
Regards,
Adrian
I'm afraid that's not possible, at least not for the main output file specified in the transformation scenario. The output is specified for the transformer/engine at the moment the transformation starts, so you can't make it dynamic depending on the content.
However, assuming you're using XSLT 2.0, why not use xsl:result-document in your stylesheet?
e.g.
Code: Select all
<xsl:result-document href="file{element/id}.xml">
...
</xsl:result-document>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 28
- Joined: Thu Mar 12, 2009 4:16 am
Re: Custom Output File Name in XSLT Transformation Scenarios
Post by Rumplestiltzkin »
Just wondering if anything has changed in this respect in the last 5 years? I would _really_ like to be able to have output file names from an XSL transformation that vary according to content. There are reasons why I can't really use xsl:result-document, so if the output naming functionality in XSLT Transformation Scenarios has improved, I'd love to find out about it.
-
- Posts: 28
- Joined: Thu Mar 12, 2009 4:16 am
Re: Custom Output File Name in XSLT Transformation Scenarios
Post by Rumplestiltzkin »
Whoops! Sorry; I misread the user join time as the message posting time.
It's not been 5 years; only 1 or so, so the answer, I'm sure is "no."

-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Custom Output File Name in XSLT Transformation Scenarios
Hi,
Starting with v16.0 there is a new editor variable that can be used to evaluate an XPath directly in the Output/Save As field:
So, you can use an XPath expression to contribute to the output file path and name.
e.g.
However, in Windows, due to a bug (present in v16.0 builds, up to 2014052022), you must escape the forward slash characters '/', to avoid the Windows path correction (replaces '/' with'\' and breaks the XPath expression).
So, for the example above, in order to work in Windows, the expression must look like this (replaced '/' with '/'):
Regards,
Adrian
Starting with v16.0 there is a new editor variable that can be used to evaluate an XPath directly in the Output/Save As field:
Code: Select all
${xpath_eval(expression)}
e.g.
Code: Select all
${cfd}/${xpath_eval(doc('personal.xml')/personnel[1]/person[1]/@id)}.xml
So, for the example above, in order to work in Windows, the expression must look like this (replaced '/' with '/'):
Code: Select all
${cfd}\${xpath_eval(doc('personal.xml')/personnel[1]/person[1]/@id)}.xml
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 28
- Joined: Thu Mar 12, 2009 4:16 am
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service