Namespace: Consultingwerk.Util
Class 
XmlHelper Copy to Clipboard
Parent classes:
Inherits: Progress.Lang.Object

File:XmlHelper
Purpose:Provides supporting routines for XML Processing
Author(s):Mike Fechner / Consultingwerk Ltd.
Created:Thu Nov 08 16:17:13 CET 2012
Notes:Static methods only



Top Method Summary
Options Name Purpose
+ HANDLE ChildNodeByName (handle, character) Recursively locates a Node with the given name
+ HANDLE ChildNodeByNameAndAttributeValue (handle, character, character, character) Recursively locates a Node with the given name and attribute value
+ HANDLE ChildNodeByNameAndAttributeValues (handle, character, character[], character[]) Recursively locates a Node with the given name and attribute values
+ HANDLE ChildNodeByNameAndAttributeValuesCaseSensitive (handle, character, character[], character[]) Recursively locates a Node with the given name and attribute values
+ DecodeLineBreaks (handle) Recursively decodes line break characters CHR(10) and CHR(13)
+ EncodeLineBreaks (handle) Recursively encodes line break characters CHR(10) and CHR(13)
+ CHARACTER GetCharacterValueInNode (handle) Returns the CHARACTER Value of the Text node that is the first child of an XML Element
+ HANDLE GetChildByName (handle, character) Returns a X-NODEREF that points to the first child node of the given node with the given name
+ HANDLE GetChildByName (handle, character, integer) Returns a X-NODEREF that points to the first child node of the given node with the given name
+ HANDLE GetChildElement (handle, integer) Returns the n'th child node of type NODE
+ HANDLE GetChildNodeByNameAndAttributeValues (handle, character, ListNameValuePair) Locates a direct child node with the given name and attribute values
+ HANDLE GetChildNodeByNameAndAttributeValuesCaseSensitive (handle, character, ListNameValuePair) Locates a direct child node with the given name and attribute values
+ HANDLE GetChildNodeByPath (handle, character) Returns the child node by a path
+ LONGCHAR GetLongcharValueInNode (handle) Returns the LONGCHAR Value of the Text node that is the first child of an XML Element
+ HANDLE InsertElementNode (handle, character) Adds an Element node to a X-NODEREF
+ InsertNodeAttribute (handle, character, character) Inserts an Attribute Node to an exiting XML Node
+ HANDLE InsertTextNode (handle, character) Adds a Text node to a X-NODEREF
+ HANDLE InsertTextNode (handle, longchar) Adds a Text node to a X-NODEREF
+ HANDLE InsertTextNode (handle, raw) Adds a base64-encoded Text node for RAW value to a X-NODEREF
+ LOGICAL IsWellFormed (longchar) Verifies of the physical structure of the passed in Longchar is a valid (well-formed) XML Document
# NestNodeChildren (handle, integer, integer) Recursively nestst the child nodes
+ NestNodeElements (handle) Nests the children of the given XML Document
+ CHARACTER Sanitize (character) Sanitizes the passed in Character value as an XML Document
+ LONGCHAR Sanitize (longchar) Sanitizes the passed in Longchar value as an XML Document

Top Constructor Summary
Options Name Purpose
# XmlHelper () Constructor for the XmlHelper class


Method Detail
Top

PUBLIC HANDLE ChildNodeByName (handle, character)

Purpose: Recursively locates a Node with the given name
Notes: The caller is responsible for cleaning of the returned x-noderef

Parameters:
phParentNode HANDLE
The x-noderef of the parent node
pcNodeName CHARACTER
The name of the element
Returns HANDLE
The x-noderef representing the located node or ?
Top

PUBLIC HANDLE ChildNodeByNameAndAttributeValue (handle, character, character, character)

Purpose: Recursively locates a Node with the given name and attribute value
Notes: The caller is responsible for cleaning of the returned x-noderef

Parameters:
phParentNode HANDLE
The x-noderef of the parent node
pcNodeName CHARACTER
The name of the element
pcAttributeName CHARACTER
The name of the attribute
pcAttributeValue CHARACTER
The value of the attribute
Returns HANDLE
The x-noderef representing the located node or ?
Top

PUBLIC HANDLE ChildNodeByNameAndAttributeValues (handle, character, character[], character[])

Purpose: Recursively locates a Node with the given name and attribute values
Notes: The caller is responsible for cleaning of the returned x-noderef

Parameters:
phParentNode HANDLE
The x-noderef of the parent node
pcNodeName CHARACTER
The name of the element
pcAttributeNames CHARACTER
The array with names of the attributes
pcAttributeValues CHARACTER
The array with values of the attribute
Returns HANDLE
The x-noderef representing the located node or ?
Top

