Display xreflabel attribute contents in link text

Oxygen general issues.
xsaero00
Posts: 58
Joined: Sat Aug 01, 2009 12:57 am

Display xreflabel attribute contents in link text

Post by xsaero00 »

According to DocBook docs, (http://www.docbook.org/tdg5/en/html/xref.html) when a link (xref, link, ... ) is pointing to an element that has xreflabel attribute defined, the link text should match the content of the xreflabel attribute.

I cannot seem to find a way to do that in Author view. The CSS does not seem to allow something like that. Is there a way to do it with extension/plugins?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Display xreflabel attribute contents in link text

Post by sorin_ristache »

Hello,

That is not possible in the current version. We will consider that for a future version.


Regards,
Sorin
xsaero00
Posts: 58
Joined: Sat Aug 01, 2009 12:57 am

Re: Display xreflabel attribute contents in link text

Post by xsaero00 »

OK. Thanks for reply.

Is there some sort of substring function in CSS. Using function like those i could format my xref links to look like xreflabel.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Display xreflabel attribute contents in link text

Post by sorin_ristache »

Hello,

There is no substring function in CSS. We will consider adding a CSS extension function for finding the substring of a string but the problem will be solved by xref taking the display text from the xreflabel attribute of the target element.


Regards,
Sorin
xsaero00
Posts: 58
Joined: Sat Aug 01, 2009 12:57 am

Re: Display xreflabel attribute contents in link text

Post by xsaero00 »

I guess we'll just wait for that feature. It is not a show stopper, but it is highly desired. Any idea on when you will work on it.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Display xreflabel attribute contents in link text

Post by sorin_ristache »

It was not planned for a version number. It will be probably implemented in one of the future versions.


Regards,
Sorin
xsaero00
Posts: 58
Joined: Sat Aug 01, 2009 12:57 am

Re: Display xreflabel attribute contents in link text

Post by xsaero00 »

I was reading the development docs and it seems like I should be able to do this by implementing AuthorReferenceResolver interface. It seems suited exactly for that purpose.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Display xreflabel attribute contents in link text

Post by sorin_ristache »

You can set the content property of the link element using a ro.sync.ecss.extensions.api.StylesFilter implementation that you provide with ro.sync.ecss.extensions.api.ExtensionsBundle.createAuthorStylesFilter(). You call setProperty(KEY_MIXED_CONTENT, yourInstanceOf_StringContent) on the ro.sync.ecss.css.Styles parameter of StylesFilter.filter() for overriding the content property of the link element specified in the CSS stylesheet. yourInstanceOf_StringContent is an object of type ro.sync.ecss.css.StringContent that contains the displayed text of the link element when it is rendered in Author mode. In your case the displayed text should be the xreflabel attribute of the target element which you find with an XPath expression executed with ro.sync.ecss.extensions.api.AuthorAccess.getDocumentController().findNodesByXPath(). You get an AuthorAccess object in a listener of type ro.sync.ecss.extensions.api.AuthorExtensionStateListener that you provide in the method ro.sync.ecss.extensions.api.ExtensionsBundle.createAuthorExtensionStateListener().

It seems complicated but there are just a few lines of code because the Author API provides the entire infrastructure and hook points. Please let me know if it is not clear.


Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Display xreflabel attribute contents in link text

Post by sorin_ristache »

We will add this to the Simple Documentation Framework included in Author SDK as another example of using the Author API.


Regards,
Sorin
xsaero00
Posts: 58
Joined: Sat Aug 01, 2009 12:57 am

Re: Display xreflabel attribute contents in link text

Post by xsaero00 »

Thanks I think that will work. StyleFilter seems to be more suited for my purpose.
Post Reply