hmmm...my bad.. sorry about that.. .I'm not sure whether we have support for this in Axiom... Is there any api to wrap a xmleventreader by a xmlstreamreader...
thanks, Thilina On Wed, Sep 24, 2008 at 3:24 AM, Thorsten Scherler < [EMAIL PROTECTED]> wrote: > On Tue, 2008-09-23 at 09:52 -0400, Thilina Gunarathne wrote: > > I would say the usual way to present a set of StaX events is to wrap them > > using the standardized the XMLStreamReader [1][2][3] interface. > > ...or XMLEvenReader (see [1]). There are two approaches in StAX: > - Cursor (XMLStreamReader/Writer) > - Event Iterator (XMLEventReader/Writer) > > If you look at > http://java.sun.com/javase/6/docs/api/javax/xml/stream/XMLEventReader.html > you find "public interface XMLEventReader extends Iterator". > > Meaning a XMLEventReader is basically a "pimped" Iterator. I have an > iterator of XMLEvents. The best would be to pass my iterator to the > XMLEventReader. > > XMLInputFactory factory = XMLInputFactory.newInstance(); > XMLEventReader reader = > factory.createXMLEventReader(events); > > However sadly there is no such a method in the api: > http://java.sun.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html > > createXMLEventReader(Iterator<XMLEvent> events) > > ...but that would make a lot of sense. > > > Axiom works > > on top of StaX and can use the XMLStreamReader to create an OM tree.. > Axiom > > will pull events out of the given StaXreader as an when needed. > > > > > > My current code does this like follows for "normal" StAX: > > > > ... > > > > LinkedHashSet<XMLEvent> part = resultTree.get(element); > > > > Object[] partResult = part.toArray(); > > > > for (int i = 0; i < partResult.length; i++) { > > > > writer.add((XMLEvent) partResult[i]); > > > > } > > I'm sorry,I don't have much knowledge about DOM.. Is this XMLEvents are > > part of DOM, cause I haven't seen them in the StaX world... > > http://java.sun.com/javase/6/docs/api/javax/xml/stream/events/XMLEvent.html > > it is from StAX see as well [1]. > > salu2 > > > > > thanks, > > Thilina > > > > [1] http://edocs.bea.com/wls/docs90/xml/stax.html > > [2] http://www.jcp.org/en/jsr/detail?id=173 > > [3] http://wso2.org/library/1844 > > On Tue, Sep 23, 2008 at 6:01 AM, Thorsten Scherler < > > [EMAIL PROTECTED]> wrote: > > > > > On Mon, 2008-09-22 at 21:48 +0530, Saliya Ekanayake wrote: > > > > Hi, > > > > > > > > I am not sure exactly on your requirement, but normally Axiom builds > > > OMNodes > > > > from the XML events on requirement basis. Anyway you can access the > > > > underlying StAX parser of Axiom. If you can elaborate more on your > > > > requirement it will be helpful in answering your question. > > > > > > http://markmail.org/message/mwg5le6slrikjyak > > > > > > "Axiom builds OMNodes from the XML events on requirement basis" so is > > > there no way to create a OMNode by passing a xmlevent array? > > > > > > salu2 > > > > > > > Thanks, > > > > Saliya > > > > > > > > On Mon, Sep 22, 2008 at 5:33 PM, Thorsten Scherler < > > > > [EMAIL PROTECTED]> wrote: > > > > > > > > > Hi all, > > > > > > > > > > I am looking for the best way to create OMElements based on > XMLEvents. > > > > > > > > > > My current code does this like follows for "normal" StAX: > > > > > ... > > > > > LinkedHashSet<XMLEvent> part = resultTree.get(element); > > > > > Object[] partResult = part.toArray(); > > > > > for (int i = 0; i < partResult.length; i++) { > > > > > writer.add((XMLEvent) partResult[i]); > > > > > } > > > > > ... > > > > > > > > > > How can I do something like this with AXIOM? > > > > > > > > > > salu2 > > > > > -- > > > > > Thorsten Scherler > > > thorsten.at.apache.org > > > > > Open Source Java consulting, training and > > > solutions > > > > > > > > > > > > > > > > > > > > > -- > > > Thorsten Scherler > thorsten.at.apache.org > > > Open Source Java consulting, training and > solutions > > > > > > > > > > > -- > Thorsten Scherler thorsten.at.apache.org > Open Source Java consulting, training and solutions > > -- Thilina Gunarathne - http://thilinag.blogspot.com
