Skip to main content

%XML.Utils.InspectSAXTree

Class %XML.Utils.InspectSAXTree

Support Utility to review contents of SAXTree independently from XML Writer functionality.
Provides convenience methods ParseFile, ParseString, ParseStream and ParseXData for common support situations. Alternatively the method "OutputTree" can be called directly for additional scenarios.

Parameters

Indent

Parameter Indent = 1;

lblElement

Parameter lblElement = "e";

Display name used to indicate an element type

lblAttribute

Parameter lblAttribute = "a";

Display name used to indicate an attribute type

lblWhiteSpaceNode

Parameter lblWhiteSpaceNode = "wsn";

Display name used to indicate a whitespace node type

lblTextNode

Parameter lblTextNode = "txt";

Display name used to indicate a text node type

lblRAWNode

Parameter lblRAWNode = "raw";

Display name used to indicate a raw node type

NewLine

Parameter NewLine = {$C(13,10)};

pad

Parameter pad = "                                                                                    ";

Methods

OutputTree

ClassMethod OutputTree(ByRef xmlGbl = "", docSequence = 0, nodeId = 0, outstream As %CharacterStream = {$$$NULLOREF}, dumpBinary = 0) [ PublicList = %SAX ]

xmlGbl = %SAX variable passed by reference Support user entry point Parameters:

  • xmlGbl - Optional. The name of the local global being used to hold a SAX tree.
    If not supplied this will default to %SAX global
  • docSequence - Optional. The %SAX global (or alternative global) first key is an incrementing sequence for each XML document deserialized into XML Nodes. ie: %SAX(docSequence)
    If not supplied the highest document id incremented is assumed to be the current one of interest.
  • nodeId - Optional. The starting point in the SAX Tree to start analysis from. Typically would want to walk the whole document tree from 0.
  • outstream - Optional. If not supplied when the tool is run it will output to default device, for example the window of an interactive terminal session. Alternatively an open file stream can be passed in and output will be written to the file.
  • dumpBinary - Optional. Some additional presentation of binary SAX tree portion that may be of value. Example to output to terminal session (or other default device): do ##class(Util.SAXDebugWriter).OutputTree() Example to output to a file: Set stream=##class(%FileBinaryStream).%New() set stream.Filename="c:\tmp\SAXDebug"_msgId_"LoadedSimple.txt" do ##class(Util.SAXDebugWriter).OutputTree(,simpleDocId,,.stream) do stream.%Save() do stream.%Close()

DumpBinaryTree

ClassMethod DumpBinaryTree(ByRef xmlGbl = "", docId = "", outstream As %Stream.Object = {$$$NULLOREF})

Optional binary tree walking Normal operation would be to invoke OutputTree method instead. Parameters:

  • xmlGbl - Required. Pass local global by reference, being used to hold a SAX tree. eg: .%SAX
  • docId - Required. The %SAX global (or alternative global) first key is an incrementing sequence for each XML document deserialized into XML Nodes.
    ie: for %SAX(docId) would pass first key docId
  • outstream - Optional. If not supplied when the tool is run it will output to default device, for example the window of an interactive terminal session. Alternatively an open file stream can be passed in and output will be written to the file.

DumpBinaryNode

ClassMethod DumpBinaryNode(ByRef xmlGbl = "", docId = 1, nodeId = 0, outstream As %Stream.Object) [ Internal ]

Currently only working for %SAX

PadTxt

ClassMethod PadTxt(val, pad) [ CodeMode = expression, Internal ]

TreeInternal

ClassMethod TreeInternal(DocId, NodeId, baseChildlist, indent = -2, outstream As %Stream.Object) [ Internal, PublicList = (xmlGbl, %SAX) ]

Recursive output nodes Repurpose of %XML.Writer method implementation for TreeInternal

FormatText

ClassMethod FormatText(data, empty = "<<EMPTY STRING>>") [ Internal ]

Covert non-printable and formating whitespace into ZWRITE style format
Allows some visibility and understanding of non-printing and formatting characters

Constant ValuePrints as
"ABC""ABC"
$C(10,13)_"ABC"$C(10,13)_"ABC"
"DEF"_$C(10,13)_"ABC""DEF"_$C(10,13)_"ABC"
"DEF"_$C(1,2,3)_"G"_$C(4,5,6,7,8,9)_"ABC""DEF"_$C(1,2,3)_"G"_$C(4,5,6,7,8,9)_"ABC"

ParseFile

ClassMethod ParseFile(inputFilePath As %String, outputFilePath As %String = "", dumpBinary = 0) As %Status

For a given filepath Read in file as XML and output the corresponding SAX Tree structure Parameters:

  • inputFilePath - Required. The name of a local file containing XML.
  • outputFilePath - Optional. The name of a local file containing XML.
  • dumpBinary - Optional. To include additional and alternative view of content. Example to explore an XML file and print output to default device set tSC=##class(%XML.Utils.InspectSAXTree).ParseFile(inputFilePath) do $SYSTEM.Status.DisplayError(tSC) Example to explore an XML file and print output report to file. set tSC=##class(%XML.Utils.InspectSAXTree).ParseFile(inputFilePath,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)

ParseString

ClassMethod ParseString(xmlString As %String = "", outputFilePath As %String = "", dumpBinary As %Boolean = 0) As %Status

For a given string containing XML. Read in XML and output the corresponding SAX Tree structure Parameters:

  • xmlString - Required. String containing well formed XML data.
  • outputFilePath - Optional. The name of a local file containing XML.
  • dumpBinary - Optional. To include additional and alternative view of content. Example to explore a string of XML content and print output to default device set myxmlstring="some data</root" set tSC=##class(%XML.Utils.InspectSAXTree).ParseString(myxmlstring) do $SYSTEM.Status.DisplayError(tSC) Example to explore a string of XML content and print output report to file. ` set tSC=##class(%XML.Utils.InspectSAXTree).ParseStream(myxmlstream,outputFilePath) do $SYSTEM.Status.DisplayError(tSC) `

ParseStream

ClassMethod ParseStream(xmlstream, outputFilePath As %String = "", dumpBinary As %Boolean = 0) As %Status

For a given stream containing XML. Read in XML and output the corresponding SAX Tree structure Parameters:

  • xmlstream - Required. Stream containing well formed XML data.
  • outputFilePath - Optional. The name of a local file containing XML.
  • dumpBinary - Optional. To include additional and alternative view of content. Example to explore a stream of XML content and print output to default device set tSC=##class(%XML.Utils.InspectSAXTree).ParseStream(myxmlstream) do $SYSTEM.Status.DisplayError(tSC) Example to explore an XData block and print output report to file. set tSC=##class(%XML.Utils.InspectSAXTree).ParseStream(myxmlstream,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)

ParseXData

ClassMethod ParseXData(xdataclass = "", xdataname = "", outputFilePath As %String = "", dumpBinary As %Boolean = 0) As %Status

For a given Class XData Block. Read in XData content as XML and output the corresponding SAX Tree structure Parameters:

  • xdataclass - Required. Compiled classname with XData to review.
  • xdataname - Required. The name of XData block to review.
  • outputFilePath - Optional. The name of a local file containing XML.
  • dumpBinary - Optional. To include additional and alternative view of content. Example to explore an XData block and print output to default device set tSC=##class(%XML.Utils.InspectSAXTree).ParseXData(myclassname,xdataname) do $SYSTEM.Status.DisplayError(tSC) Example to explore an XData block and print output report to file. set tSC=##class(%XML.Utils.InspectSAXTree).ParseXData(myclassname,xdataname,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)