-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow use of xsl on the fly (output) #201
Conversation
Hallo Carsten, thanks for your contribution, but it seems you did not recognize that XStream has already XSL support? It is wrapped in com.thoughtworks.xstream.io.xml.TraxSource and com.thoughtworks.xstream.io.xml.SaxWriter that turns an XStream instance into a SAX parser used by the transformer. That way the transformer uses directly the events generated by XStream without generating intermediate XML. However, the implementation did not support an ObjectOutputStream to convert all the stuff on-the-fly. Your implementation gave the idea how to achieve this. Internally I also use a background thread with a simple BlockingQueue. Works like charm. |
Hi Jörg, |
Hi Carsten, no, I have no experience in this area. Do you have a use case for the input scenario? Using a style sheet for output makes sense if you generate a completely different format. To use a style sheet as input for XStream simply means you're transforming your XML ... but why? Isn't it possible to configure XStream for the original format in first place? |
Hi Jörg, |
OK, nice approach. I was just interested in a valid use case. When I have to read different versions of the "same" XML data, I use normally a version attribute in the root element. The converter, that handles it, will put the value in the DataHolder (Context) and the information is therefore available in the complete unmarshaling process ... and so I am able to expect different things depending on the format version. But yes, this implies more work in converters. |
One thing to consider: if you use a stylesheet for small changes on import or output changing your code to the traxsource approach seems to be rather heavyweight. Maybe you can think about a second way to make use of a stylesheet similar to the one in this pull request that needs minimal changes to your existing code. |
Prove of concept for using xsl internally to xstream.
Same could be done for input and simplifies usage. Not sure if it would be possible to implement "streaming" (low memory footprint) in some use cases. There are some flaws regarding threading in the implementation but do not care for the moment.