I searched the web and I searched stackoverflow up and down. There is no decision. Although I found solutions how to do this in pure xslt here .
But the problem is that the resulting xml will have several hundred megabytes. So I have to do it using SAX in Java. (please do not xslt solution, although I marked it with xslt ;-))
Let me explain in more detail. I have several few xml files (preferably InputSteam) that need to be parsed. Files or InputStream look like
inputstream1
<root> <doc> <tag>test1</tag> </doc> <doc> <tag>test2</tag> </doc> ... </root>
inputstream2
<root> <doc> <tag>test3</tag> </doc> <doc> <tag>test4</tag> </doc> ... </root>
inputstream1 + inputstream2 + ... + inputstreamN = xml result . It will look like
<root> <doc> <tag>test1</tag> </doc> <doc> <tag>test2</tag> </doc> ... <doc> <tag>test3</tag> </doc> <doc> <tag>test4</tag> </doc> ... </root>
Does anyone have a solution or link for this? Can this be implemented using a custom InputSource or using a custom ContentHandler? Or is this possible with joost / stx ?
The good thing, if I can use the ContentHandler, would be that I could apply some minor transformations (I already implemented this). But then the problem is that I don’t know a way to transfer multiple files or an InputStream as an InputSource:
XMLReader xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setContentHandler(customHandler); xmlReader.parse(getInputSource());
or should I parse InputStreams directly in my ContentHandler?
source share