axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Pocock <matthew_poc...@yahoo.co.uk>
Subject Re: SAX2EventRecorder
Date Tue, 11 Nov 2003 11:21:50 GMT
Hi,

Seems even odder things are going on. I found some methods on 
DeserializationContext for getting the current recording position 
(perhaps they should be on the recorder not the context). These methods 
only work as I'd expect in some situations. Here is some code that 
prints out the indecies:

public class CountingDeser extends DeserializerImpl {
  public void oNtartElement(Strig namespace,
                            String localName,
                            String prefix,
                            Attributes attributes,
                            DeserializationContext ctxt)
          throws SAXException
  {
    System.err.println("startElement index: " + ctxt.getCurrentRecordPos());
  }

  public void onEndElement(String namespace,
                           String localName,
                           DeserializationContext ctxt)
        throws SAXException
  {
    System.err.println("endElement index: " + ctxt.getCurrentRecordPos());
  }
}

Somewhere in the deserialization guts, something equivalent to this is 
working just fine (in SOAPHandler, RPCElement and RPCProvider these 
calls are used to work out what events make which part of the soap 
message, populating the start and end event index of RPCElement). These 
evants are then played back to the deserialization handlers somewhere in 
JavaProvider.invoke(). However, something odd happens here with the 
recorder, and ctxt.getRecorder() sees the recorder being used for 
playback, not one that's recording the event stream relative to your 
deserializer. So - in custom handlers, getCurrentRecordPos() always 
returns the index of the final SAX event regardless of how far through 
the event stream the deserializer thinks it is.

Clear as mud? I think someone who knows this code should take a look as 
I'm out of my depth.

Matthew

Matthew Pocock wrote:

> Hi
>
> This class has API to replay sax events between a start & end index. 
> However, I can't see any method that would let me guess the values of 
> these. Could we add a method like this:
>
> /**
> * Return the index of the current event.
> */
> int getCurrentPosition()
>
> Related to this, I am setting the event recorder in onStartElement() 
> to a new recorder instance, and in onEndElement() calling playback() 
> on this recorder. It seems that the events it plays back are not 
> ballanced - the events are deeper at the beginning than the end. 
> Looking into it now.
>
> Matthew
>



Mime
View raw message