How to use XSLT variables in my customized webhelp
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 75
- Joined: Mon Sep 28, 2009 8:10 am
How to use XSLT variables in my customized webhelp
I need to use some DITA OT XSLT variables in my webhelp output. Things like the title of the ditamap, some Tridion Docs metadata like Date Last Modified, etc. I want to add these values to the webhelp topics. How can I access them? I have not yet found a webhelp parameter for this.
Thanks,
Mark
Thanks,
Mark
-
- Posts: 75
- Joined: Mon Sep 28, 2009 8:10 am
Re: How to use XSLT variables in my customized webhelp
I'm assuming it's the usual: Find the existing XSLT variables or add ones of my own, and then find the proper XSLT to use them in.
I was just trying to find out if, somewhere in webhelp's many many variables, there was some way to pass a variable into a webehlp config file, for example.
Mark
I was just trying to find out if, somewhere in webhelp's many many variables, there was some way to pass a variable into a webehlp config file, for example.
Mark
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: How to use XSLT variables in my customized webhelp
Hello,
The Oxygen WebHelp Responsive output can be customized using XSLT Extension files. There are several XSLT-Import Extension points available. For each extension point you can access the global variables that are available in the XSLT context where the extension file is loaded.
The available XSLT-Import Extension points and their associated XSLT files are listed in our User Manual: XSLT-Import Extension Points.
You can also customize the WebHelp output by inserting additional content using custom HTML Fragment files. Using this technique you can insert dynamic content in your output HTML pages with the help of WebHelp Macros, which are variables that will be expanded when the content of the HTML fragment file will be copied in the final output.
We have a repository of custom Publishing Templates that cover different customization topics: https://github.com/oxygenxml/oxygen-pub ... /templates
Maybe the following templates would help you:
Alin
The Oxygen WebHelp Responsive output can be customized using XSLT Extension files. There are several XSLT-Import Extension points available. For each extension point you can access the global variables that are available in the XSLT context where the extension file is loaded.
The available XSLT-Import Extension points and their associated XSLT files are listed in our User Manual: XSLT-Import Extension Points.
You can also customize the WebHelp output by inserting additional content using custom HTML Fragment files. Using this technique you can insert dynamic content in your output HTML pages with the help of WebHelp Macros, which are variables that will be expanded when the content of the HTML fragment file will be copied in the final output.
We have a repository of custom Publishing Templates that cover different customization topics: https://github.com/oxygenxml/oxygen-pub ... /templates
Maybe the following templates would help you:
- Last modified date & time after the topic content - https://github.com/oxygenxml/oxygen-pub ... in-content
- Insert Topic Meta in HTML <body> - https://github.com/oxygenxml/oxygen-pub ... ta-in-body
- Map Title in Breadcrumb - https://github.com/oxygenxml/oxygen-pub ... breadcrumb
- Process Cutom Metadata (<othermeta>) in Topic Content - https://github.com/oxygenxml/oxygen-pub ... a-in-topic
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 75
- Joined: Mon Sep 28, 2009 8:10 am
Re: How to use XSLT variables in my customized webhelp
Thanks for the info Alin, it helps. I can do some of the things I want to do, but I am finding that the normal DITA OT variables that are usually available in the XSLT are not available in some of the webhelp XSLT. For example, I am overriding this webhelp template from com.oxygenxml.webhelp.responsive/xsl/dita2webhelp/dita2webhelpImpl.xsl:
My code needs to know the input directory where the input ditamap is, but when I add this variable to my plugin, it is not available in the webhelp XSLT. I added this to my plugin.xml:
My integrator file:
My insertParameters.xml file:
Normally this setup would make the variable $input.dir.url available in XLST, but it does not work.
How can I do this? I can eventually figure out what webhelp is doing, but is there an easier way?
Code: Select all
<!-- Normal Webhelp transformation, filtered. -->
<xsl:template match="/">
<xsl:variable name="template_base_uri" select="base-uri()"/>
[...]
Code: Select all
<feature extension="dita.conductor.html5.param" value="insertParameters.xml" type="file"/>
Code: Select all
<dirname property="args.input.dir" file="${args.input}"/>
Code: Select all
<dummy>
<param name="input.dir.url" expression="${args.input.dir}"/>
</dummy>
How can I do this? I can eventually figure out what webhelp is doing, but is there an easier way?
-
- Posts: 75
- Joined: Mon Sep 28, 2009 8:10 am
Re: How to use XSLT variables in my customized webhelp
Update -- I can now get to the XML metadata file I need to open, using XSLT. But I've tried doc(filename) and document(filename) and it will not let me read into the metadata file, which definitely is there. doc-avalaible() returns false. I'm doing this inside a webhelp template I am overriding. It's this XSLT file:
But if I access this same metadata file with XSLT outside the Oxygen webhelp plugin, it works fine, I can read data out of it. Is there some kind of process lock when webhelp runs that would cause XSLT file reading to fail?
Do you think I should just post-process these HTML files to add the metadata I need, instead of trying to hack the Oxygen webhelp XSLT?
Thanks
Code: Select all
dita-ot/plugins/com.oxygenxml.webhelp.responsive/xsl/dita2webhelp/dita2webhelpImpl.xsl
Do you think I should just post-process these HTML files to add the metadata I need, instead of trying to hack the Oxygen webhelp XSLT?
Thanks
-
- Posts: 404
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: How to use XSLT variables in my customized webhelp
Post by radu_pisoi »
Hi,
See more details in the following links:
https://www.saxonica.com/html/documenta ... n/doc.html
https://www.w3.org/TR/xpath-functions-31/#func-doc
Please note that relative paths for doc() function are resolved relative to the static base URI.But I've tried doc(filename) and document(filename) and it will not let me read into the metadata file, which definitely is there. doc-avalaible() returns false.
See more details in the following links:
https://www.saxonica.com/html/documenta ... n/doc.html
https://www.w3.org/TR/xpath-functions-31/#func-doc
Radu Pisoi
<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: 75
- Joined: Mon Sep 28, 2009 8:10 am
Re: How to use XSLT variables in my customized webhelp
I fixed the problem. It was a namespace mismatch. The XSLT file from the webehlp code that I am overriding, which seems to be merging XHTML files, has this attribute on it:
That means that the stylesheet expects everything to be in the XHTML namespace. My external file has no namespace (it's in the "null namespace") but XPath is looking for the XHTML namespace, so it finds nothing. So I put my <xsl:value-of> (or other instruction) in the null namespace, and then XPath can read into the external XML file:
It's this attribute with the value of "" that sets it to the null namespace and fixes the problem:
Thanks,
Mark
Code: Select all
xpath-default-namespace="http://www.w3.org/1999/xhtml"
Code: Select all
<xsl:value-of xpath-default-namespace="" select="$testxml//ishfield[@name='FTITLE']" />
Code: Select all
xpath-default-namespace=""
Mark
Return to “DITA (Editing and Publishing DITA Content)”
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