Adding separators between vrnlist attributes (CSS based PDF)

Post here questions and problems related to editing and publishing DITA content.
MariPe
Posts: 15
Joined: Wed Mar 06, 2019 4:35 pm

Adding separators between vrnlist attributes (CSS based PDF)

Post by MariPe »

I set the version number in the topicmeta of the map:

Code: Select all

<prodinfo>
            <prodname>ABC </prodname>
            <vrmlist>
                <vrm version="6" release="2"/>
            </vrmlist>
        </prodinfo>
        
I need to display vrm attributes on the cover page, separated with dots, eg. "6.3.2"
But if only two attributes are set it should be "6.3"

I got this so far but of course it always adds a dot no matter if an attribute is set or not:

Code: Select all

*[class ~= "front-page/front-page-title"]:after {
    display:block;
   content:   "Number: " oxy_xpath('(//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@version)[1]')"."  oxy_xpath('(//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@release)[1]') "."oxy_xpath('(//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@modification)[1]');

}
I don't know how to set a conditon at this point, so I could really use a hint here :)
MariPe
Posts: 15
Joined: Wed Mar 06, 2019 4:35 pm

Re: Adding separators between vrnlist attributes (CSS based PDF)

Post by MariPe »

Finally solved it. Used the merged2merged extension point to create an additional div with the version attributes as value.
julien_lacour
Posts: 495
Joined: Wed Oct 16, 2019 3:47 pm

Re: Adding separators between vrnlist attributes (CSS based PDF)

Post by julien_lacour »

Hello,

I'm glad you succeed using XSL and the extension point.
If you still want to do this only using CSS you can use the following selector:

Code: Select all

*[class ~= "front-page/front-page-title"]:after {
    display:block;
   content:   "Number: " oxy_xpath('(//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@version)[1]')
   "." oxy_xpath('(//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@release)[1]')
   oxy_xpath('if ((//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@modification)[1]) then concat(".", (//*[contains(@class, " map/topicmeta ")]/*[contains(@class, " topic/prodinfo ")]/*[contains(@class, " topic/vrmlist ")]/*[contains(@class, " topic/vrm")]/@modification)[1]) else ""');
}
For simple conditions, XPath support the 'if then else' structure.

Regards,
Julien
MariPe
Posts: 15
Joined: Wed Mar 06, 2019 4:35 pm

Re: Adding separators between vrnlist attributes (CSS based PDF)

Post by MariPe »

Great, that was exactly what I was looking for but couldnt find an example!
Thanks!
julien_lacour
Posts: 495
Joined: Wed Oct 16, 2019 3:47 pm

Re: Adding separators between vrnlist attributes (CSS based PDF)

Post by julien_lacour »

You are right, we will add an example using 'if then else' structure in oxy_xpath() functions inside our documentation.
Post Reply