PUBLIC HANDLE ChildNodeByNameAndAttributeValuesCaseSensitive (handle, character, character[], character[])

Purpose: Recursively locates a Node with the given name and attribute values
Notes: The caller is responsible for cleaning of the returned x-noderef

Parameters:
phParentNode HANDLE
The x-noderef of the parent node
pcNodeName CHARACTER
The name of the element
pcAttributeNames CHARACTER
The array with names of the attributes
pcAttributeValues CHARACTER
The array with values of the attribute
Returns HANDLE
The x-noderef representing the located node or ?
Top

PUBLIC DecodeLineBreaks (handle)

Purpose: Recursively decodes line break characters CHR(10) and CHR(13)
Notes: Used to convert ABL line breaks from XML as created by the
EncodeLineBreaks method

Parameters:
phXmlDoc HANDLE
The handle of the X-DOCUMENT or X-NODEREF handle
Top

PUBLIC EncodeLineBreaks (handle)

Purpose: Recursively encodes line break characters CHR(10) and CHR(13)
Notes: Used to convert ABL line breaks for XML

Parameters:
phXmlDoc HANDLE
The handle of the X-DOCUMENT or X-NODEREF handle
Top

PUBLIC CHARACTER GetCharacterValueInNode (handle)

Purpose: Returns the CHARACTER Value of the Text node that is the first child
of an XML Element
Notes: Returns an Empty String when the node does not have a Text Child

Parameters:
phXmlNode HANDLE
The XML Element to return the text for
Returns CHARACTER
The CHARACTER Value
Top

PUBLIC HANDLE GetChildByName (handle, character)

Purpose: Returns a X-NODEREF that points to the first child node of the given
node with the given name
Notes: The caller is responsible for deleting the returned X-NODEREF

Parameters:
phParentNodeRef HANDLE
The X-NODEREF of the Parent
pcChildName CHARACTER
The name of the child node to be returned
Returns HANDLE
The X-NODEREF pointing to the requested child or ?
Top

PUBLIC HANDLE GetChildByName (handle, character, integer)

Purpose: Returns a X-NODEREF that points to the first child node of the given
node with the given name
Notes: The caller is responsible for deleting the returned X-NODEREF

Parameters:
phParentNodeRef HANDLE
The X-NODEREF of the Parent
pcChildName CHARACTER
The name of the child node to be returned
piNodeNum INTEGER
The minimum value for the node number to be retrieved (allows to retrieve the next sibling of a given node)
Returns HANDLE
The X-NODEREF pointing to the requested child or ?
Top

PUBLIC HANDLE GetChildElement (handle, integer)

Purpose: Returns the n'th child node of type NODE
Notes: Iterates through the child nodes, only counting the nodes with SUBTYPE = ELEMENT

Parameters:
phNode HANDLE
The parent X-NODEREF or X-DOCUMENT
piIndex INTEGER
The index of the ELEMENT node to return
Returns HANDLE
The X-NODEREF of the child element or ? when the piIndex is not valid
Top

PUBLIC HANDLE GetChildNodeByNameAndAttributeValues (handle, character, ListNameValuePair)

Purpose: Locates a direct child node with the given name and attribute values
Notes:

Parameters:
phParentNode HANDLE
The x-noderef of the parent node
pcNodeName CHARACTER
The name of the attribute
poAttributes Consultingwerk.ListNameValuePair
The list of attribute names and values
Returns HANDLE
The x-noderef representing the located node or ?
Top

PUBLIC HANDLE GetChildNodeByNameAndAttributeValuesCaseSensitive (handle, character, ListNameValuePair)

Purpose: Locates a direct child node with the given name and attribute values
Notes:

Parameters:
phParentNode HANDLE
The x-noderef of the parent node
pcNodeName CHARACTER
The name of the attribute
poAttributes Consultingwerk.ListNameValuePair
The list of attribute names and values
Returns HANDLE
The x-noderef representing the located node or ?
Top

PUBLIC HANDLE GetChildNodeByPath (handle, character)

