StylesFilter fires many, many times
Posted: Sat Jan 11, 2014 6:10 am
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!