Форум продуктов IBM Lotus
Общие вопросы => Разработка приложений => Тема начата: GlooMMy от 11 Март 2010, 16:33:04
-
Из базы создаю *.dxl файл. Он получается довольно большой.
Как сделать чтобы создавалось несколько файлов? Разбивать на файлы например в зависимости от значения атрибута form
Например есть исходный файл:
<?xml version="1.0" ?>
<database>
<document form="form1">
...
</document>
<document form="form2">
...
</document>
<document form="form1">
...
</document>
</database>
чтобы не создавать такой документ, как сделать чтобы было для данного случая два таких
1:
<?xml version="1.0" ?>
<database>
<document form="form1">
...
</document>
<document form="form1">
...
</document>
</database>
2:
<?xml version="1.0" ?>
<database>
<document form="form2">
...
</document>
</database>
Или может даже лучше будет для каждого form создавать новый файл.
Агент создания файла *.dxl
(Declarations):
Dim domParser As NotesDOMParser
Dim LF As String
Initialize:
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim inputStream As NotesStream, outputStream As NotesStream
Dim docNode As NotesDOMDocumentNode
Dim outputFile As String
outputFile = "c:\dxl\dxlhelloworld_dom.xml"
On Error Goto errh
Set session = New NotesSession
Set db = session.CurrentDatabase
'Create the output file
Set outputStream = session.CreateStream
outputStream.Open (outputFile)
outputStream.Truncate
'Build a NoteCollection to limit the export file to documents
Dim nc As NotesNoteCollection
Set nc = db.CreateNoteCollection(False)
nc.SelectDocuments=True
Call nc.BuildCollection
'Create the DXL exporter
Dim exporter As NotesDXLExporter
Set exporter = session.CreateDXLExporter(nc)
exporter.OutputDOCTYPE = False
'Create DOM parser and process
Set domParser = session.CreateDOMParser(exporter, outputStream)
domParser.AddXMLDeclNode = True
exporter.Process
'Get the document node
Set docNode = domParser.Document
Call walkTree(docNode)
results:
Call outputStream.Close
Exit Sub
errh:
outputStream.WriteText ("errh: "+Cstr(Err)+": "+Error+LF)
Resume results
End Sub
walkTree:
Sub walkTree ( node As NotesDOMNode )
Dim child As NotesDOMNode
Dim attrs As NotesDOMNamedNodeMap
Dim a As NotesDOMAttributeNode
Dim piNode As NotesDOMProcessingInstructionNode
LF = Chr(13) + Chr(10)
If Not node.IsNull Then
Select Case node.NodeType
Case DOMNODETYPE_DOCUMENT_NODE: 'It's the Document node
Set child = node.FirstChild 'Get first node
Dim numChildNodes As Integer
numChildNodes = node.NumberOfChildNodes
'Create an XML declaration for the output
Dim xNode As NotesDOMXMLDeclNode
Set xNode = node.FirstChild
domParser.Output({<?xml version="} + xNode.Version + {" ?>})
'Get the number of children of Document,
'and call walkTree for the first child
While numChildNodes > 0
Set child = child.NextSibling 'Get next node
numChildNodes = numChildNodes - 1
Call walkTree(child)
Wend
Case DOMNODETYPE_DOCUMENTTYPE_NODE: 'It's a <!DOCTYPE> tag
domParser.Output({Document Type node: } + node.NodeName + LF)
Case DOMNODETYPE_TEXT_NODE: 'It's a plain text node
If node.NodeValue <> Chr(10) Then
domParser.Output(node.NodeValue)
End If
Case DOMNODETYPE_ELEMENT_NODE: 'Most nodes are Element nodes
If node.NodeName = "databaseinfo" Then
Exit Sub
End If
If node.NodeName = "noteinfo" Then
Exit Sub
End If
If node.NodeName = "revisions" Then
Exit Sub
End If
If node.NodeName = "updatedby" Then
Exit Sub
End If
domParser.Output({<} + node.NodeName)
Dim numAttributes As Integer, numChildren As Integer
numAttributes = node.attributes.numberofentries
Set attrs = node.Attributes 'Get attributes
Dim i As Integer
For i = 1 To numAttributes 'Loop through attributes
Set a = attrs.GetItem(i)
domParser.Output({ }+a.NodeName + {="} + a.NodeValue + {"})
Next
domParser.Output(">")
numChildren = node.NumberOfChildNodes
Set child = node.FirstChild 'Get child
While numChildren > 0
Call walkTree(child)
Set child = child.NextSibling 'Get next child
numChildren = numChildren - 1
Wend
domParser.Output( {</} + node.nodeName + {>} + LF)
Case DOMNODETYPE_COMMENT_NODE: 'It's a Comment
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case DOMNODETYPE_PROCESSINGINSTRUCTION_NODE: 'It's a PI node
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case DOMNODETYPE_CDATASECTION_NODE: 'It's a CDATA section
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case DOMNODETYPE_ENTITYREFERENCE_NODE: 'It's an entity
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case Else:
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
End Select
End If
End Sub
ps:
может все просто, но чет я туплю ???