The AppendAttribs subroutine takes its parameters from the following call in the GetNodeValue subroutine:
Call AppendAttribs(elem, lXML.nodeFromID(elem.Attributes(count).nodeValue))
The current element becomes copyToNode and the expression lXML.nodeFromID(elem.Attributes(count).nodeValue), which evaluates to the element that has the same LID as the current element, becomes copyFromNode. The copyToNode value is passed as an IXMLDOMElement object so that the setAttribute method can be used; this method is not available from the IXMLDOMNode object.
Next, the code iterates through the attributes in the node. The setAttribute method copies each attribute and value from the node in lingo.xml into the corresponding node in the XML template file. The following code illustrates this process:
Private Sub AppendAttribs(ByRef copyToNode As IXMLDOMElement, ByRef copyFromNode As IXMLDOMNode)
Dim count As Integer
Dim index As Integer
Dim childNode As IXMLDOMNode
Dim checkNode As IXMLDOMNode
' count = 0 is ID mapped with LID on form -- skip it
For count = 1 To copyFromNode.Attributes.length - 1
copyToNode.setAttribute copyFromNode.Attributes(count).nodeName, _
copyFromNode.Attributes(count).nodeValue
Next
After the code loops through the attributes in the node, it checks for child nodes. Elements in lingo.xml contain child nodes that are used to mark up the values contained in them when the globalized XML template files are saved as HTML. For example, some elements contain a character embedded in <u></u> tags used to indicate an access key.
The code uses hasChildNodes to determine whether the copyFromNode element contains further nodes. If it does, the code determines whether the node contains children and copies the hierarchy of child nodes to the globalized XML template file with cloneNode if it does. The following code illustrates this process:
If copyFromNode.hasChildNodes Then
'In case labels have <U> tag to identify accesskey
If copyFromNode.childNodes.length > 1 Then
For index = 0 To copyFromNode.childNodes.length - 1
Set checkNode = copyFromNode.childNodes(index)
Set childNode = checkNode.cloneNode(True)
copyToNode.appendChild childNode
Next
If the code does not detect child nodes, it creates a text node in the XML template document object (gXML). This action inserts the text value from lingo.xml (lXML) into a text node in the XML template file. The following code illustrates this process:
Else
'creates textNode and appends to global XML template file
Set childNode = gXML.createTextNode(copyFromNode.Text)
copyToNode.appendChild childNode
End If
End If
End Sub
The following code fragments illustrate the input and output of this function. This code contains a node from a globalized XML template file:
<LABEL class="LabelBold" LID="lbl76"></LABEL>
Here is the corresponding node in lingo.xml:
<LABEL LID="lbl76"><U>F</U>irst Name:</LABEL>
Here is the element that results from the processing in the AppendAttribs subroutine:
<label class="LabelBold" LID="lbl76"><u>F</u>irst Name:</label></td>