Jan
11
Posted on 2006-01-11
Filed Under (LotusScript, XML) by Johan Känngård

I have a problem, that nor I nor any of my colleagues can’t solve easily. I have several classes that are passing objects/variables between them. On of them is handling Web Service request, and parsing the responses to a NotesDOMDocumentNode via the NotesDOMParser. The NotesDOMDocumentNode is passed returned, and are used in several places to extract information. But, I need to cache the response, so concurrent request with the same parameters are sped up.
To cache the response, I need to serialize the NotesDOMDocumentNode. At first, I thought this was easy, since there is a Serialize method on the NotesDOMParser. But no… You have to keep the original NotesDOMParser that parsed the raw XML data. The only solutions I can figure out are:

  • pass both the NotesDOMDocumentNode AND the original NotesDOMParser at all times
  • write my own Serialize method
  • pass the XML string only, and do the parsing at each method. I think this would be really slow…

To further illustrate what I want, here is an example:

Public Sub testDOMParser()
Dim parser As NotesDOMParser
Dim inStream As NotesStream
Dim node As NotesDOMDocumentNode
Set inStream = session.createStream()
Call inStream.open("c:\temp\test.xml")
Set parser = session.createDOMParser(inStream)
Call parser.process()
Set node = parser.document
Call serializeDocument(node)
End Sub
Public Sub serializeDocument(node As NotesDOMDocumentNode)
' Here, I want to do something like this:
Dim outStream As NotesStream
Dim parser As NotesDOMParser
Set outStream = session.createStream()
Set parser = session.createDOMParser(node, outStream)
parser.exitOnFirstFatalError = True
Call parser.serialize()
Print "Serialized tree: " + outStream.readText()
End Sub

Anyone who have had any experience with this and are willing to share their thoughts? We are talking R6 here…

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
(5) Comments    Read More   

Comments

Jeff Crossett on 11 January, 2006 at 20:14:07 #

Would setting the output of the parser to a NotesStream and using the “ReadText” method of the stream work for you?


Johan Känngård on 11 January, 2006 at 22:18:13 #

That’s what I’m doing in the example above, but it doesn’t work. It isn’t giving me an error either. :-(


Johannes on 16 January, 2006 at 07:11:32 #

Does it help if you use this ?

Set parser = session.createDOMParser(inStream, outputStream )

Must define outputStream though,
then no need to call serialize
once node is changed, then it is reflected in outputstream until it close command is called.

If I’m not mistaken, I had problem with serializing in LN 6.5.1


Johan Känngård on 16 January, 2006 at 10:17:53 #

But I don’t have access to the inStream, only a NotesDOMNode as in the example above.


guolw on 19 July, 2007 at 13:02:02 #

thank you It’s useful


Post a Comment
Name:
Email:
Website:
Comments: