Hello Michael,

You will find attached a second version of the adapter.
Now, it's able to read events from both XMLStreamReader and XMLEventReader.

Otherwise, as you will see by running the tests, there are 2 missing events when using the xalam.xml file.
These events are 'endPrefixMapping' ones and I think it may be a bug in the Java included StAX implementation.

You can verify on the method 'adaptEndElementEvent(...)' of the class 'StAX2SAXEventAdapter' that I call the method 'getNamespaces()' on the EndElement instance. The behavior of this method is: "Returns an Iterator of namespaces that have gone out of scope. Returns an empty iterator if no namespaces have gone out of scope.", but it's not returning anything.

I am gonna test this with the Woodstox' StAX implementation.

Thanks,
Samuel



2013/7/11 Samuel Medeiros <ccc.samuel@gmail.com>
Hi Michael,

Thanks for your reply.

While you check if we can proceed with the same approach to the StAXResult, I am implementing the support for XMLEventReader.

Sincerely,
Samuel


2013/7/10 Michael Glavassevich <mrglavas@ca.ibm.com>
Hi Samuel,

Samuel Medeiros <ccc.samuel@gmail.com> wrote on 07/08/2013 05:39:34 PM:

> Hi Michael,
>
> A StAXSource holds an XML source, i.e., XMLStreamReader or
XMLEventReader.
>
> In the adapter I have developed, I only have considered
> XMLStreamReader as a source.
> I think I also have to consider XMLEventReader and then modify my
> adapter. Do you agree?

Yes, that's right. Should structurally be fairly similar to what you have
so far for the XMLStreamReader.

> Also, I would like to know if you also have in mind any approach to
> implement the StAXResult.

I need to double check but I think you could wire this in as a SAX
ContentHandler too, where the ContentHandler (a "SAX2StAXAdapter") takes
each SAX event and converts it to a call (or multiple calls) on the
XMLStreamWriter / XMLEventWriter.

