%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.
Method Inventory
Parameters
parameter Indent = 1;
parameter NewLine;
parameter lblAttribute = a;
Display name used to indicate an attribute type
parameter lblElement = e;
Display name used to indicate an element type
parameter lblRAWNode = raw;
Display name used to indicate a raw node type
parameter lblTextNode = txt;
Display name used to indicate a text node type
parameter lblWhiteSpaceNode = wsn;
Display name used to indicate a whitespace node type
parameter pad = ;
Methods
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.
classmethod OutputTree(ByRef xmlGbl="", docSequence=0, nodeId=0, outstream As %CharacterStream = $$$NULLOREF, dumpBinary=0)
xmlGbl = %SAX variable passed by reference
Support user entry point
Parameters:
Example to output to a file:
- 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.
do ##class(Util.SAXDebugWriter).OutputTree()
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()
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:
Example to explore an XML file and print output report to file.
- 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.
set tSC=##class(%XML.Utils.InspectSAXTree).ParseFile(inputFilePath) do $SYSTEM.Status.DisplayError(tSC)
set tSC=##class(%XML.Utils.InspectSAXTree).ParseFile(inputFilePath,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)
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:
Example to explore an XData block and print output report to file.
- 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.
set tSC=##class(%XML.Utils.InspectSAXTree).ParseStream(myxmlstream) do $SYSTEM.Status.DisplayError(tSC)
set tSC=##class(%XML.Utils.InspectSAXTree).ParseStream(myxmlstream,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)
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:
Example to explore a string of XML content and print output report to file.
- 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.
set myxmlstring="<root><test>some data</test></root" set tSC=##class(%XML.Utils.InspectSAXTree).ParseString(myxmlstring) do $SYSTEM.Status.DisplayError(tSC)
set tSC=##class(%XML.Utils.InspectSAXTree).ParseStream(myxmlstream,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)
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:
Example to explore an XData block and print output report to file.
- 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.
set tSC=##class(%XML.Utils.InspectSAXTree).ParseXData(myclassname,xdataname) do $SYSTEM.Status.DisplayError(tSC)
set tSC=##class(%XML.Utils.InspectSAXTree).ParseXData(myclassname,xdataname,outputFilePath) do $SYSTEM.Status.DisplayError(tSC)