Using a <bookmap>

201 views
Skip to first unread message

mrob

unread,
Jul 22, 2016, 7:36:54 PM7/22/16
to DITA-OT Users
I've set up a <bookmap> to include a bunch of information, and I have learned how to output this in the frontmatter.

Question: is there a way to also reference the <bookmap> metadata from within my dita files? I.e., within <p>, etc.?

I gather that I need to use an ENTITY declaration and then reference the entity (e.g., &bookNumber;), but I'm not clear on what the declaration should look like.

Any ideas?

Thanks,

mrob

Jarno Elovirta

unread,
Jul 23, 2016, 2:21:02 AM7/23/16
to mrob, DITA-OT Users
ENTITY is not the way to go with XML DITA, instead just use keys and reference thise in both map metadata and topics. Not as simple as you'd want, but still single source.

J

--
Sent from a mobile device.
--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mrob

unread,
Jul 23, 2016, 5:10:26 AM7/23/16
to DITA-OT Users, mrober...@gmail.com
I'm not clear on how to do what you suggest.

Let's say my <bookmap> contains these elements:

<prodinfo><prodname>MyProduct</prodname>
<vrmlist><vrm version = "11.0"/></vrmlist></prodinfo>

How do I use keys to insert "MyProduct" and "11.0" into a dita file inside this bookmap?

Jarno Elovirta

unread,
Jul 23, 2016, 6:51:41 AM7/23/16
to mrob, DITA-OT Users
For version you're out of luck, DITA doesn't allow keys in attribute values. For prodname you can use a nested keyword element with key reference.

J

--
Sent from a mobile device.

mrob

unread,
Jul 23, 2016, 8:16:24 AM7/23/16
to DITA-OT Users, mrober...@gmail.com
Sorry to ask again, but could you suggest some actual XML that works for this?

I have been trying different things for hours are there are so many restrictions on which tags can contain which others, etc. that I'm getting nothing but errors from DITA-OT.

Thanks,

mrob

mrob

unread,
Jul 23, 2016, 8:46:26 AM7/23/16
to DITA-OT Users, mrober...@gmail.com
My last message might seem a bit vague. To be more precise, I have tried adding the keys attribute to bookmap, bookmeta, prodinfo, and prodname, but I always get an error like this:

Attribute "keys" must be declared for element type "prodname".

I have tried adding a keydef element enclosing the bookmap, or bookmeta, or prodname, or prodinfo elements, but I always get an error like this:

The content of element type "keydef" must match "(topicmeta?,(anchor|data|data-about|navref|topicref|anchorref|keydef|mapref|topicgroup|topichead|topicset|topicsetref)*)".

I'm probably doing something wrong, but keys are not working for me here.

Stefan Eike

unread,
Jul 23, 2016, 9:20:34 AM7/23/16
to DITA-OT Users, mrober...@gmail.com
I think Jarno means something like that:

my.bookmap

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd">
<bookmap>
    <booktitle>
        <mainbooktitle>Main book title</mainbooktitle>
    </booktitle>
    <bookmeta>
        <publisherinformation>
            <person>
                <keyword conkeyref="my/foo"/>
            </person>
        </publisherinformation>
    </bookmeta>
    <frontmatter>
        <topicref href="my.dita" toc="no" keys="my" processing-role="resource-only"/>
    </frontmatter>
</bookmap>


my.dita

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic_ctx_wsk_sw">
  <title>Topic</title>
  <body>
    <p><keyword id="foo">bar</keyword></p>
  </body>
</topic>

mrob

unread,
Jul 24, 2016, 1:11:25 AM7/24/16
to DITA-OT Users, mrober...@gmail.com
Stefan, Jarno,

Wow, that works -- thanks!

But now, what can I do about <vrm version= "11.0"/> ?

Is there some way I can also define the version number in the my.dita file, and then use that to set the @version attribute of <vrm> in the bookmap?


mrob

unread,
Jul 24, 2016, 11:31:51 PM7/24/16
to DITA-OT Users, mrober...@gmail.com
I'm still looking at this, not finding an answer.

If <vrm> used child elements to represent version and release, I could use conkeyref. But, it uses attributes.

Is there really no way to use this attribute in my dita documents? E.g., I want the output to be something like "In version 11.0 of the BlahBlah component, ...".

Of course, I could add <p><keyword id="product_version">11.0</keyword></p> to my.dita and reference that with a keyword conkeyref element in my document files, but that would mean the vrm element is quasi-useless.

What about other ways to do this?

For example, I could create a $productVersion variable in my custom plugin, and use xpath to assign a value to it, e.g., "(/*/opentopic:map//*[contains(@class,' topic/vrm')]/@version) [1]".

But then, would it be possible to reference the variable in my dita document source?

Are there any other approaches to this?

Stefan Eike

unread,
Jul 25, 2016, 2:43:15 AM7/25/16
to DITA-OT Users, mrober...@gmail.com
Hi,

as Jarno said, reusing attributes does not work. I do not understand, why <vrm> is modelled like it is. Maybe you should define a keyword on the bookmap and create a Schematron rule, that compares the values of the <vrm> and the <keyword> element and throws an error, if they are not equal. Regarding your version-number example: If you want to speak of product versions in the text, you probably need more than one version, so using <keyword> (with conkeyrefs) for that may not work. Think of a paragraph like that:

Version 2 is the latest version of product x. It was released ten months after version 1, but contains less new features as 1.5 did.

Please also notice the release management domain in mind.

Greetings,
Stefan

mrob

unread,
Jul 25, 2016, 8:49:51 AM7/25/16
to DITA-OT Users, mrober...@gmail.com
Thanks for your thoughts about this. The release management domain is overkill for my needs, but it looks interesting. Maybe I could use that for something else in the future.

I guess my conclusion is that <vrm> is poorly modeled and I must go with the separate <keyword>. I am too much of a noob to figure out schematron rules for this, so I'll probably pass on that.

Stefan Eike

unread,
Jul 25, 2016, 9:44:33 AM7/25/16
to DITA-OT Users, mrober...@gmail.com
Try something like this:

  <pattern>
    <rule context="*[contains(@class, ' bookmap/bookmap ')]">
      <assert test="contains(descendant::*[contains(@class, ' mapgroup-d/keydef ')][@keys='current-version']/text(), descendant::*[contains(@class, ' topic/vrm ')][1]/@version)">
        First &lt;vrm&gt; must be equal to &lt;keydef @keys='current-version'&gt;
      </assert>
    </rule>
  </pattern>
Reply all
Reply to author
Forward
0 new messages