Purpose: Returns the child node by a path
Notes: Performs an XPath-Like selection of an XML Node. Nodes are referenced
by the name or attributes or position in a set, e.g.:
/lm:eCafModel/lm:serviceCollection/lm:details eCafModel/lm:serviceCollection/lm:details
/lm:eCafModel/lm:serviceCollection/lm:details/lm:adapterDetails/lm:properties[2] eCafModel/lm:serviceCollection/lm:details/lm:adapterDetails/lm:properties[2]
/lm:eCafModel/lm:serviceCollection/lm:services/lm:details/lm:adapterDetails/lm:properties[2] eCafModel/lm:serviceCollection/lm:services/lm:details/lm:adapterDetails/lm:properties[2]
/lm:eCafModel/lm:serviceCollection/lm:services/lm:details/lm:adapterDetails/lm:properties/[2] eCafModel/lm:serviceCollection/lm:services/lm:details/lm:adapterDetails/lm:properties/[2]
/lm:eCafModel/lm:serviceCollection/lm:services[@displayName="api" eCafModel/lm:serviceCollection/lm:services[@displayName="api" and @id="api"][1]

Parameters:
phNode HANDLE
The x-noderef or x-document
pcPath CHARACTER
The node path
Returns HANDLE
The X-NODEREF referencing the selected node
Top

PUBLIC LONGCHAR GetLongcharValueInNode (handle)

Purpose: Returns the LONGCHAR Value of the Text node that is the first child
of an XML Element
Notes: Returns an Empty String when the node does not have a Text Child

Parameters:
phXmlNode HANDLE
The XML Element to return the text for
Returns LONGCHAR
The LONGCHAR Value
Top

PUBLIC HANDLE InsertElementNode (handle, character)

Purpose: Adds an Element node to a X-NODEREF
Notes: The caller is responsible for cleaning up the created X-NODEREF

Parameters:
phParentNode HANDLE
The parent X-NODEREF
pcNodeName CHARACTER
The name of the node to add to the parent X-NODEREF
Returns HANDLE
The Element X-NODEREF
Top

PUBLIC InsertNodeAttribute (handle, character, character)

Purpose: Inserts an Attribute Node to an exiting XML Node
Notes:

Parameters:
phParentNode HANDLE
The parent X-NODEREF
pcAttributeName CHARACTER
The name of the attribute to add to the parent X-NODEREF
pcAttributeValue CHARACTER
The value of the attribute to add to the parent X-NODEREF
Top

PUBLIC HANDLE InsertTextNode (handle, character)

Purpose: Adds a Text node to a X-NODEREF
Notes: The caller is responsible for cleaning up the created X-NODEREF

Parameters:
phParentNode HANDLE
The parent X-NODEREF
pcText CHARACTER
The text to add to the parent X-NODEREF
Returns HANDLE
The Text X-NODEREF
Top

PUBLIC HANDLE InsertTextNode (handle, longchar)

Purpose: Adds a Text node to a X-NODEREF
Notes: The caller is responsible for cleaning up the created X-NODEREF

Parameters:
phParentNode HANDLE
The parent X-NODEREF
plcText LONGCHAR
The text to add to the parent X-NODEREF
Returns HANDLE
The Text X-NODEREF
Top

PUBLIC HANDLE InsertTextNode (handle, raw)

Purpose: Adds a base64-encoded Text node for RAW value to a X-NODEREF
Notes: The caller is responsible for cleaning up the created X-NODEREF

Parameters:
phParentNode HANDLE
The parent X-NODEREF
prValue RAW
The RAW value to encode and add to the parent X-NODEREF
Returns HANDLE
The Text X-NODEREF
Top

PUBLIC LOGICAL IsWellFormed (longchar)

Purpose: Verifies of the physical structure of the passed in Longchar is a
valid (well-formed) XML Document
Notes:

Parameters:
pcXmlString LONGCHAR
The Xml String to varify
Returns LOGICAL
Logical value indicating if the value contains a well-formed XML document
Top

PROTECTED NestNodeChildren (handle, integer, integer)

Purpose: Recursively nestst the child nodes
Notes:

Parameters:
phNodeRef HANDLE
The x-noderef representing the currnet node
piIndent INTEGER
The number of space characters to insert at each level
piLevel INTEGER
The current node level
Top

PUBLIC NestNodeElements (handle)

Purpose: Nests the children of the given XML Document
Notes: Inserts text nodes

Parameters:
phDocument HANDLE
The x-document representing the XML document
Top

PUBLIC CHARACTER Sanitize (character)

Purpose: Sanitizes the passed in Character value as an XML Document
Notes:

Parameters:
pcXmlString CHARACTER
The Xml String to sanitize
Returns CHARACTER
The sanitized XML String
Top

PUBLIC LONGCHAR Sanitize (longchar)

Purpose: Sanitizes the passed in Longchar value as an XML Document
Notes:

Parameters:
pcXmlString LONGCHAR
The Xml String to sanitize
Returns LONGCHAR
The sanitized XML String


Constructor Detail
Top

PROTECTED XmlHelper ()

Purpose: Constructor for the XmlHelper class
Notes: Disallow instance creation



©2006-2019 Consultingwerk Ltd.         info@consultingwerk.de         http://www.consultingwerk.de       08.08.2019 23:58:01