XPath to get variable using from linked key using oxy_xpath in PDF css

Questions about XML that are not covered by the other forums should go here.
Posts: 4
Joined: Thu Oct 02, 2014 7:35 pm

XPath to get variable using from linked key using oxy_xpath in PDF css

Post by bridget.rooney » Tue May 14, 2019 12:56 pm

I'm unsure if this is the right group but I'm using OxygenXML 21.0 and creating PDF using CSS.
I'm trying to use an xpath query in the CSS to extract the revision (stored in a key within a map of keys that's included in the main map).

The xpath expression I use in the CSS extracts the correct value from both the merged XML and the merged html files, in the Oxygenxml XPath/XQuery builder (see attached). But when I create the PDF it comes up blank. It should put the revision value (1.1)Image

I've looked through the online help and think I should give the xpath to the location in the merged XML rather than the more simple one in the DITA file? I'm also unsure if I have correctly used the oxy_xpath() function? Or should I look some place else for the cause?

Any help would be very much appreciated.
CSS and Merged XML below

The xpath in PDF uses the following oxy_xpath in blue :

@page:left {
content: "ROU " oxy_xpath("//*[contains(@class, 'front-page/front-page')][1]/*[contains(@class, 'map/topicmeta')][1]/*[contains(@class, 'topic/category')][1]/*[contains(@class, 'topic/keyword')][1]/text()[1]") " GE";
font-size: 10pt;
font-family: "Arial";
color: red;

(the text rendered to the PDF is ROU GE without the extracted revision value (1.1).

The merged XML that is produced is below with the value that should be extracted in blue :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/css' href='file:/C:/Program Files/Oxygen XML Editor 20.1/frameworks/dita/DITA-OT2.x/plugins/com.oxygenxml.webhelp.responsive/oxygen-webhelp/app/topic-page.css'?>
<?xml-stylesheet type='text/css' href='file:/C:/Program Files/Oxygen XML Editor 20.1/frameworks/dita/css/print/p-dita.css'?>
<?xml-stylesheet type='text/css' href='file:/C:/GitHub/techpubs/buildAutomation/publishingTemplates/css/oxygen-print.css'?>
<?xml-stylesheet type='text/css' href='file:/C:/GitHub/techpubs/buildAutomation/publishingTemplates/css/AAM_style_responsive.css'?>
<?xml-stylesheet type='text/css' href='file:/C:/GitHub/techpubs/buildAutomation/publishingTemplates/css/aam-print-ug.css'?>
<map xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
xmlns:opentopic-index="http://www.idiominc.com/opentopic/index" cascade="merge"
class="- map/map " ditaarch:DITAArchVersion="1.3"
domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d) "
xtrc="map:1;4:6" xtrf="file:/C:/GitHub/techpubs/AAM/Courier_UG.ditamap">
<oxy:front-page xmlns:oxy="http://www.oxygenxml.com/extensions/author"
class="+ front-page/front-page ">
<topicmeta xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
class="- map/topicmeta " xtrc="topicmeta:1;10:13"
<category class="- topic/category " xtrc="category:1;11:13"
xtrf="file:/C:/GitHub/techpubs/AAM/Courier_UG.ditamap">Revision <keyword
class="- topic/keyword " keyref="guide_revision" xtrc="keyword:3;11:55"
Thank you kindly for your time

Posts: 485
Joined: Mon Feb 03, 2003 10:56 am

Re: XPath to get variable using from linked key using oxy_xpath in PDF css

Post by Dan » Tue May 14, 2019 4:08 pm

Avoid using [1], it means the first item from its parent. Use (..)[1] to select the first item returned by the inner expression.

I would write the expression like:

//*[contains(@class, " front-page/front-page ")]//*[contains(@class, " topic/category ")]/*[contains(@class, "topic/keyword")]/text()

Use oXygen to debug the expressions, always start with a simple one, then add more predicates to it.

See also: https://www.oxygenxml.com/doc/versions/ ... sions.html

Post Reply