Show title from xref'ed document in Author mode

Post here questions and problems related to editing and publishing DITA content.
JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Show title from xref'ed document in Author mode

Post by JamesL »

In an effort to assist our authors, I am looking for a way to modify the Author mode so that instead of the document name/id/key shown for an xref, the actual title of the reference document is should. Something similar to how a conref is represented.

I have been fiddling with the CSS files in the frameworks directory, but have not found a way.

I am asking for this because we have very large projects (3000+ topics in a series of maps), and the title for certain topics contains useful information.

Thanks.
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Show title from xref'ed document in Author mode

Post by Radu »

Hi James,

We've had a previous improvement request for this and I added your comments to it.

If you want to approach this from the CSS side, the most powerful CSS extension that we have, the xpath function:

http://www.oxygenxml.com/doc/ug-editor/ ... ction.html

allows you to run full XPath 2.0 expressions so you could maybe try to come up with an XPath expression which parses the target topic document and retrieves some title text.

Also, our Java Author SDK API allows for you to take control about what to display for an xref by implementing a StylesFilter interface, thus also you would be responsible to parse the reference topic and obtain the title from it. So this is another alternative you can explore if you are comfortable with Java:
http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK
I can give you more details about this approach if you are interested.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Re: Show title from xref'ed document in Author mode

Post by JamesL »

I have finally had time to take a look at the XPATH part of your suggestion.

I have tried a few things and have gotten stuck with trying to use xpath on an external document.

So in the *[class~="topic/xref"][href]:before CSS section of topic.css, when I changed to content to:
content:url("../img/link.png") "[" attr(href, url) "]";
I correctly get the path to referenced file (file:/path/on/disk/file.xml), though a message that the file is an unsupported image type.

But if I wrap that in an oxy_xpath like so:
content:url("../img/link.png") "[" oxy_xpath(attr(href, url)) "]";
The Author editor throws errors saying:
System ID: /Applications/author/modified_frameworks/dita/css_classed/dita.css
Severity: error
Description: [CSS]:XPath failed: XPath failed due to: QName cannot end with colon: {file:}
Is there a trick to using oxy_xpath with an external document?

Thanks.
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Show title from xref'ed document in Author mode

Post by Radu »

Hi James,

There are two problems here, one on your side and one on ours.

You first need to gather some knwwledge about XPath 2.0 expressions:

http://www.w3.org/TR/xpath20/

As expression like this:

Code: Select all

oxy_xpath(attr(href, url))
is first expanded by Oxygen by expanding the attr function to something like this:

Code: Select all

oxy_xpath("file:/path/on/disk/file.xml")
An XPath like this is invalid and meaningless and this is why the XPath execution engine reports the engine:

Code: Select all

QName cannot end with colon: {file:}
Basically if you only xref to entire topic files the XPath expression should have been something like:

Code: Select all

content:url("../img/link.png") "[" oxy_xpath("if(contains(@href, '#')) then fn:doc(substring-before(@href, '#'))//title[1]/text() else fn:doc(@href)//title[1]/text()") "]";
But this does not work in Oxygen although it should. We'll try to fix this bug in time for Oxygen 13.2 which will appear in January next year.
I'll update this forum post when the issue gets fixed.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Show title from xref'ed document in Author mode

Post by Radu »

Hi James,

Oxygen 13.2 which has just been released should contain a fix for this issue.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Re: Show title from xref'ed document in Author mode

Post by JamesL »

Thank you for the heads up. I will check it out.
JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Re: Show title from xref'ed document in Author mode

Post by JamesL »

I finally got some time to experiment with this, and wanted to say that things are working great! I have the basic functionality working, now just need to expand it.

Thank you for the help!
JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Re: Show title from xref'ed document in Author mode

Post by JamesL »

Not sure if this is a bug in Oxygen, or something not right in my CSS.

I have a topic as follows:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="conceptId">

<title>Normal Topic Title</title>

<conbody>
<p>Concept definition.</p>

<section>
<title>Section Title</title>
</section>

</conbody>
</concept>
and have modified the CSS as follows:

Code: Select all


*[class~="topic/link"][href]:before,
*[class~="topic/xref"][href]:before {
content:url("../img/link.png") "[" oxy_xpath("if(contains(@href, '#')) then fn:doc(substring-before(@href, '#'))//title[1]/text() else fn:doc(@href)//title[1]/text()") "]";
}
The "title[1]" would imply that it should be pulling the text from the first occurrence of title ("Normal Topic Title"), but when I view the above topic in Author view, I get: "Normal Topic TitleSection Title".

If I change the title[1] to title[2], I get nothing for the title in Author view.

Thoughts?
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Show title from xref'ed document in Author mode

Post by Radu »

Hi James,

My fault, //title[1] means the first title in its parent, it should be more like (//title)[1].

So the CSS property should be like this:

Code: Select all

content:url("../img/link.png") "[" oxy_xpath("if(contains(@href, '#')) then fn:doc(substring-before(@href, '#'))/(//title)[1]/text() else fn:doc(@href)/(//title)[1]/text()") "]";
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Re: Show title from xref'ed document in Author mode

Post by JamesL »

That got everything working perfectly. We will have some very happy authors now :)

Thanks again!
Post Reply