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

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…


Comments:
Jeff Crossett on January 11th, 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 January 11th, 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 January 16th, 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 January 16th, 2006 at 10:17:53 #

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

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

thank you It’s useful

Post a comment
Name: 
Email: 
URL: 
Comments: