How can I grab build paramaters to use in my xsl?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 58
- Joined: Fri Sep 12, 2008 12:12 am
How can I grab build paramaters to use in my xsl?
I would like to make a "Back" or "Return to Previous Page" link in my HTML output with dita2xhtmlImpl.xsl and I don't want to hard code it to default to index.html so I thought of somehow using the args.xhtml.toc parameter that you can set on your build to somehow feed the filename into the XSL so that I can use it to make the href point to myfilename.html with "myfilename" parsed from args.xhtml.toc.
I noticed that build_dita2xhtml.xml has a build statement with that parameter here:
What is the best way to access this parameter? And also how could I write it to use the parameter to customize the 'href' which the link points to? Currently it looks like: <a href="../index.html">Back</a>. Can you directly interpolate a variable/parameter into an href="" statement, like <a href="../{$myparam-var}.html">Back</a>?
Thanks for any suggestions.
Josh
I noticed that build_dita2xhtml.xml has a build statement with that parameter here:
Code: Select all
<target name="dita.map.xhtml.init" description="">
<condition property="out.ext" value=".html">
<not>
<isset property="out.ext" />
</not>
</condition>
<condition property="args.xhtml.toc" value="index">
<not>
<isset property="args.xhtml.toc" />
</not>
</condition>
</target>
Thanks for any suggestions.
Josh
-
- Posts: 9469
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How can I grab build paramaters to use in my xsl?
Hi Josh,
So there are two steps to accomplish what you want.
1) Specify in the Oxygen DITA scenario the value for the "args.xhtml.toc" parameter which is already defined in the build.xml.
2) Take this parameter's value from the build.xml and then pass it as a value for a parameter defined in the XSL stylesheet.
So in the dita2xhtmlImpl.xsl you will declare an xsl:param as follows:
That parameter will be used as a normal xslt variable in the XSL file.
To pass the value for the parameter from the ANT build.xml you have to find the place in the build file where the transformer is invoked for the stylesheet.
It should be something like:
Just pass the value of the ANT parameter to the XSLT parameter adding a new parameter like:
Hope this helps,
Regards,
Radu
So there are two steps to accomplish what you want.
1) Specify in the Oxygen DITA scenario the value for the "args.xhtml.toc" parameter which is already defined in the build.xml.
2) Take this parameter's value from the build.xml and then pass it as a value for a parameter defined in the XSL stylesheet.
So in the dita2xhtmlImpl.xsl you will declare an xsl:param as follows:
Code: Select all
<xsl:param name="args.xhtml.toc"/>
To pass the value for the parameter from the ANT build.xml you have to find the place in the build file where the transformer is invoked for the stylesheet.
It should be something like:
Code: Select all
<xslt processor="trax"
basedir="${dita.temp.dir}"
destdir="${output.dir}"
includes="${user.input.file}"
classpathref="dost.class.path"
style="${dita.script.dir}${file.separator}map2xhtmtoc.xsl">
<param name="DITAEXT" expression="${dita.ext}" if="dita.ext" />
<param name="OUTEXT" expression="${out.ext}" if="out.ext" />
<mapper type="glob"
from="*${dita.input.filename}"
to="*${args.xhtml.toc}${out.ext}" />
</xslt>
Code: Select all
<param name="args.xhtml.toc" expression="${args.xhtml.toc}" if="args.xhtml.toc" />
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 58
- Joined: Fri Sep 12, 2008 12:12 am
Re: How can I grab build paramaters to use in my xsl?
Wonderful, that works great. For future reference for anyone who wants to set a parameter in dita2htmlImpl.xsl the "Invocation Path" as I'll call it, starting with build.xml, is build.xml->build_xhtml.xml->build_general.xml->dita2xhtml.xsl->dita2htmlImpl.xsl, so build_general.xml is the "last" xml in the path and it is in there that the parameters should be passed under the dita.inner.topics.xhtml target which calls dita2xhtml.xsl which in turn calls dita2htmlImpl.xsl along with the other xsl transforms for XHTML output.
Thanks again Radu!
Josh
Thanks again Radu!
Josh
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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