Responsive Webhelp: include bookmap xml:lang value to footer of main page
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Responsive Webhelp: include bookmap xml:lang value to footer of main page
Post by steinbacherGE »
How can I add the bookmap xml:lang value to footer of a Responsive Webhelp main page (index.html)?
I'm working in this file ..\xsl\mainFiles\customFooter.xsl
This value shows up correctly in all of my topic footers, but not the main index.html page.
<xsl:value-of select="document($windows_inputMap)/bookmap/@xml:lang"/>
Any suggestions?
Thanks,
Leroy
I'm working in this file ..\xsl\mainFiles\customFooter.xsl
This value shows up correctly in all of my topic footers, but not the main index.html page.
<xsl:value-of select="document($windows_inputMap)/bookmap/@xml:lang"/>
Any suggestions?
Thanks,
Leroy
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Hello,
You can add custom HTML content in the WebHelp Responsive output by inserting it in a well-formed XML file that will be referenced in the transformation (either from an Oxygen Publishing Template or using one of the HTML fragment parameters).
The XML file can use WebHelp macros, which are variables that will be expanded when the content of the HTML fragment file will be copied in the final output.
In your case, you can use the map-xpath macro to retrieve the value of the xml:lang attribute from the map root element.
For example the content of the XML file can look like this:
In order to include the above content in your publication footer section you should reference the path of the file using the webhelp.fragment.footer transformation parameter.
You can find more details here: https://www.oxygenxml.com/doc/versions/ ... -html.html
Regards,
Alin
You can add custom HTML content in the WebHelp Responsive output by inserting it in a well-formed XML file that will be referenced in the transformation (either from an Oxygen Publishing Template or using one of the HTML fragment parameters).
The XML file can use WebHelp macros, which are variables that will be expanded when the content of the HTML fragment file will be copied in the final output.
In your case, you can use the map-xpath macro to retrieve the value of the xml:lang attribute from the map root element.
For example the content of the XML file can look like this:
Code: Select all
<div xmlns:whc="http://www.oxygenxml.com/webhelp/components">
Publication Language: <b><whc:macro value="${map-xpath(/*/@*:lang)}"/></b>
</div>
You can find more details here: https://www.oxygenxml.com/doc/versions/ ... -html.html
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Post by steinbacherGE »
Thanks for the information. I got this to work, but if the parent map doesn't have an xml:lang attribute the defualt value (en) isn't included.
Or, if there is no xml:lang value, can the entire HTML fragment just be ignored so there is no "Publication Language:" at all?
Thanks,
Leroy
no-lang.png
Is there a way to show the default value (en) if the xml:lang attribute is empty?Or, if there is no xml:lang value, can the entire HTML fragment just be ignored so there is no "Publication Language:" at all?
Thanks,
Leroy
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Hello,
Regards,
Alin
You can use the following content in the HTML fragment file:Is there a way to show the default value (en) if the xml:lang attribute is empty?
Code: Select all
<div xmlns:whc="http://www.oxygenxml.com/webhelp/components">
Publication Language: <b><whc:macro value="${map-xpath(if (/*/@*:lang) then /*/@*:lang else 'en')}"/></b>
</div>
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Post by steinbacherGE »
This works great. Thanks!


