Show title from xref'ed document in Author mode

JamesL
Posts: 16
Joined: Thu Nov 03, 2011 3:16 pm

Show title from xref'ed document in Author mode

Post by JamesL » Thu Nov 03, 2011 3:23 pm

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: 7028
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Thu Nov 03, 2011 4:12 pm

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 » Wed Nov 30, 2011 11:39 pm

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: 7028
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Thu Dec 01, 2011 12:19 pm

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: 7028
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Thu Jan 12, 2012 1:52 pm

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 » Thu Jan 12, 2012 2:25 pm

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 » Tue Jan 17, 2012 4:01 pm

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 » Tue Jan 17, 2012 5:32 pm

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: 7028
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Tue Jan 17, 2012 6:20 pm

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 » Tue Jan 17, 2012 6:28 pm

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

Thanks again!

Post Reply