How to use XSLT variables in my customized webhelp

Post here questions and problems related to editing and publishing DITA content.
maglid
Posts: 74
Joined: Mon Sep 28, 2009 8:10 am

How to use XSLT variables in my customized webhelp

Post by maglid »

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
maglid
Posts: 74
Joined: Mon Sep 28, 2009 8:10 am

Re: How to use XSLT variables in my customized webhelp

Post by maglid »

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
alin
Site Admin
Posts: 217
Joined: Thu Dec 24, 2009 11:21 am

Re: How to use XSLT variables in my customized webhelp

Post by alin »

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: Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
maglid
Posts: 74
Joined: Mon Sep 28, 2009 8:10 am

Re: How to use XSLT variables in my customized webhelp

Post by maglid »

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:

Code: Select all

<!-- Normal Webhelp transformation, filtered. -->
    <xsl:template match="/">
        <xsl:variable name="template_base_uri" select="base-uri()"/>
        [...]
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:

Code: Select all

<feature extension="dita.conductor.html5.param" value="insertParameters.xml" type="file"/>
My integrator file:

Code: Select all

<dirname property="args.input.dir" file="${args.input}"/>
My insertParameters.xml file:

Code: Select all

<dummy>
    <param name="input.dir.url" expression="${args.input.dir}"/>
</dummy>
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?
maglid
Posts: 74
Joined: Mon Sep 28, 2009 8:10 am

Re: How to use XSLT variables in my customized webhelp

Post by maglid »

Update, I found the webhelp XSLT variable I need, it is $DITAMAP_URL. This gives me the location of the source ditamap in my custom override XSLT.
maglid
Posts: 74
Joined: Mon Sep 28, 2009 8:10 am

Re: How to use XSLT variables in my customized webhelp

Post by maglid »

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:

Code: Select all

dita-ot/plugins/com.oxygenxml.webhelp.responsive/xsl/dita2webhelp/dita2webhelpImpl.xsl
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
radu_pisoi
Posts: 391
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,
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.
Please note that relative paths for doc() function are resolved relative to the static base URI.

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
maglid
Posts: 74
Joined: Mon Sep 28, 2009 8:10 am

Re: How to use XSLT variables in my customized webhelp

Post by maglid »

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:

Code: Select all

xpath-default-namespace="http://www.w3.org/1999/xhtml"
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:

Code: Select all

<xsl:value-of  xpath-default-namespace="" select="$testxml//ishfield[@name='FTITLE']" />
It's this attribute with the value of "" that sets it to the null namespace and fixes the problem:

Code: Select all

xpath-default-namespace=""
Thanks,
Mark
Post Reply