-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Post by steinbacherGE »
Now that I have the xml:lang value in the footer I would also like to use a whc:macro to add the revision number from /bookmap/bookmeta/publisherinformation/published/revisionid. I would also like to pull in a string value for "Revision" which I already have translated for all languages. The problem is, for certain languages (hu, kk, lv), the revision number comes before the "Revision" string.
I've gotten a good start on this, but I think my code may be more complicated than it needs to be.
My other problem is the string for Revision still shows up even if the /bookmap/bookmeta/publisherinformation/published/revisionid element is empty.
Is there a way to check for a value in the revisionid element before pulling in the "Revision"string?
I'm also wondering if there is a simpler way to change the order for certain langauges? I'm not sure what all is allowed in the whc:macro syntax.
I looked into creating a wh-macro-extension, but I wonder if that is needed for this problem.
Thanks,
Leroy
I've gotten a good start on this, but I think my code may be more complicated than it needs to be.
Code: Select all
<div class="after-body" xmlns:whc="http://www.oxygenxml.com/webhelp/components">
Publication Language: <whc:macro value="${map-xpath(if (/*/@*:lang) then /*/@*:lang else 'en')}"/><br/>
<whc:macro value="${map-xpath(if ((/*/@*:lang='hu') or (/*/@*:lang='kk') or (/*/@*:lang='lv')) then /bookmap/bookmeta/publisherinformation/published/revisionid else '')}"/><whc:macro value="${i18n(Revision)}"/>
<whc:macro value="${map-xpath(if ((not(/*/@*:lang='hu' or /*/@*:lang='kk' or /*/@*:lang='lv'))) then /bookmap/bookmeta/publisherinformation/published/revisionid else '')}"/>
</div>
revisionid.png
Is there a way to check for a value in the revisionid element before pulling in the "Revision"string?
I'm also wondering if there is a simpler way to change the order for certain langauges? I'm not sure what all is allowed in the whc:macro syntax.
I looked into creating a wh-macro-extension, but I wonder if that is needed for this problem.
Thanks,
Leroy
You do not have the required permissions to view the files attached to this post.
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Post by steinbacherGE »
I figured out a way to handle this using an XSLT extension.
I defined a variable for the xsl.dita2webhelp XSLT extension.
But it didn't work for main, search and IndexTerm pages.
I found $WEBHELP_DITAMAP_URL in the map-xpath macro template (macroExpander.xsl) and used it instead for the non-topic pages.
Here is the xsl that I used to get this to work.
So what is the prefered method? Using wh:macro in a XML fragment, or writing a custom XSLT extension?
What are the limits of using conditional expressions with wh:macros? Can you provide some more examples of the proper way to use if and if(not)?
My guess is a wh:macro is easier to use for basic customization, but for more complex conditions, an XSLT extension will work better.
Can you provide some additional information on example use cases for each?
Thanks,
Leroy
I defined a variable for the xsl.dita2webhelp XSLT extension.
Code: Select all
<xsl:variable name="lang" select="/*/@*:lang"/>
I found $WEBHELP_DITAMAP_URL in the map-xpath macro template (macroExpander.xsl) and used it instead for the non-topic pages.
Code: Select all
<xsl:param name="WEBHELP_DITAMAP_URL"/>
<xsl:variable name="lang" select="document($WEBHELP_DITAMAP_URL)/*/@*:lang"/>
Code: Select all
<xsl:if test="$toc/*:topicmeta[1]/*:publisherinformation/*:published/*:revisionid[1]">
<span>
<xsl:choose>
<xsl:when test="$lang = 'hu' or $lang = 'kk' or $lang = 'lv'">
<xsl:apply-templates
select="$toc/*:topicmeta[1]/*:publisherinformation/*:published/*:revisionid[1]"
mode="footer-custom"/>
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'Revision'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'Revision'"/>
</xsl:call-template>
<xsl:apply-templates select="$toc/*:topicmeta[1]/*:publisherinformation/*:published/*:revisionid[1]" mode="footer-custom"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:text> | </xsl:text>
</xsl:if>
What are the limits of using conditional expressions with wh:macros? Can you provide some more examples of the proper way to use if and if(not)?
My guess is a wh:macro is easier to use for basic customization, but for more complex conditions, an XSLT extension will work better.
Can you provide some additional information on example use cases for each?
Thanks,
Leroy
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Responsive Webhelp: include bookmap xml:lang value to footer of main page
Hello,
The Macro Component can be used to execute a single XPath expression. There is no limit on how complex the expression is.
It was developed as an workaround for XSLT extensions in order to cover basic use cases when you needed to extract a piece of information from the source document and output it in the HTML files.
You can find several examples of Publishing Templates in this repository: https://github.com/oxygenxml/oxygen-pub ... /templates
Regards,
Alin
The Macro Component can be used to execute a single XPath expression. There is no limit on how complex the expression is.
Yes, you are right.My guess is a wh:macro is easier to use for basic customization, but for more complex conditions, an XSLT extension will work better.
It was developed as an workaround for XSLT extensions in order to cover basic use cases when you needed to extract a piece of information from the source document and output it in the HTML files.
You can find several examples of Publishing Templates in this repository: https://github.com/oxygenxml/oxygen-pub ... /templates
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
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