Page 1 of 1

Adding separators between vrnlist attributes (CSS based PDF)

Posted: Mon Oct 19, 2020 12:23 pm
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 :)

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

Posted: Tue Oct 20, 2020 10:10 am
by MariPe
Finally solved it. Used the merged2merged extension point to create an additional div with the version attributes as value.

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

Posted: Tue Oct 20, 2020 11:10 am
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

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

Posted: Tue Oct 20, 2020 11:13 am
by MariPe
Great, that was exactly what I was looking for but couldnt find an example!
Thanks!

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

Posted: Tue Oct 20, 2020 11:49 am
by julien_lacour
You are right, we will add an example using 'if then else' structure in oxy_xpath() functions inside our documentation.