oxy_link-text() and refresh
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 40
- Joined: Wed Jan 29, 2014 4:30 pm
oxy_link-text() and refresh
Hi,
I am using the oxy_link-text() function in my CSS.
I have implemented a custom LinkTextResolver that returns different values depending on attributes set on the xref. For example, if @reftext=yes, I show the title of the target element; but if @reftext=no, I show some other text.
However, when I change the attribute value in my document, the value displayed by oxy_link-text() does not change unless I force a "reload F5" which then prompts me for saving the document before refreshing it.
Is there a way to automatically refresh without saving the doc ?
Thanks,
Pascale
I am using the oxy_link-text() function in my CSS.
Code: Select all
xref:empty {
content: oxy_link-text() ;
}
However, when I change the attribute value in my document, the value displayed by oxy_link-text() does not change unless I force a "reload F5" which then prompts me for saving the document before refreshing it.
Is there a way to automatically refresh without saving the doc ?
Thanks,
Pascale
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: oxy_link-text() and refresh
Post by alex_jitianu »
Hi Pascale,
Your link resolver should listen on document changes. When such an attribute changes, if it keeps some sort of cache it must clear what's outdated and must call refresh on the node. You can use the activated call of the resolver to add such a listener. Here is how we do it in the default DITA link text resolver:
Another possible solution is to add a CSS rule that will mark the element as being dependent on an attribute. Oxygen will then automatically refresh the element when its attribute changes:
This second approach will be enough if your link text resolver doesn't keep an inner cache with the references it resolves. If it does, then you need to go with the first solution.
Best regards,
Alex
Your link resolver should listen on document changes. When such an attribute changes, if it keeps some sort of cache it must clear what's outdated and must call refresh on the node. You can use the activated call of the resolver to add such a listener. Here is how we do it in the default DITA link text resolver:
Code: Select all
public class DitaLinkTextResolver extends LinkTextResolver {
/**
* @see ro.sync.ecss.extensions.api.AuthorExtensionStateListener#activated(ro.sync.ecss.extensions.api.AuthorAccess)
*/
@Override
public void activated(AuthorAccess authorAccess) {
this.authorAccess = authorAccess;
authorAccess.getDocumentController().addAuthorListener(authorListenerAdapter);
}
/**
* For a map/topicref the attributes locktitle and navtitle control the expanded text.
* So when they change we must also refresh.
*/
private AuthorListenerAdapter authorListenerAdapter = new AuthorListenerAdapter() {
@Override
public void attributeChanged(ro.sync.ecss.extensions.api.AttributeChangedEvent e) {
AuthorElement element = (AuthorElement) e.getOwnerAuthorNode();
String attrName = e.getAttributeName();
if (resolvesTopicrefs) {
// If the resolver was never for topicrefs used there is no point in refreshing.
// oxy_link_text() was encountered on topicref styles. Changing these two
// attributes will give a different text for the element so we'll refresh.
AttrValue classValue = element.getAttribute("class");
if (classValue != null
&& classValue.getValue().contains(" map/topicref ")) {
boolean depends = "locktitle".equals(attrName) ||
"navtitle".equals(attrName);
if (depends) {
// Refresh the node so that it's styles are recomputed.
authorAccess.getEditorAccess().refresh(element);
}
}
}
}
};
Code: Select all
/* This rule is just so that Oxygen refreshes the Styles of the element when the attribute changes*/
xref[reftext] {}
Best regards,
Alex
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service