Ways to store CSS-accessible book metadata besides <bookmeta>?
Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Ways to store CSS-accessible book metadata besides <bookmeta>?
Post by chrispitude »
We store metadata about our book in a <bookmeta> element in the top-level bookmap file, like this:
Then I reference this metadata in our PDF Chemistry CSS via oxy_xpath() to populate the cover page and headers/footers, like this:
and this works exactly as expected.
But in the merged XML file created by PDF Chemistry, the book metadata is propagated (duplicated!) in every single topic in the book. This metadata cascade is described as a requirement in the DITA spec (https://docs.oasis-open.org/dita/v1.2/o ... tamap.html), but it contributes to a significant size increase in the merged XML file:
book_without_meta.xml: 4,794,623 bytes
book_with_meta.xml: 5,285,917 bytes
Half a megabyte of text overhead to store a handful of text strings is too much for my comfort, even for a temporary file.
I tried defining some key values in the top-level bookmap:
but they don't get replicated in the merged XML file for me to access via oxy_xpath().
Is there another way to store and maintain book information that can be accessed from CSS? Or is there a way to disable this book metadata propagation in a transform?
Thanks!
- Chris
Code: Select all
<bookmap>
<title>Our Product User Guide</title>
<bookmeta>
<author>chrispy</author>
<publisherinformation>
<organization>My Company, Inc.</organization>
<printlocation>Mountain View, CA</printlocation>
<published>
<publishtype value="general"/>
<completed>
<year>2019</year>
<month>June</month>
</completed>
</published>
</publisherinformation>
<prodinfo>
<prodname>My Product</prodname>
</prodinfo>
<bookid>
<edition>My Version</edition>
</bookid>
</bookmeta>
Code: Select all
*[class~="front-page/front-page-title"]::after(2) {
content: "Version " oxy_xpath('//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/edition ")]/text()') ", "
oxy_xpath('//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/completed ")]/div[contains(@class, " bookmap/month ")]/text()') " "
oxy_xpath('//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/completed ")]/div[contains(@class, " bookmap/year ")]/text()');
}
@page {
@bottom-left {
content: string(maptitle) "\a" oxy_xpath('//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/edition ")]/text()');
}
}
But in the merged XML file created by PDF Chemistry, the book metadata is propagated (duplicated!) in every single topic in the book. This metadata cascade is described as a requirement in the DITA spec (https://docs.oasis-open.org/dita/v1.2/o ... tamap.html), but it contributes to a significant size increase in the merged XML file:
book_without_meta.xml: 4,794,623 bytes
book_with_meta.xml: 5,285,917 bytes
Half a megabyte of text overhead to store a handful of text strings is too much for my comfort, even for a temporary file.
I tried defining some key values in the top-level bookmap:
Code: Select all
<keydef keys="version">
<topicmeta>
<keywords>
<keyword>P-2019.03-SP2</keyword>
</keywords>
</topicmeta>
</keydef>
<keydef keys="date">
<topicmeta>
<keywords>
<keyword>June 2019</keyword>
</keywords>
</topicmeta>
</keydef>
Is there another way to store and maintain book information that can be accessed from CSS? Or is there a way to disable this book metadata propagation in a transform?
Thanks!
- Chris
-
- Posts: 846
- Joined: Mon Dec 05, 2011 6:04 pm
Re: Ways to store CSS-accessible book metadata besides <bookmeta>?
Hi Chris,
There are two solutions for that:
- either select only the 1st instance of the content returned by the XPath, encapsulating each of your path expressions in parentheses (), followed by [1], like:
- or use a more specific path. For example, you should try collecting all "div" elements only from inside the div in the frontpage.
You could do that by adding somthing like: at the very beginning of your path expression.
I hope this helps.
Regards,
Costin
There are two solutions for that:
- either select only the 1st instance of the content returned by the XPath, encapsulating each of your path expressions in parentheses (), followed by [1], like:
Code: Select all
*[class~="front-page/front-page-title"]::after(2) {
content: "Version " oxy_xpath('(//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/edition ")]/text())[1]') ", "
oxy_xpath('(//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/completed ")]/div[contains(@class, " bookmap/month ")]/text())[1]') " "
oxy_xpath('(//div[contains(@class, " bookmap/bookmeta ")]//div[contains(@class, " bookmap/completed ")]/div[contains(@class, " bookmap/year ")]/text())[1]');
}
You could do that by adding somthing like:
Code: Select all
div[contains(@class, " front-page/front-page")]
I hope this helps.
Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support
oXygen XML Editor and Author Support
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Ways to store CSS-accessible book metadata besides <bookmeta>?
Post by chrispitude »
Thanks Costin! Yes, I've used a similar solution in my own CSS.
I would really like to eliminate the duplicated metadata itself. Is there a way to (1) prevent the DITA-OT from such excessive duplication, or (2) is there another way besides the <bookmeta> construct to communicate data from DITA source files to the CSS files?
Maybe I could put the book information into a nonprinting DITA topic and access that...
I would really like to eliminate the duplicated metadata itself. Is there a way to (1) prevent the DITA-OT from such excessive duplication, or (2) is there another way besides the <bookmeta> construct to communicate data from DITA source files to the CSS files?
Maybe I could put the book information into a nonprinting DITA topic and access that...
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Ways to store CSS-accessible book metadata besides <bookmeta>?
Please read here:
post55679.html#p55679
The idea is to add to the metadata section of the bookmap data elements that expand the needed keys. We are not pushing all the defined keys in the merged map because there are cases of large key pools (thousands).
post55679.html#p55679
The idea is to add to the metadata section of the bookmap data elements that expand the needed keys. We are not pushing all the defined keys in the merged map because there are cases of large key pools (thousands).
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service