> Thanks,
> Samuel
>
> 2013/7/7 <shathawa@e-z.net>
> Samuel,
>
> Thanks for your report.
>
> Sincerely,
> Steven J. Hathaway
>
> > Greetings,
> >
> > Following the approach suggested by Michael, I have developed the
first
> > version of the 'StAX to SAX events' adapter.
> >
> > To develop it, I have created a local project (attached) with the
> > following
> > structure:
> >
> >    - *org.apache.xalan.stax.StAX2SAXAdapter
> >    *Represents the adapter.
> >    - *org.apache.xalan.sax.SAXHandler
> >    *It's the SAX handler. It logs all incoming events into a stack.
> >    - *org.apache.xalan.stax.test.StAX2SAXAdapterTest
> >    *It tests the adapter by calling both SAXHandler
> >    and StAX2SAXAdapter with a common XML file and verifying that their
> > event
> >    stacks are equal.
> >    - *org.apache.xalan.stax.resource
> >    *This package contains some XML files used in the tests: xalam.xml,
> >    birds.xml and xmark.xml. This last one is not included into the
> > attached
> >    .zip file because its size is 35,7 MB. I have generated it using
XMark
> > (
> >    http://www.xml-benchmark.org/downloads.html).
> >
> >
> > As provided in the plan, this week I should study how to implement
> > StAXResult support, but I can also start integrating this adapter into
the
> > Xalan code.
> >
> > Michael, what do you advise me to do?
> >
> > I am looking forward to having your feedback about this adapter.
> >
> > Thanks,
> > Samuel Queiroz
> >
> >
> > 2013/6/25 Michael Glavassevich <mrglavas@ca.ibm.com>
> >
> >> Hi Samuel,
> >>
> >> Xerces has partial support for StAX but doesn't yet have an
> >> implementation
> >> of XMLStreamReader.
> >>
> >> For testing purposes I'd suggest using Woodstox [1]. It's a popular
open
> >> source StAX implementation which many Apache projects already use.
> >>
> >> There's also a complete implementation of StAX in all versions of
Java
> >> 6+,
> >> so you could use that for testing too.
> >>
> >> Thanks.
> >>
> >> [1] http://woodstox.codehaus.org/
> >>
> >> Michael Glavassevich
> >> XML Technologies and WAS Development
> >> IBM Toronto Lab
> >> E-mail: mrglavas@ca.ibm.com
> >> E-mail: mrglavas@apache.org
> >>
> >> Samuel Medeiros <ccc.samuel@gmail.com> wrote on 06/25/2013 11:19:00
AM:
> >>
> >> > Hi Michael,
> >> >
> >> > Please disconsider my first email in this thread.
> >> > I was thinking about implement StAX. However, this project is
> >> > nothing to do with this.
> >> >
> >> > I have read the tutorial [1] and the ideas got more clear for me:
> >> > In fact, what is proposed is to accomplish the XLS Transformation
by
> >> > receiving a StAXSource and sending the result trough a StAXResult.
> >> >
> >> > The approach you have proposed in your last message is now clear
for
> >> > me: I have to iterate over the StAXSource by using an
XMLEventReader
> >> > / XMLStreamReader and translate these events to SAX ones.
> >> >
> >> > I just have to check how to apply this approach into the code.
> >> >
> >> > --
> >> >
> >> > I know the implementation is based on the interfaces defined by
> >> > JAXP. However, for run the samples as well as the tests I will
> >> > write, we are gonna need an implementation. By default, Xalan uses
> >> > Xerces. The question is: does Xerces support StAX?
> >> >
> >> > Thanks,
> >> > Samuel
> >> >
> >> > [1] http://tutorials.jenkov.com/java-xml/index.html
> >>
> >> > 2013/6/25 Samuel Medeiros <ccc.samuel@gmail.com>
> >> > Hi Michael,
> >> >
> >> > Thanks for this information.
> >> > I am gonna study exactly how to apply this approach into the source
> >> code.
> >> >
> >> > If I have questions, I will let you know.
> >> >
> >> > Sincerely,
> >> > Samuel
> >> >
> >>
> >> > 2013/6/24 Michael Glavassevich <mrglavas@ca.ibm.com>
> >> > Hi Samuel,
> >> >
> >> > One approach you could take for StAXSource would be to write a StAX
to
> >> SAX
> >> > converter. This would take an XMLStreamReader / XMLEventReader as
> >> input
> >> > and generate SAX events on to a ContentHandler. You could wire that
to
> >> the
> >> > TemplatesHandler (org.apache.xalan.processor.StylesheetHandler)
> >> allowing
> >> > you to reuse the existing components for building the Templates
> >> object.
> >> >
> >> > Thanks for the update.
> >> >
> >> > Michael Glavassevich
> >> > XML Technologies and WAS Development
> >> > IBM Toronto Lab
> >> > E-mail: mrglavas@ca.ibm.com
> >> > E-mail: mrglavas@apache.org
> >> >
> >> > Samuel Medeiros <ccc.samuel@gmail.com> wrote on 06/23/2013 04:30:38
> >> PM:
> >> >
> >> > > Hi Michael,
> >> > >
> >> > > I have read the documentation available at the Xalan's website
and
> >> > > also its pointers to XSL/XSLT, XPath and JAXP. I have also run
some
> >> > > samples and did some tracing by adding some prints into the code.
> >> > >
> >> > > It's quite clear for me how the things work, but I am not
> >> > > familiarized enough with the code.
> >> > >
> >> > > According to [1], the javax.xml.transform.stax was added to
support
> >> > > StAX. This package consists of the interfaces: TemplatesHandler
> >> > > and TransformerHandler; and classes: StAXResult and StAXSource.
> >> > > Also, the packages javax.xml.stream, javax.xml.stream.events and
> >> > > javax.xml.stream.util were added to support StAX. In addition,
the
> >> > > class Validator have also to accept StAXSource.
> >> > >
> >> > > For me, to add StAX support, it would be just implement the
> >> > > interfaces provided by these packages and plug them into the
> >> > > existent code. For example, in the
> >> > > org.apache.xalan.processor.TransformerFactoryImpl's method
> >> > > newTemplates(Source source), I would add a condition to test if
the
> >> > > source is a StAX one and then create the correct TemplatesHandler
> >> > > instance, that will create the Templates object.
> >> > >
> >> > > I don't know exactly how prepared is Xalan to receive these
changes.
> >> > >
> >> > > I need help to understand the project's structure. Then I will be
> >> > > able to do the work of the 2 next weeks (as provided in the
plan):
> >> > > define precisely the changes I will do.
> >> > >
> >> > > Sincerely,
> >> > > Samuel
> >> > >
> >> > > [1]
http://docs.oracle.com/javase/6/docs/technotes/guides/xml/jaxp/
> >> > > ReleaseNotes_160.html
> >> >
> >>
> >> >
---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
> >> > For additional commands, e-mail: dev-help@xalan.apache.org
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
> >> For additional commands, e-mail: dev-help@xalan.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
> > For additional commands, e-mail: dev-help@xalan.apache.org

Michael Glavassevich
XML Technologies and WAS Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org




--
Samuel de Medeiros Queiroz
Formal Methods Group (GMF - UFCG - Brazil)



--
Samuel de Medeiros Queiroz
Formal Methods Group (GMF - UFCG - Brazil)