Skip to main content

%XML.ImportHandler

class %XML.ImportHandler extends %XML.SAX.ContentHandler

SAX Content handler for Cache' Objects XML Implementation.

This class and the data structure defined here is used internally by Caché. You should not make direct use of this class or data structure within your applications. The global data structure may be accessed using the macros in %xmlDOM.inc or by using the %XML.Node class. There is no guarantee made about either the behavior or future operation of this class.

This content handler stores the XML document as nodes of a tree. The GlobalName property determines where these nodes are stored. The default for the GlobalName property is ^||%xmlTemp. The Tree property determines the specific node used to store the nodes of the tree. The structure of the tree is as follows:

The tree is stored @..GlobalName@(..Tree) which is stored in ..DocumentId. @..GlobalName@(..Tree) - number of nodes. @i%DocumentId@(node) describes the node given by the integer node number.

Each XML DOM node will be described by a 4 character entry node descriptor.
Since any node will be the child of an element node, the node descriptor entries will be
stored in the childlist of its parent which is in the element descriptor node or one of its extension nodes.  
The attribute nodes will be first in the element descriptor node in the order that they are 
presented by Xerces.  Element and character node entries follow in the XML document order.
Each element descriptor is limited to the maximum length Cache string.  
Thus provision is made for extension child lists.
The list of element and character nodes is terminated by a next descriptor node which is
a reference to the next extension or 0 for the last.
Each element descriptor node and element descriptor extension node is structured as follows:
@i%DocumentId@(node) is 28 character base followed by the list of node descriptors. @i%DocumentId@(node) = CLparent_CLoffset_name_(prefix|flags)_elementOffset_URI_line_column_ChildList CLparent($zlchar) is the node number of the parent's child list which contains this node's descriptor. CLoffset($zlchar) is the 1-based offset in characters in CLparent node of this node's descriptor. name ($zlchar) - index of element name in the name dictionary. prefix($zlchar\16) - index of the prefix part of the QName (including ':') in the name dictionary or 0 if no prefix If the qname and the unqualified name are the same, then the prefix is not present. flags($zlchar#16) right-most bit (1) if xsi:nil or xsi:null specified as true or 1 second bit (2) is skip flag elementOffset($zwchar) is the offset of the first child element in the child list. This value is 29+(numAttrs*16) for the first child list and 29 for all subsequent child lists. URI($zwchar) is index of the URI for this element or not stored. line($zlchar) part of the location for element node. column($zlchar) part of the location for element node. ChildList is list of attribute, element and character entries. A document node is introduced which represents the document and has as its child the root element of the document. Node 0 is the document node and node 1 is the child list for the document node. @i%DocumentId@(0) = documentBase_documentChildlist @i%DocumentId@(1) = rootElementDescriptor documentBase: $zlchar(0,0,0,0,0)_$zwchar(29,0)_$zlchar(0,0) documentChildList: $zlchar(16) i.e 1 shifted left 4 rootElementDescriptor: $zlchar(0,0,0)_name_prefix_elementOffset_URI_line_column name, URI, prefix, elementOffset, line, column refer to the root element. See below for definition of element descriptor. There are 4 types of node descriptors: attribute, element, character and next. The attribute node descriptor (length 16): name_prefix_URI_valueURI_value name($zlchar) is the attribute name prefix($zlchar) - index of the prefix (including ':') in the name dictionary or 0 if no prefix URI($zwchar) - index of the namespace URI for this attriibute or 0 if no namespace. valueURI($zwchar) - index of the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value". value($zlchar) - index of the value of the attribute in the name dictionary The element node descriptor: elementDescriptor|type elementDescriptor($zlchar\16) is the node number of the elementDescriptor for this element. type($zlchar#16) of the node: 0 for element The character node descriptor: valueindex|type valueindex($zlchar\16) - data dictionary index of character value of the node. type($zlchar#16) of the node: 1 for character data or 2 for character data that is only whitespace. The next node descriptor: next|type next($zlchar\16) - index of next element descriptor extension. type($zlchar#16) of the node: 3 for next element descriptor. Errors and warnings are returned as follows. The SAX parser also returns immediately following a fatal error with an error status: @i%DocumentId@(type)=count where type is "fatalerror", "error" or "warning". @i%DocumentId@(type,index)=message Elements with "id" attributes are indexed as follows: @i%DocumentId@("i",id)=CLparent_","_CLoffset id is the value of "id" atribute CLparent is the node number of the parent's child list which contains this node's descriptor. CLoffset is the 1-based offset in characters in CLsub node of this node's descriptor. The name dictionary used in this XML document is maintained as: @i%DocumentId@("d")=the number of names, values, or prefixes including ':' used by this XML document. @i%DocumentId@("d",index)=name Reverse "D" name to index is only used for COS codde added names. Not for names added by Xerces parser. @i%DocumentId@("D",name)=index where name is a name or prefix and index is the integer index used for this name. The list of namespaces used in this XML document is maintained as: @i%DocumentId@("n")=the number of namespaces used by this XML document. @i%DocumentId@("n",index)=namespace @i%DocumentId@("N",namespace)=index where namespace is the the uri for a namespace and index is the integer index used for this namespace in the "u" and "v" nodes above. @i%DocumentId@("N","http://www.w3.org/2001/XMLSchema-instance")=1 and @i%DocumentId@("n",1)="http://www.w3.org/2001/XMLSchema-instance" are always true to allow easy lookup of the schema instance namespace: "http://www.w3.org/2001/XMLSchema-instance" The version of the internal content handler is given by a single integer in @i%DocumentId@("v")=version integer -- currently 4

Method Inventory

Methods

method AddIDs()
Adds the elements with ID attribute to the id table.
method CopyDocument() as %String
Make a copy of the document to another node in the same global. Return the document id of the copy.
method GetNextId(ByRef id As %String) as %String
Gets the next id for this document based on the id table and returns in id argument. The nodeid for the rewturned id is the return value.
classmethod KillDocument(documentId)
Kill the document specified by the documentId argument
classmethod SerializeBase64Node(tree As %Integer, node As %Integer, outputStream As %Boolean, ByRef data, hex As %Boolean = 0, baseChildlist As %String) as %Boolean
Serialize the base64 encoded text children of this node as text.
tree is the id of the ML document tree.
node is the id of the node to be serialized.
outputStream is true if the serialized output is to be sent to to the existing stream data.
outputStream is false if the serialized output is to be be appended to the string data. data is created if it is not already defined.
classmethod SerializeNode(tree As %String, node As %String, outputStream As %Boolean, mixed As %Integer = 0, ByRef data, includeTop As %Boolean = 0, lineMode As %Boolean = 0, baseChildlist As %String) as %Boolean
Serialize the children of this node as text.
tree is the id of the ML document tree.
node is the id of the node to be serialized.
outputStream is true if the serialized output is to be sent to to the existing stream data.
outputStream is false if the serialized output is to be be appended to the string data. data is created if it is not already defined.
mixed is true if child elements should be serialized, else an error is returned if child elements are found. mixed=1 uses XML translate table. mixed=2 uses HTML translate table.
includeTop is true if the containing element should be included in the returned output.
lineMode is true if the stream output should be written in line oriented mode, else the stream output will be written as a continuous block.

Inherited Members

Inherited Methods

Subclasses

FeedbackOpens in a new tab