Check condition in topic-xpath macro
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 5
- Joined: Wed Jan 23, 2019 4:11 pm
Check condition in topic-xpath macro
Dear Oxygen-Team,
I'm currently using the macro "topic-xpath" in my Webhelp-Project in order to insert the value of the topic-attribute "product" in the HTML-Content.
The expression is as follows:
So far, this works fine and the static string + the attribute value are inserted in the HTML-Content.
The problem is, that the attribute "product" isn't always filled with a value. In the case that the value of the attribute is empty, I don't want to insert the above string in the HTML-Content. I've tried to use an if-statement within the macro, but this failed. Is there a way to achieve the conditional output with the "topic-xpath" macro?
Thank you and best regards,
Stephan
I'm currently using the macro "topic-xpath" in my Webhelp-Project in order to insert the value of the topic-attribute "product" in the HTML-Content.
The expression is as follows:
Code: Select all
<whc:macro value="${topic-xpath(string-join(('Note: The feature described above is available from release' , //attribute::product), ' '))}"/>
The problem is, that the attribute "product" isn't always filled with a value. In the case that the value of the attribute is empty, I don't want to insert the above string in the HTML-Content. I've tried to use an if-statement within the macro, but this failed. Is there a way to achieve the conditional output with the "topic-xpath" macro?
Thank you and best regards,
Stephan
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Check condition in topic-xpath macro
Hello,
Can you please try to use the following fragment:
Regards,
Alin
Can you please try to use the following fragment:
Code: Select all
<whc:macro value="${topic-xpath(if (normalize-space(string-join((//attribute::product), '')) != '') then string-join(('Note: The feature described above is available from release' , //attribute::product), ' ') else '')}"/>
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Wed Jan 23, 2019 4:11 pm
Re: Check condition in topic-xpath macro
Hi Alin,
it works, which is pretty cool! Thank you very much!
Unfortunately, I have another problem:
As I learned from your user guide, the topic-xpath macro is available only in the topic HTML page template (wt_topic.html). And it requires, that I use and specify a custom wt_topic.html in my custom publishing template. I specified the HTML page templates in my publishing template as follows:
When I run the WebHelp transformation now, my custom header and footer xhtml files don't work any more. In the output, the following is displayed:
header.xml
footer.xml
In my publishing template, I specified the header and footer as follows:
Is there a way to both use the custom html-page-layout-files and the html-fragments?
Thanks and best regards
Stephan
it works, which is pretty cool! Thank you very much!
Unfortunately, I have another problem:
As I learned from your user guide, the topic-xpath macro is available only in the topic HTML page template (wt_topic.html). And it requires, that I use and specify a custom wt_topic.html in my custom publishing template. I specified the HTML page templates in my publishing template as follows:
Code: Select all
<html-page-layout-files>
<page-layout-file page="topic" file="resources/page-templates/wt_topic.html"/>
<page-layout-file page="main" file="resources/page-templates/wt_index.html"/>
<page-layout-file page="search" file="resources/page-templates/wt_search.html"/>
<page-layout-file page="index-terms" file="resources/page-templates/wt_terms.html"/>
</html-page-layout-files>
header.xml
footer.xml
In my publishing template, I specified the header and footer as follows:
Code: Select all
<html-fragments>
<fragment file="resources/footer/my_footer.xhtml" placeholder="webhelp.fragment.footer"/>
<fragment file="resources/header/my_header.xhtml" placeholder="webhelp.fragment.head"/>
</html-fragments>
Thanks and best regards
Stephan
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Check condition in topic-xpath macro
Hello,
Did you manually copy the HTML Page Layout Files (HTML page templates) in your custom template? If yes, I suppose that you have omitted two additional files that are referenced from the page layout files. These are header.xml and footer.xml and they are not optional.
Can you please check that the resources/page-templates directory from your custom template contains these two files?
If not, please copy them from the same directory you have copied the 4 HTML Page Layout files (i.e.: {DITA-OT_DIR}/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/).
Also, please note that the webhelp.fragment.head parameter you have used to reference your custom page header is expanded within the HTML <head> element.
[A.] If you want to entirely override the default header you should reference your header fragment using the webhelp.fragment.header parameter.
Note that the default header includes the Publication Title, the Top Menu and the Index Terms link and overriding it would result in removing these components from your HTML pages.
The default value for the webhelp.fragment.header parameter is header.xml. By changing its value you don't need to copy the header.xml file to your custom template.
[B.] If you just want to add some custom content in the header section of your HTML pages you can use one of the following parameters:
Regards,
Alin
Did you manually copy the HTML Page Layout Files (HTML page templates) in your custom template? If yes, I suppose that you have omitted two additional files that are referenced from the page layout files. These are header.xml and footer.xml and they are not optional.
Can you please check that the resources/page-templates directory from your custom template contains these two files?
If not, please copy them from the same directory you have copied the 4 HTML Page Layout files (i.e.: {DITA-OT_DIR}/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/page-templates/).
Also, please note that the webhelp.fragment.head parameter you have used to reference your custom page header is expanded within the HTML <head> element.
[A.] If you want to entirely override the default header you should reference your header fragment using the webhelp.fragment.header parameter.
Note that the default header includes the Publication Title, the Top Menu and the Index Terms link and overriding it would result in removing these components from your HTML pages.
The default value for the webhelp.fragment.header parameter is header.xml. By changing its value you don't need to copy the header.xml file to your custom template.
[B.] If you just want to add some custom content in the header section of your HTML pages you can use one of the following parameters:
- webhelp.fragment.before.body
In the generated output it displays a given XHTML fragment before the page body. The value of the parameter can be either an XHTML fragment or a path to a file that contains a well-formed XHTML fragment. - webhelp.fragment.before.logo_and_title
In the generated output it displays a given XHTML fragment before the logo and title. The value of the parameter can be either an XHTML fragment or a path to a file that contains a well-formed XHTML fragment. - webhelp.fragment.after.logo_and_title
In the generated output it displays a given XHTML fragment after the logo and title. The value of the parameter can be either an XHTML fragment or a path to a file that contains a well-formed XHTML fragment. - webhelp.fragment.before.top_menu
In the generated output it displays a given XHTML fragment before the top menu. The value of the parameter can be either an XHTML fragment or a path to a file that contains a well-formed XHTML fragment. - webhelp.fragment.after.top_menu
In the generated output it displays a given XHTML fragment after the top menu. The value of the parameter can be either an XHTML fragment or a path to a file that contains a well-formed XHTML fragment.
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Wed Jan 23, 2019 4:11 pm
Re: Check condition in topic-xpath macro
Hello Alin,
I've copied the header.xml and footer.xml in the same directory as the 4 HTML Page Layout files and now it works.
Thank you very much for your help!
Best regards,
Stephan
I've copied the header.xml and footer.xml in the same directory as the 4 HTML Page Layout files and now it works.
Thank you very much for your help!
Best regards,
Stephan
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