Re: [Mono-list] parsing an incomplete xml

2004-07-19 Thread Krisztian PIFKO
On Sun, 2004-07-18 at 20:34 -0700, Scott Boston wrote:
 How are you feeding the incomplete xml into the XmlTextReader? 

i have a StringBuilder buffering the input, and i try to create
the XmlTextReader using a StringReader created from StringBuilder's
ToString().

 You can create a NetworkStream from your Socket and use that to create
 your XmlTextReader instance.  Then you just do a continuous Read() loop,
 until EOF.

i can't, as the initial tag is only closed when the session is over.
imagine something like this:

(connection starts)
client: ?xml ...?stream:stream 
server: ?xml ...?stream:stream 
client: auth info...//auth info
server: some answer...//some answer
client: comm1...//comm1
server: some answer...//some answer
...
client: /stream:stream
server: /stream:stream
(connection terminates)

not a parser friendly communication ;)


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] parsing an incomplete xml

2004-07-19 Thread Krisztian PIFKO
On Mon, 2004-07-19 at 01:46 -0400, Chris Bruner wrote:
 I believe that the xml spec says that parsing should stop as soon as an error 
 occurs. (This includes begin incomplete).

yes i fear this is the correct approach for all of the parsers.

 Therefore the only way you could fix it would be to have a completion string 
 built up. So that you would mark every tag that get's added, and unmark them 
 as they are done. eg tag/tag Also tags that end with / can be thought of  
 as finished.  Then when you find the stream has died, you just complete all 
 the tags. 

i do something like this, i handle the initial incomplete part by hand
and then parse the properly closed internal parts as they arrive.

 The downside is that this means you are doing the job of parsing the xml 
 before the parser. Seems like a lot of work.

yes, but maybe something useful will grow out of this. ;)

thanks,

Krisztian PIFKO


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] parsing an incomplete xml

2004-07-19 Thread Scott Boston
On Mon, 2004-07-19 at 01:46, Krisztian PIFKO wrote:
 On Sun, 2004-07-18 at 20:34 -0700, Scott Boston wrote:
  How are you feeding the incomplete xml into the XmlTextReader? 
 
 i have a StringBuilder buffering the input, and i try to create
 the XmlTextReader using a StringReader created from StringBuilder's
 ToString().
 
  You can create a NetworkStream from your Socket and use that to create
  your XmlTextReader instance.  Then you just do a continuous Read() loop,
  until EOF.
 
 i can't, as the initial tag is only closed when the session is over.
 imagine something like this:
 
 (connection starts)
 client: ?xml ...?stream:stream 
 server: ?xml ...?stream:stream 
 client: auth info...//auth info
 server: some answer...//some answer
 client: comm1...//comm1
 server: some answer...//some answer
 ...
 client: /stream:stream
 server: /stream:stream
 (connection terminates)
 
 not a parser friendly communication ;)

That should be no problem.  Just create both an XmlTextReader and an
XmlTextWriter on the stream.  In your Read loop, you know where you are
in your stream, and can take action based on that.  In your example, if
the NodeType is XmlNodeType.Element, and the Name is stream, then
write the beginning elements back to the client on the writer and
continue.  If the Name is auth, then continue reading the input until
the NodeType is XmlNodeType.EndElement and the name is also auth. 
(Along the way to EndElement you can get the data out of the node that
you're looking for.)  Then you can send your answer down the writer and
continue.  This is somewhat simplified explanation, but it should give
the general idea.

-- Scott

 
 
 ___
 Mono-list maillist  -  [EMAIL PROTECTED]
 http://lists.ximian.com/mailman/listinfo/mono-list

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] parsing an incomplete xml

2004-07-19 Thread Jonathan Stowe
On Mon, 2004-07-19 at 03:36, Krisztian PIFKO wrote:
 On Sun, 2004-07-18 at 21:21 -0400, Stephen Caldwell wrote:
  Well if you have some way of knowing how big the stream is, then maybe
  buffer it all and then parse it, or you might have to create a parsing
  class which can better handle mal-formed xml documents.
 
 sad, but i need to parse it as it comes (xmpp/jabber protocol is like
 this), so i'll interpret the stream by hand.
 

This sounds like you are reinventing a rather big wheel - have you
looked at how jabber.net deals with this?

  http://www.jabberstudio.org/projects/jabber-net/project/view.php

/J\ 

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] parsing an incomplete xml

2004-07-18 Thread Krisztian PIFKO
hi,

should someone please tell me how to parse an incomplete xml?
i'm reading the xml asynchronously from a socket and i need to
parse it continously as it arrives.
when i feed the incomplete xml into XmlTextReader it hangs at
the first unclosed element.

thanks in advance,

Krisztian PIFKO


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] parsing an incomplete xml

2004-07-18 Thread Krisztian PIFKO
On Sun, 2004-07-18 at 21:21 -0400, Stephen Caldwell wrote:
 Well if you have some way of knowing how big the stream is, then maybe
 buffer it all and then parse it, or you might have to create a parsing
 class which can better handle mal-formed xml documents.

sad, but i need to parse it as it comes (xmpp/jabber protocol is like
this), so i'll interpret the stream by hand.

thanks,

Krisztian PIFKO


___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] parsing an incomplete xml

2004-07-18 Thread Scott Boston
How are you feeding the incomplete xml into the XmlTextReader? 

You can create a NetworkStream from your Socket and use that to create
your XmlTextReader instance.  Then you just do a continuous Read() loop,
until EOF.

On Sun, 2004-07-18 at 16:56, Krisztian PIFKO wrote:
 hi,
 
 should someone please tell me how to parse an incomplete xml?
 i'm reading the xml asynchronously from a socket and i need to
 parse it continously as it arrives.
 when i feed the incomplete xml into XmlTextReader it hangs at
 the first unclosed element.
 
 thanks in advance,
 
 Krisztian PIFKO
 
 
 ___
 Mono-list maillist  -  [EMAIL PROTECTED]
 http://lists.ximian.com/mailman/listinfo/mono-list

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list