Domino 9 und frühere Versionen > ND6: Entwicklung
RichText in RichText EINFÜGEN
eknori (retired):
Habe es mal ins LDD gepostet und, wie erhofft, eine Antwort von Stan Rogers erhalten.
https://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/024f2d5bde011f06852571630063abaf?OpenDocument
flaite:
Klasse. Ich hab mir auch jetzt ein bischen die Zähne ausgebissen.
Bin aber auch müde. Der hat auf jeden Fall etwas verstanden das ich nicht sehe.
Interessant.
bleib dran
Axel
flaite:
Sind in dem auf notes.net geposteten code Exporter/Importer auch NotesDOMParser Objekte?
Das glaub ich.
Kriegs aber z.Zt. nicht hin.
flaite:
Nö. Leider immer noch nicht.
Agent:
Options:
--- Code: ---Option Public
Option Declare
--- Ende Code ---
Declarations:
--- Code: ---Dim session As NotesSession
--- Ende Code ---
Initialize:
--- Code: ---Dim db As NotesDatabase
Dim inputStream As NotesStream
Dim docNode As NotesDOMDocumentNode
Dim domParser As NotesDOMParser
Dim Importer As NotesDOMParser
Dim rootElement As NotesDOMElementNode
Dim docList As NotesDOMNodeList
Dim node As NotesDOMNode
Dim newNode As NotesDOMNode
Dim nodeChildOfRTOne As NotesDOMNode
Dim nodeChildRichText As NotesDOMNode
Dim eNode As NotesDOMElementNode
Dim i As Integer
Dim origXML As String
Dim outputFile As String
Dim outputStream As NotesStream
Dim exporter As NotesDOMParser
origXML = "c:\temp\RichText.xml"
Set session = New NotesSession
Set db = session.CurrentDatabase
Set inputStream = session.CreateStream
inputStream.Open (origXML)
Set exporter=session.CreateDOMParser ()
Set domParser = session.CreateDOMParser()
Set Importer=session.CreateDOMParser ( inputStream)
outputFile = "c:\temp\RichTextNew.xml"
Set outputStream = session.CreateStream
outputStream.Open(outputFile)
' Set input for Exporter
'Set output for Exporter
'Set output for Parser
Call exporter.setInput(domParser)
Call exporter.setOutput(outputStream)
Call domParser.setInput(importer)
importer.Process
On Event PostDOMParse From domParser Call PlayWithDXLRoutine
Set docNode = domParser.Document
Set rootElement = domParser.Document.DocumentElement
Set docList = rootElement.GetElementsByTagName ( "item" )
If docList.NumberOfEntries = 0 Then
Messagebox "No <item> element nodes in file", , "Error"
Exit Sub
End If
For i = 1 To docList.NumberOfEntries
Set node = docList.GetItem( i )
Set enode = node
If enode.GetAttribute("name") = "RTONE" Then
Msgbox "found at position " & Cstr(i)
Stop
If enode.hasChildNodes Then
Set nodeChildOfRTOne = enode.FirstChild
While Not (nodeChildOfRTOne.isNull)
Msgbox nodeChildOfRTOne.NodeName & " vom Typ : " & Cstr(nodeChildOfRTOne.NodeType)
If nodeChildOfRTOne.NodeName = "richtext" Then
If nodeChildOfRtOne.hasChildNodes Then
Set nodeChildRichText = nodeChildOfRTOne.FirstChild
While Not (nodeChildRichText.IsNull)
'Msgbox "kind von <richtext>:" & nodeChildRichText.nodeName & " vom Typ: " & Cstr(nodeChildRichText.NodeType)
If nodeChildRichText.NodeName = "pardef" Then
Stop
Set newNode = docNode.CreateElementNode("NewElement")
Call nodeChildRichText.AppendChild(newNode)
End If
Set nodeChildRichText = nodeChildRichText.nextSibling
Wend
End If
End If
Set nodeChildOfRTOne = nodeChildOfRTOne.nextSibling
Wend
End If
End If
Next
Stop
--- Ende Code ---
Subroutine:
--- Code: ---Public Sub PlayWithDxlRoutine(domParser As NotesDomParser)
domParser.serialize
End Sub
--- Ende Code ---
2 files in c:\temp
RichText.xml und RichTextNew.xml
RichTextNew.xml kann einfach eine leere Datei sein.
RichText.xml
--- Code: ---<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE document SYSTEM 'xmlschemas/domino_7_0.dtd'>
<document xmlns='http://www.lotus.com/dxl' version='7.0' replicaid='C125715F002D73D1'
form='Sample'>
<noteinfo noteid='916' unid='7EE586C3D6B725CCC1257160004210E3' sequence='26'>
<created><datetime dst='true'>20060430T140136,99+02</datetime></created>
<modified><datetime dst='true'>20060501T143234,46+02</datetime></modified>
<revised><datetime dst='true'>20060501T143234,45+02</datetime></revised>
<lastaccessed><datetime dst='true'>20060501T143234,45+02</datetime></lastaccessed>
<addedtofile><datetime dst='true'>20060430T140144,62+02</datetime></addedtofile></noteinfo>
<updatedby><name>CN=Heinz Ulrich Krause/O=Witte/C=de</name></updatedby>
<revisions><datetime dst='true'>20060430T140144,62+02</datetime><datetime
dst='true'>20060430T140243,32+02</datetime><datetime dst='true'>20060430T140318,98+02</datetime><datetime
dst='true'>20060430T140350,65+02</datetime><datetime dst='true'>20060430T140423,73+02</datetime><datetime
dst='true'>20060430T144720,51+02</datetime><datetime dst='true'>20060430T153953,81+02</datetime><datetime
dst='true'>20060430T154101,45+02</datetime><datetime dst='true'>20060430T154103,21+02</datetime><datetime
dst='true'>20060430T154143,04+02</datetime><datetime dst='true'>20060430T154235,77+02</datetime><datetime
dst='true'>20060430T154437,24+02</datetime><datetime dst='true'>20060430T154904,73+02</datetime><datetime
dst='true'>20060430T155631,37+02</datetime><datetime dst='true'>20060430T160359,38+02</datetime><datetime
dst='true'>20060430T162002,11+02</datetime><datetime dst='true'>20060430T162040,60+02</datetime><datetime
dst='true'>20060430T162107,21+02</datetime><datetime dst='true'>20060430T163828,93+02</datetime><datetime
dst='true'>20060501T094942,46+02</datetime><datetime dst='true'>20060501T095028,39+02</datetime><datetime
dst='true'>20060501T101412,59+02</datetime><datetime dst='true'>20060501T104914,32+02</datetime><datetime
dst='true'>20060501T114738,49+02</datetime><datetime dst='true'>20060501T115259,27+02</datetime></revisions>
<item name='OriginalModTime'><datetime dst='true'>20060501T143234,44+02</datetime></item>
<item name='RTONE'>
<richtext>
<pardef id='1'/>
<par def='1'>TEST</par>
<par def='1'/>
<par def='1'><<RT:RTTWO>></par>
<par def='1'/>
<par def='1'>noch mehr Text</par>
</richtext>
</item>
<item name='RTTWO'><richtext>
<pardef id='2'/>
<par def='2'/></richtext></item>
<item name='TextField'><text/></item>
</document>
--- Ende Code ---
eknori (retired):
So, dank Stan Rogers habe ich es jetzt hinbekommen,
--- Zitat ---'DOMParser:
Option Declare
Dim domParser As NotesDOMParser
Dim exporter As NotesDXLExporter
Dim importer As NotesDXLImporter
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim dc As NotesDocumentCollection
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then
Messagebox "No document selected",, "No document"
Exit Sub
End If
Dim doc As NotesDocument
Set doc = dc.GetFirstDocument
Set exporter = session.CreateDXLExporter
Set domParser=session.CreateDOMParser
Set importer = session.CreateDXLImporter ( domParser, db )
importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
Call exporter.SetInput ( doc )
Call exporter.SetOutput ( domParser )
Call domParser.SetOutput ( importer )
On Event PostDOMParse From domParser Call PlayWithDXLRoutine
Call exporter.process
End Sub
Sub PlayWithDXLRoutine(Source As NotesDOMParser)
Dim eNode As NotesDOMElementNode
Dim cloneNode As NotesDOMNode
Dim i As Integer
Dim rootElement As NotesDOMElementNode
Dim docList As NotesDOMNodeList
Dim node As NotesDOMNode
Dim nodeChildOfRTOne As NotesDOMNode
Dim nodeChildRichText As NotesDOMNode
Dim parNode As NotesDOMElementNode
Set rootElement = domParser.Document.DocumentElement
Set docList = rootElement.GetElementsByTagName ( "item" )
If docList.NumberOfEntries = 0 Then : Exit Sub
For i = 1 To docList.NumberOfEntries
Set node = docList.GetItem( i )
Set enode = node
If enode.GetAttribute("name") = "RTONE" Then
If enode.hasChildNodes Then
Set nodeChildOfRTOne = enode.FirstChild
While Not (nodeChildOfRTOne.isNull)
If nodeChildOfRTOne.NodeName = "richtext" Then
If nodeChildOfRtOne.hasChildNodes Then
Set nodeChildRichText = nodeChildOfRTOne.FirstChild
While Not (nodeChildRichText.IsNull)
If nodeChildRichText.NodeName = "par" Then
Set parnode = nodeChildRichText
If ( Not parNode.FirstChild.IsNull ) Then ' skip NULL Values
If parnode.FirstChild.NodeValue = "RT:RTONE" Then
parnode.FirstChild.NodeValue = "Hallo Welt"
Msgbox "HEUREKA"
Else
End If
End If
End If
Set nodeChildRichText = nodeChildRichText.nextSibling
Wend
End If
End If
Set nodeChildOfRTOne = nodeChildOfRTOne.nextSibling
Wend
End If
End If
Next
Call Source.Serialize
End Sub
--- Ende Zitat ---
Der Code ersetzt alle Vorkommen von RT:RTONE im gewählten Dokument durch die ausdrucksstarken Worte "Hallo Welt". Beeindruckend ;D
Navigation
[0] Themen-Index
[#] Nächste Seite
[*] Vorherige Sete
Zur normalen Ansicht wechseln