Hi, I’m attempting to process a document to remove the green borders around hyperlinks, using a pipeline to export the dxl, modify it with the DOM Parser and then reimport it. I’ve got to the stage where it works on all documents except those containing apostrophes. Same problem as reported here:
Any suggestions for a fix or workaround gratefully received, this is driving me crazy!
Here’s the code so far:
Sub removeBorders(doc As NotesDocument)
REM: run doc through DOM Parser to remove the green borders around link hotspots
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim exporter As NotesDXLExporter
Dim importer As NotesDXLImporter
Dim domParser As NotesDOMParser
REM : Export current document as DXL and pipeline into DOMParser then DXL importer
Set exporter = session.CreateDXLExporter(doc)
Set domParser=session.CreateDOMParser(exporter)
REM: xml modification occurs in PostDOMParse event
On Event PostDOMParse From domParser Call processDOM
Set importer = session.CreateDXLIMporter(domParser, db)
REM: reimport the modified DXL, replacing the original doc
importer.DocumentImportOption = DXLIMPORTOPTION_UPDATE_ELSE_IGNORE
Call exporter.process
End Sub
Sub processDOM(Source As NotesDOMParser)
Dim docNode As NotesDOMDocumentNode
Set docNode = Source.Document
REM: walkTree is called recursively to navigate the DOM
REM: it locates "showborder" attribute in the "doclink" element and changes its value to false
Call walkTree(docNode)
REM: output the modified DXL to NotesDXLImporter
Call Source.Serialize
End Sub
Sub walkTree (node As notesdomnode)
Dim child As notesdomnode
Dim elt As notesdomelementnode
Dim numChildNodes As Integer
Dim numChildren As Integer
If Not node.IsNull Then
Select Case node.NodeType
Case DOMNODETYPE_DOCUMENT_NODE:
Set child = node.FirstChild
numChildNodes = node.NumberOfChildNodes
While numChildNodes > 0
Set child = child.NextSibling
numChildNodes = numChildNodes - 1
Call walkTree(child)
Wend
Case DOMNODETYPE_ELEMENT_NODE:
Set elt = node
If elt.NodeName = "doclink" Then Call elt.SetAttribute("showborder", "false")
numChildren = elt.NumberOfChildNodes
Set child = elt.FirstChild
While numChildren > 0
Call walkTree(child)
Set child = child.NextSibling
numChildren = numChildren - 1
Wend
End Select
End If
End Sub