Topics

Pulling Bookmeta data into PDF footer #CSS #PDF #Oxygen

Matt Lorenzi
 

I think my original post did not get published, or got lost.

I would like to pull a metadata entry into my footer, specifically from a tag called <prognum>

I don't know if I need to create a string-set first to define this variable, then use the CSS content property to call up the value.

I have found on thread on this subject in the Oxygen forums. Found here: https://www.oxygenxml.com/forum/post54911.html#p54911
I sense I may have to make use of XPath -  which scares me. 

Is what I am asking doable?

 

Matt Lorenzi
 

Upon further reading - would I be better using a keyref for my document number and that have placed in my footer using the CSS content property?

Radu Coravu
 

Hi Matt,

I think you will need to use an xpath expression in the CSS "content" property:

https://www.oxygenxml.com/doc/ug-editor/topics/dcpp_how_to_use_in_headers_text_extracted_from_the_document__xpath.html

You first need to get your hands on the merged HTML document from which the PDF will be created:

https://www.oxygenxml.com/doc/ug-editor/topics/dcpp_debugging_the_css.html

and practice your xpath expression on it using the Oxygen XPath toolbar.
The xpath expression you may end up using might be very simple, something like:

(//prognum)[1]/text()

meaning "find any "prognum" in the document, retrieve the first one and get all the text from it.

Regards,
Radu

Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

On 2/5/2020 2:07 AM, Matt Lorenzi via Groups.Io wrote:
Upon further reading - would I be better using a keyref for my document number and that have placed in my footer using the CSS content property?

Chris Papademetrious
 

Hi Matt,

I had a similar question here:

https://www.oxygenxml.com/forum/post55680.html

with answer provided here:

https://www.oxygenxml.com/forum/post55679.html

We originally stored our book information, including release information, in <bookmeta>. However, the metadata was getting duplicated many times in the intermediate files, which made it painful to look through the HTML for adjusting CSS, etc.

We've since moved to storing our release information in a shared key definition file:

<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="urn:oasis:names:tc:dita:rng:map.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<map>
  <keydef keys="Release">
    <topicmeta>
      <keywords>
        <keyword>Q-2019.12</keyword>
      </keywords>
    </topicmeta>
  </keydef>
  <keydef keys="Date">
    <topicmeta>
      <keywords>
        <keyword>December 2019</keyword>
      </keywords>
    </topicmeta>
  </keydef>
</map>

We then mapref this from all of our books in this collection. Changing the file updates all the books.

The trick to this (provided by SyncroSoft in the second link above) is that an unreferenced key's value is not present in the HTML file to grab from the CSS. To remedy this, just add <data> bookmeta entries that reference these keys to your book:

<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="urn:oasis:names:tc:dita:rng:bookmap.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<bookmap>
  <title>Fusion Compiler™ Design-for-Test User Guide</title>
  <bookmeta>
    <data keyref="Release"/>
    <data keyref="Date"/>
  </bookmeta>
  <frontmatter>
    <mapref href="synthesis/release_vars.ditamap"/>

These are copied to the merged HTML as nonprinting metadata elements (only once!!):

<div keyref="Release" class="- topic/data data">
  <div class="- topic/keyword keyword">Q-2019.12</div>
</div>
<div keyref="Date" class="- topic/data data">
  <div class="- topic/keyword keyword">December 2019</div>
</div>

which you can then reference from your CSS:

@page {
    @bottom-left {
      content: string(maptitle) "\a" oxy_xpath('//div[contains(@class, " bookmap/bookmeta ")]/div[@keyref = "Release"]//text()');
    }
}

 - Chris

(Radu - should I contribute this as a blog post to your Git blog repo?)

Radu Coravu
 

Hi Chris,

It would be great if you could contribute topics to the Oxygen XML Blog.
Some details about how you can contribute can be found here:

https://oxygenxmlblog.netlify.com/topics/welcome.html#welcome__section_tnr_rr3_jkb

I think you can contribute only the topic with your author name and creation date specified in the prolog and we'll try to find a place for it in the DITA Map, maybe make a category called "Guest Posts".

Regards,
Radu

Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

On 2/5/2020 3:53 PM, Chris Papademetrious wrote:
Hi Matt,
I had a similar question here:
https://www.oxygenxml.com/forum/post55680.html
with answer provided here:
https://www.oxygenxml.com/forum/post55679.html
We originally stored our book information, including release information, in <bookmeta>. However, the metadata was getting duplicated many times in the intermediate files, which made it painful to look through the HTML for adjusting CSS, etc.
We've since moved to storing our release information in a *shared key definition file*:
<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="urn:oasis:names:tc:dita:rng:map.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<map>
  <keydef keys="Release">
    <topicmeta>
      <keywords>
        <keyword>Q-2019.12</keyword>
      </keywords>
    </topicmeta>
  </keydef>
  <keydef keys="Date">
    <topicmeta>
      <keywords>
        <keyword>December 2019</keyword>
      </keywords>
    </topicmeta>
  </keydef>
</map>
We then mapref this from all of our books in this collection. Changing the file updates all the books.
The trick to this (provided by SyncroSoft in the second link above) is that an *unreferenced* key's value is not present in the HTML file to grab from the CSS. To remedy this, just add <data> bookmeta entries that reference these keys to your book:
<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="urn:oasis:names:tc:dita:rng:bookmap.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<bookmap>
  <title>Fusion Compiler™ Design-for-Test User Guide</title>
<bookmeta>
    <data keyref="Release"/>
    <data keyref="Date"/>
  </bookmeta>
  <frontmatter>
<mapref href="synthesis/release_vars.ditamap"/>
These are copied to the merged HTML as nonprinting metadata elements (only once!!):
<div keyref="Release" class="- topic/data data">
  <div class="- topic/keyword keyword">Q-2019.12</div>
</div>
<div keyref="Date" class="- topic/data data">
  <div class="- topic/keyword keyword">December 2019</div>
</div>
which you can then reference from your CSS:
@page {
    @bottom-left {
      content: string(maptitle) "\a" oxy_xpath('//div[contains(@class, " bookmap/bookmeta ")]/div[@keyref = "Release"]//text()');
    }
}
 - Chris
(Radu - should I contribute this as a blog post to your Git blog repo?)