StylesFilter fires many, many times
Post here questions and problems related to oXygen frameworks/document types.
StylesFilter fires many, many times
I have a question about creating a custom StylesFilter. I've developed one that performs an XQuery to get the values and labels needed for a combo box. My example case is a list of people, so my XQuery simply pulls out the xml:id and then transforms various parts of people's names, birth and death dates, etc. in order to generate labels to go along with the ids. I took the example given in the documentation http://www.oxygenxml.com/doc/ug-oxygen/ ... ilter.html and also located in the AuthorSDK as my basis and tweaked it. I did get it to work, but unfortunately, the filter() method is being called dozens of times for a single node (70+ times!), which in turn is compiling and executing my XQuery dozens of times. This causes the editor to run extremely slowly.
I tried adding the results from the query to static variables, so they were essentially cached in global variables, but when my StylesFilter implementation is called it does not have access to any static variables across instances, so it's re-running the XQuery regardless. How can I avoid this being called so many times? Ultimately, I'd like to be able to use static variables and cache the results so that multiple fields of the same type could use the same results from my XQuery, or at the very least find a way to only have it compile and call the XQuery once per node. Does anyone know how to do that?
Thanks for any help you can provide!
I tried adding the results from the query to static variables, so they were essentially cached in global variables, but when my StylesFilter implementation is called it does not have access to any static variables across instances, so it's re-running the XQuery regardless. How can I avoid this being called so many times? Ultimately, I'd like to be able to use static variables and cache the results so that multiple fields of the same type could use the same results from my XQuery, or at the very least find a way to only have it compile and call the XQuery once per node. Does anyone know how to do that?
Thanks for any help you can provide!
-
- Posts: 1009
- Joined: Wed Nov 16, 2005 11:11 am
Re: StylesFilter fires many, many times
Post by alex_jitianu »
Hi,
The StylesFilter is called many times because we don't cache it's results on our side and the styles for an element are requested a lot. So it's up to the implementation to do a caching if necessary.
I suspect that you are using the node as the key in your cache. There might be a problem if this node is a pseudo element (:before/:after) because these are not present in the model and we create instances every time we need them. If this is indeed what's happening then you can keep the parent element as the key:
Might also help to use a WeakHashMap to avoid memory leaks generated by the fact you are keeping nodes in the cache.
If that's not the actual issue then it would help to take a look at the StylesFilter implementation so perhaps you could send it to our support email address.
Best regards,
Alex
The StylesFilter is called many times because we don't cache it's results on our side and the styles for an element are requested a lot. So it's up to the implementation to do a caching if necessary.
I suspect that you are using the node as the key in your cache. There might be a problem if this node is a pseudo element (:before/:after) because these are not present in the model and we create instances every time we need them. If this is indeed what's happening then you can keep the parent element as the key:
Code: Select all
AuthorNode key = authorNode;
if (authorNode.getType() == AuthorNode.NODE_TYPE_PSEUDO_ELEMENT) {
key = authorNode.getParent();
}
If that's not the actual issue then it would help to take a look at the StylesFilter implementation so perhaps you could send it to our support email address.
Best regards,
Alex
Re: StylesFilter fires many, many times
Actually, after reading your answer, I realized that I had made a mistake in my code which was causing it not to cache correctly, so in the end it was just a bug in the way I was caching my objects Thanks for your help nonetheless!
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