XStream
  1. XStream
  2. XSTR-138

Wish to have StaxEventWriter and StaxEventReader

    Details

    • Type: Wish Wish
    • Status: Open Open
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      New XStream has StaxWriter to write using XMLStreamWriter and StaxReader to read from XMLStreamReader.

      I'd like to have classes to work with XMLEventWriter and XMLEventReader from StAX...

        Activity

        Hide
        Jörg Schaible added a comment -

        Well, a StaxEventReader is for the same reason not possible, why there exists no SaxReader:

        XStream works on a stream-based parser model, while SAX is event-based. The steam based model implies, that the
        caller consumes the individual tokens from the XML parser on demand, while in an event-based model the parser
        controls the application flow on its own and will use callbacks to support client processing. The different
        architecture makes it therefore impossible for XStream to use an event-driven XML parser.

        All that can be implemented is a StaxEventWriter which is technically a HierarchicalStreamWriter of XStream but triggers an XMLEventReader from StAX. See SaxReader implementation.

        Show
        Jörg Schaible added a comment - Well, a StaxEventReader is for the same reason not possible, why there exists no SaxReader: XStream works on a stream-based parser model, while SAX is event-based. The steam based model implies, that the caller consumes the individual tokens from the XML parser on demand, while in an event-based model the parser controls the application flow on its own and will use callbacks to support client processing. The different architecture makes it therefore impossible for XStream to use an event-driven XML parser. All that can be implemented is a StaxEventWriter which is technically a HierarchicalStreamWriter of XStream but triggers an XMLEventReader from StAX. See SaxReader implementation.
        Hide
        Tatu Saloranta added a comment -

        Hi Joerg – actually, I think you may have read too much into XMLEventReader. It is still using pull-model (just like XMLStreamReader), it's just that instead of offering a cursor in the stream, results are event objects (XMLEvent) that contain all the data for the event.

        So, it should not be super-difficult to support this I think, although at the same time usually it just should not be used – stream reader is more efficient than event reader, without exceptions. But I guess application may not get to choose which one is used in some cases.

        I think I could hack together a reader if this feature is what users want.

        Show
        Tatu Saloranta added a comment - Hi Joerg – actually, I think you may have read too much into XMLEventReader. It is still using pull-model (just like XMLStreamReader), it's just that instead of offering a cursor in the stream, results are event objects (XMLEvent) that contain all the data for the event. So, it should not be super-difficult to support this I think, although at the same time usually it just should not be used – stream reader is more efficient than event reader, without exceptions. But I guess application may not get to choose which one is used in some cases. I think I could hack together a reader if this feature is what users want.
        Hide
        Jörg Schaible added a comment -

        Well, you're definitely the expert in this area

        Show
        Jörg Schaible added a comment - Well, you're definitely the expert in this area
        Hide
        Tatu Saloranta added a comment -

        Looking at sources, it looks that while technically feasible, I am not 100% sure if it is needed.
        Most of the time users probably use XStream.toXML and fromXML methods, which just take streams, readers or writers. It is possible to use marshal/unmarshal which allow for passing specific HierarchicStreamWriter/Reader instead, tho. So it could be used.

        Maybe I will just wait if anyone actually wants to have such readers/writers, before writing code.
        (anyone reading this, just add a comment to indicate you would want to these for actual use?)

        Show
        Tatu Saloranta added a comment - Looking at sources, it looks that while technically feasible, I am not 100% sure if it is needed. Most of the time users probably use XStream.toXML and fromXML methods, which just take streams, readers or writers. It is possible to use marshal/unmarshal which allow for passing specific HierarchicStreamWriter/Reader instead, tho. So it could be used. Maybe I will just wait if anyone actually wants to have such readers/writers, before writing code. (anyone reading this, just add a comment to indicate you would want to these for actual use?)

          People

          • Assignee:
            Unassigned
            Reporter:
            Stepan Koltsov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: