Page 1 of 1

Check condition in topic-xpath macro

Posted: Tue Feb 26, 2019 3:53 pm
by Stephan2
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:

Code: Select all

<whc:macro value="${topic-xpath(string-join(('Note: The feature described above is available from release' , //attribute::product), ' '))}"/>
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

Re: Check condition in topic-xpath macro

Posted: Fri Mar 01, 2019 3:52 pm
by alin
Hello,

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 '')}"/>
Regards,
Alin

Re: Check condition in topic-xpath macro

Posted: Fri Mar 01, 2019 5:01 pm
by Stephan2
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:

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>
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:

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>
Is there a way to both use the custom html-page-layout-files and the html-fragments?

Thanks and best regards
Stephan

Re: Check condition in topic-xpath macro

Posted: Mon Mar 04, 2019 5:35 pm
by alin
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:
  • 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.
For the full list of HTML fragment parameters please see: https://www.oxygenxml.com/doc/versions/ ... aid-title6

Regards,
Alin

Re: Check condition in topic-xpath macro

Posted: Tue Mar 05, 2019 6:09 pm
by Stephan2
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