Page 1 of 1

Compare map and topic values

Posted: Mon Sep 12, 2016 9:03 pm
by xephon
Hi,

I have a DITA Map with a topic reference, that has a filter attribute, for example @foo:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map id="map">
<title>DITA Topic Map</title>
<topicref href="topic.dita" foo="bar"/>
</map>
The topic has a <data> element, named foo with a value, that must be equal to the filter attribute.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic">
<title>Topic</title>
<prolog>
<metadata>
<data name="foo" value="no-bar"/>
</metadata>
</prolog>
</topic>
Is it possible to compare both values with <oXygen/>, preferably with Schematron and a DITA Map validation scenario and a DITA Topic validation scenario :?:

Greetings,
Stefan

Re: Compare map and topic values

Posted: Tue Sep 13, 2016 9:22 am
by Radu
Hi Stefan,

Possibly in the Schematron used to validate the topic you could use the document() function to load the DITA Map and look inside it.
Other than this, I'm not sure how this could be done...

Regards,
Radu

Re: Compare map and topic values

Posted: Tue Sep 13, 2016 10:04 am
by xephon
Hi Radu,

alright, thanks. So, there is no option to get the DITA Map that is opened in the DITA Maps Manager?

Greetings,
Stefan

Re: Compare map and topic values

Posted: Tue Sep 13, 2016 1:27 pm
by Radu
Hi Stefan,

We have some static Java API to access the URL of the current opened DITA Map.
So in the Schematron you could define a prefix for the Java extension:

Code: Select all

    <ns uri="java:ro.sync.ecss.dita.DITAAccess" prefix="java"/>
and then use it like:

Code: Select all

<value-of select="java:getRootMapURL()"/>
but loading the main DITA Map using the document() function and parsing it each time the user types something in a topic (and automatic validation is triggered) seems a bit too much. You would need some kind of caching and I'm not sure how you could do this only with Schematron.
We have Java API which would allow you to add your own Java-based validation stage, this would possibly allow you to cache the information stored in the DITA Map instead of parsing the DITA Map each time.

Regards,
Radu