Hi,
I dont know if i m right here.
I ve a question. I am editing a XML-File with vb6 but winmerge and the programm where the file needs to be reimported are telling me that the files arent the same.
I dont see why. Maybe someone of you can figure something out. :-)
I m posting the used code and the first few lines of an accepted xml file and the one I am creating.
This is the code:
These are the first few Lines where the Error has to be due to the report i get from the program. :-)
This is the accepted Xml-File
This is the one I m creating:
Best regards Sascha
EDIT: For the programm it doesnt matter if i use Spaces or tabstops in front of the rows. I tried it by manipulationg the accepted file to its worst. ;-)
EDIT2: It doesnt matter whether i write Ln1_21DistanceProt1 or Ln1_5051OC1pole1. This is just the storage place of the Dataset.
I dont know if i m right here.
I ve a question. I am editing a XML-File with vb6 but winmerge and the programm where the file needs to be reimported are telling me that the files arent the same.
I dont see why. Maybe someone of you can figure something out. :-)
I m posting the used code and the first few lines of an accepted xml file and the one I am creating.
This is the code:
Code:
Public Sub xXMLW (Manufacturer As String,FilePath As String,Goose As Variant)
On Error GoTo ErrorHandler
Dim xDoc As MSXML2.DOMDocument
Dim DataSetNode As MSXML2.IXMLDOMElement
Dim DataSet As MSXML2.IXMLDOMElement
Dim GooseData As MSXML2.IXMLDOMElement
Dim HitemList As IXMLDOMNodeList
Dim HitemNode As MSXML2.IXMLDOMElement
Dim Communication As MSXML2.IXMLDOMElement
Dim GSECommunication As MSXML2.IXMLDOMElement
Dim GSEAddress As MSXML2.IXMLDOMElement
Dim GSEMinTime As MSXML2.IXMLDOMElement
Dim GSEMaxTime As MSXML2.IXMLDOMElement
Dim P As MSXML2.IXMLDOMElement
Dim PrivateNode As MSXML2.IXMLDOMElement
Dim GSE As MSXML2.IXMLDOMElement
Dim inst As String
Dim ENameNew As String
Dim ENameOld As String
inst = Goose.GooseData(0).AValue(0)
i = 0
Set xDoc = New MSXML2.DOMDocument
'xDoc.createProcessingInstruction("xml-stylesheet","type='text/xml' href='test.xsl'")
'-->Prooves whether the document is a valid XML Document.
xDoc.validateOnParse = True
'-->DTD = Document Type Definition
If xDoc.load(FilePath) = False Then
MsgBox ("Unable to load File.",vbExclamation,OCC)
Else
If Manufacturer = "SIEMENS" Then
Set HitemList = xDoc.documentElement.selectNodes("//History/Hitem")
'For Each HitemNode In HitemList
' ENameOld = Right(HitemNode.getAttribute("what"), Len(HitemNode.getAttribute("what")) - InStrRev(HitemNode.getAttribute("what"), " "))
' ENameNew = "GOOSE_" & ENameOld
' HitemNode.setAttribute("what","Exported as " & ENameNew)
' HitemNode.setAttribute("why","Exported as " & ENameNew)
'Next
Set Communication = xDoc.selectSingleNode("//ConnectedAP")
Set PrivateNode = AddNode(True,xDoc,Communication,"Private",False,0)
CreateAttribute(PrivateNode,"type","Siemens-Application-GSEControl")
CreateText(xDoc,PrivateNode,"GOOSE application|" & inst & "|Control_Dataset")
Set PrivateNode = AddNode(True,xDoc,Communication.parentNode,"Private",False,1)
CreateAttribute(PrivateNode,"type","Siemens-Application")
CreateText(xDoc,PrivateNode,"GOOSE application||0001||PriorityLow||10|2000|000|4")
Set GSECommunication = AddNode(False,xDoc,Communication,"GSE",True)
CreateAttribute(GSECommunication,"ldInst", inst)
CreateAttribute(GSECommunication,"cbName","Control_Dataset")
Set GSEAddress = AddNode(False,xDoc,GSECommunication,"Address",False)
Set P = AddNode(False,xDoc,GSEAddress,"P",False)
CreateText(xDoc,P,"000")
CreateAttribute(P,"type","VLAN-ID")
CreateAttribute(P,"xsi:type","tP_VLAN-ID")
Set P = AddNode(False,xDoc,GSEAddress,"P",False)
CreateText(xDoc,P,"4")
CreateAttribute(P,"type","VLAN-PRIORITY")
CreateAttribute(P,"xsi:type","tP_VLAN-PRIORITY")
Set P = AddNode(False,xDoc,GSEAddress,"P",False)
CreateText(xDoc,P,"01-0C-CD-01-00-00")
CreateAttribute(P,"type","MAC-Address")
CreateAttribute(P,"xsi:type","tP_MAC-Address")
Set P = AddNode(False,xDoc,GSEAddress,"P",True)
CreateText(xDoc,P,"0001")
CreateAttribute(P,"type","APPID")
CreateAttribute(P,"xsi:type","tP_APPID")
Set GSEMinTime = AddNode(False,xDoc,GSECommunication,"MinTime",False)
CreateText(xDoc,GSEMinTime,"10")
CreateAttribute(GSEMinTime,"unit","s")
CreateAttribute(GSEMinTime,"multiplier","m")
Set GSEMaxTime = AddNode(False,xDoc,GSECommunication,"MaxTime",True)
CreateText(xDoc,GSEMaxTime,"1000")
CreateAttribute(GSEMaxTime,"unit","s")
CreateAttribute(GSEMaxTime,"multiplier","m")
Set DataSetNode = xDoc.selectSingleNode("//LDevice[@inst = '" & inst & "']/LN0")
Set DataSet = AddNode(True,xDoc,DataSetNode,"DataSet",False,1)
CreateAttribute(DataSet,"name","Dataset")
Set GSE = AddNode(False,xDoc,DataSetNode,"GSEControl",True)
CreateAttribute(GSE,"name","Control_Dataset")
CreateAttribute(GSE,"appID","PrivateGoose")
CreateAttribute(GSE,"confRev","1")
CreateAttribute(GSE,"type","GOOSE")
CreateAttribute(GSE,"datSet","Dataset")
Do While Goose.GooseData(i).EndReached <> True
For k = 0 To 1
j = 0
Set GooseData = AddNode(False,xDoc,DataSet,"FCDA",False)
Do While Goose.GooseData(i).AName(j) <> ""
CreateAttribute(GooseData,Goose.GooseData(i).AName(j),Goose.GooseData(i).AValue(j))
j = j+1
Loop
If k = 0 Then
GooseData.setAttribute("daName","general")
Else
GooseData.setAttribute("daName","q")
End If
Next
i = i+1
Loop
ElseIf Manufacturer = "ABB" Then
End If
xDoc.Save(FilePath)
MsgBox("GOOSE succesfully written to: " & vbNewLine & Right(FilePath, Len(FilePath) - InStrRev(FilePath, "\")),vbInformation,OCC)
End If
Set GooseNode = Nothing
Set xDoc = Nothing
ErrorHandler:
Resume Next
End Sub
Private Function AddNode(Insert As Boolean, xDoc As DOMDocument, ParentNode As IXMLDOMElement, NodeName As String,Last As Boolean, Optional cNode As Integer) As MSXML2.IXMLDOMElement
Dim Node As MSXML2.IXMLDOMNode
Dim Spaces As String
Dim SpacesTotal As String
Dim CountNode As MSXML2.IXMLDOMElement
Dim Root As MSXML2.IXMLDOMElement
Dim level As Integer
Set CountNode = ParentNode
Set Root = xDoc.selectSingleNode("//SCL")
level = 0
Spaces = " "
SpacesTotal = ""
Do
Set CountNode = CountNode.parentNode
level = level + 1
Loop Until CountNode.nodeName = Root.nodeName
'Add the node to the document
Set Node = xDoc.createNode(NODE_ELEMENT,NodeName,"")
If Insert = True Then
Set AddNode = ParentNode.insertBefore(Node,ParentNode.childNodes.Item(cNode))
ParentNode.insertBefore(xDoc.createTextNode(vbNewLine),Node)
ParentNode.insertBefore(xDoc.createTextNode(vbNewLine),Node.nextSibling)
For i = 0 To level
ParentNode.insertBefore(xDoc.createTextNode(Spaces),Node)
ParentNode.insertBefore(xDoc.createTextNode(Spaces),Node.nextSibling.nextSibling)
Next
Else
ParentNode.appendChild(xDoc.createTextNode(vbNewLine))
For i = 0 To level
ParentNode.appendChild(xDoc.createTextNode(Spaces))
Next
Set AddNode = ParentNode.appendChild(Node)
If Last = True Then
For i = 0 To level-1
SpacesTotal = SpacesTotal & Spaces
Next
ParentNode.appendChild(xDoc.createTextNode(vbNewLine & SpacesTotal))
End If
End If
Set AddNode = Node
Set Node = Nothing
End Function
Private Sub CreateAttribute(Node As IXMLDOMNode, Name As String, Value As String)
Dim tNode As IXMLDOMElement
Set tNode = Node
tNode.setAttribute(Name, Value)
Set tNode = Nothing
End Sub
Private Sub CreateText(xDoc As DOMDocument,Node As IXMLDOMNode,Value As String)
Dim TextNode As MSXML2.IXMLDOMNode
Set TextNode = xDoc.createTextNode(Value)
Node.appendChild(TextNode)
End Sub
This is the accepted Xml-File
Code:
<?xml version="1.0" encoding="UTF-8"?>
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iec.ch/61850/2003/SCL SCL.xsd" version="2007" revision="B">
<Private type="Siemens-DIGSI5ExportComment"></Private>
<Header id="BachelorThesis" revision="1" version="5" toolID="DIGSI 5 V3.0">
<History>
<Hitem version="1" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Monday, August 19, 2013, 9:11:29 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
<Hitem version="2" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Monday, August 19, 2013, 9:25:31 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
<Hitem version="3" revision="1" what="File Siprotec_7SL87_Goose.cid imported." when="Monday, August 19, 2013, 9:48:22 AM" why="File Siprotec_7SL87_Goose.cid imported."/>
<Hitem version="4" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Monday, August 19, 2013, 11:42:16 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
<Hitem version="5" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Tuesday, August 20, 2013, 11:28:24 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
</History>
</Header>
<Communication>
<SubNetwork name="Default_subnet">
<Private type="Siemens-MasterId">69007239544833</Private>
<Private type="Siemens-Application">GOOSE application||0001||PriorityLow||10|2000|000|4</Private>
<ConnectedAP iedName="SIP3" apName="F">
<Private type="Siemens-Application-GSEControl">GOOSE application|Ln1_5051OC1pole1|Control_Dataset</Private>
<Address>
<P type="IP" xsi:type="tP_IP">10.16.60.60</P>
<P type="IP-SUBNET" xsi:type="tP_IP-SUBNET">255.255.255.0</P>
<P type="OSI-AP-Title">1,3,9999,23</P>
<P type="OSI-AE-Qualifier">23</P>
<P type="OSI-PSEL">00000001</P>
<P type="OSI-SSEL">0001</P>
<P type="OSI-TSEL">0001</P>
</Address>
<GSE ldInst="Ln1_5051OC1pole1" cbName="Control_Dataset">
<Address>
<P type="VLAN-ID" xsi:type="tP_VLAN-ID">000</P>
<P type="VLAN-PRIORITY" xsi:type="tP_VLAN-PRIORITY">4</P>
<P type="MAC-Address" xsi:type="tP_MAC-Address">01-0C-CD-01-00-00</P>
<P type="APPID" xsi:type="tP_APPID">0001</P>
</Address>
<MinTime unit="s" multiplier="m">10</MinTime>
<MaxTime unit="s" multiplier="m">2000</MaxTime>
</GSE>
</ConnectedAP>
</SubNetwork>
</Communication>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iec.ch/61850/2003/SCL SCL.xsd" version="2007" revision="B">
<Private type="Siemens-DIGSI5ExportComment"></Private>
<Header id="BachelorThesis" revision="1" version="5" toolID="DIGSI 5 V3.0">
<History>
<Hitem version="1" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Monday, August 19, 2013, 9:11:29 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
<Hitem version="2" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Monday, August 19, 2013, 9:25:31 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
<Hitem version="3" revision="1" what="File Siprotec_7SL87_Goose.cid imported." when="Monday, August 19, 2013, 9:48:22 AM" why="File Siprotec_7SL87_Goose.cid imported."/>
<Hitem version="4" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Monday, August 19, 2013, 11:42:16 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
<Hitem version="5" revision="1" what="Exported as Siprotec_7SL87_Goose.cid." when="Tuesday, August 20, 2013, 11:28:24 AM" why="Exported as Siprotec_7SL87_Goose.cid."/>
</History>
</Header>
<Communication>
<SubNetwork name="Default_subnet">
<Private type="Siemens-MasterId">69007239544833</Private>
<Private type="Siemens-Application">GOOSE application||0001||PriorityLow||10|2000|000|4</Private>
<ConnectedAP iedName="SIP3" apName="F">
<Private type="Siemens-Application-GSEControl">GOOSE application|Ln1_21DistanceProt1|Control_Dataset</Private>
<Address>
<P type="IP" xsi:type="tP_IP">10.16.60.60</P>
<P type="IP-SUBNET" xsi:type="tP_IP-SUBNET">255.255.255.0</P>
<P type="OSI-AP-Title">1,3,9999,23</P>
<P type="OSI-AE-Qualifier">23</P>
<P type="OSI-PSEL">00000001</P>
<P type="OSI-SSEL">0001</P>
<P type="OSI-TSEL">0001</P>
</Address>
<GSE ldInst="Ln1_21DistanceProt1" cbName="Control_Dataset">
<Address>
<P type="VLAN-ID" xsi:type="tP_VLAN-ID">000</P>
<P type="VLAN-PRIORITY" xsi:type="tP_VLAN-PRIORITY">4</P>
<P type="MAC-Address" xsi:type="tP_MAC-Address">01-0C-CD-01-00-00</P>
<P type="APPID" xsi:type="tP_APPID">0001</P>
</Address>
<MinTime unit="s" multiplier="m">10</MinTime>
<MaxTime unit="s" multiplier="m">1000</MaxTime>
</GSE>
</ConnectedAP>
</SubNetwork>
</Communication>
EDIT: For the programm it doesnt matter if i use Spaces or tabstops in front of the rows. I tried it by manipulationg the accepted file to its worst. ;-)
EDIT2: It doesnt matter whether i write Ln1_21DistanceProt1 or Ln1_5051OC1pole1. This is just the storage place of the Dataset.