Public Member Functions | |
Close () | |
Close and cleanup the XML.Document. More... | |
Correlate (_.Library.String element, _.Library.String class, _.Library.String namespace) | |
Correlate() defines an XML Element to class correlation. More... | |
CorrelateRoot (_.Library.String class) | |
CorrelateRoot defines the root element to be correlated to the specified. More... | |
_.Library.Integer | Next (_.Library.ObjectHandle oref, _.Library.Status sc, _.Library.String namespace) |
Get and return the next object. More... | |
_.Library.Status | OpenFile (_.Library.String xmlsource, _.Library.String format) |
Import XML source from a file using XML.Document. | |
_.Library.Status | OpenStream (_.Library.AbstractStream xmlsource, _.Library.String format) |
Import XML source from a stream object using XML.Document. | |
_.Library.Status | OpenString (_.Library.String xmlsource, _.Library.String format) |
Import XML source from a string using XML.Document. | |
_.Library.Status | OpenURL (_.Library.String xmlsource, _.Library.String format, _.Net.HttpRequest httprequest) |
Import XML source from a URL using XML.Document. More... | |
Rewind () | |
Restart reading at the beginning of the XML document. More... | |
![]() | |
_.Library.Status | OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount) |
This callback method is invoked when the current object is added to the SaveSet,. More... | |
_.Library.Status | OnClose () |
This callback method is invoked by the <METHOD>Close</METHOD> method to. More... | |
_.Library.Status | OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned) |
This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More... | |
_.Library.Status | OnNew () |
This callback method is invoked by the <METHOD>New</METHOD> method to. More... | |
_.Library.Status | OnValidateObject () |
This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More... | |
Public Attributes | |
CheckRequired | |
Checking the existence of REQUIRED properties is off by default in XML.Reader. More... | |
Document | |
The XML.Document that holds the parsed XML document. More... | |
EntityResolver | |
This property should be set to an instance of XML.SAX.EntityResolver OR a user-defined. More... | |
Format | |
The format of the XML document: "literal", "encoded" or "encoded12". More... | |
IgnoreNull | |
The runtime specification of the XMLIGNORENULL parameter to XML.Adaptor. More... | |
IgnoreSAXWarnings | |
If true (1), then any warnings from the SAX parser will be not be reported and ignored. More... | |
Node | |
Current node in tree representation of XML document. More... | |
SAXFlags | |
This property should be set to a combination of flags (see occSAX.inc for details) if. More... | |
SAXMask | |
The SAXMask property is kept for compatibility only. More... | |
SAXSchemaSpec | |
This property specifies the schema specifications that should be used when validating the. More... | |
SSLConfiguration | |
The name of the activated TLS/SSL configuration to use for https requests. More... | |
Summary | |
If true (1), then only the summary fields should be imported by the XML.Adaptor. More... | |
UsePPGHandler | |
If UsePPGHandler is true (1), then force document parsing to use PPG memory. More... | |
Private Attributes | |
__OpenFormat | |
The internal format to be used for XMLImport. More... | |
Additional Inherited Members | |
![]() | |
CAPTION = None | |
Optional name used by the Form Wizard for a class when generating forms. More... | |
JAVATYPE = None | |
The Java type to be used when exported. | |
PROPERTYVALIDATION = None | |
This parameter controls the default validation behavior for the object. More... | |
For details on using this class, see Importing XML into Objects.
The sample class mentioned here (Sample.Person) is part of https://github.com/intersystems/Samples-Data. See Downloading Samples.
A usage example follows:
#include occStatus // Create a new XML Reader class Set reader = ##class(XML.Reader).New()
// Begin processing of the XML input Set sc=reader.OpenFile(filename) If $$$ISERR(sc) Do $system.OBJ.DisplayError(sc) Quit
// Associate a class name with the XML element name Do reader.Correlate("Person","Sample.Person")
// read Sample.Person objects from xml file Set Count=0 While reader.Next(.person,.sc) { Write person.Name_" imported.",! Set Count=Count+1 Set sc=person.Save() If $$$ISERR(sc) Do $system.OBJ.DisplayError(sc) Quit
}
If $$$ISERR(sc) Do $system.OBJ.DisplayError(sc) Quit
Write Count_" Sample.Person instances found."
Close | ( | ) |
Close and cleanup the XML.Document.
This method is included for
backward compatibility. The XML.Document will be cleaned up anyway during object cleanup.
Correlate | ( | _.Library.String | element, |
_.Library.String | class, | ||
_.Library.String | namespace | ||
) |
Correlate() defines an XML Element to class correlation.
Any
elements encountered by Next() that are in the correlation table will cause the correlated class to be instantiated and its XMLImport method to be called with the current XML node passed as a parameter. Further examination of child nodes is skipped for correlated elements.
Matching of elements is based on the element name that is specified in the element argument. If the namespace argument is also specified, then the XML namespace of the element must also match.
CorrelateRoot | ( | _.Library.String | class | ) |
CorrelateRoot defines the root element to be correlated to the specified.
class. The root element when encountered by Next() will cause the correlated class to be instantiated and its XMLImport method to be called with the root XML node passed as a parameter. Further examination of child nodes is skipped for correlated elements.
_.Library.Integer Next | ( | _.Library.ObjectHandle | oref, |
_.Library.Status | sc, | ||
_.Library.String | namespace | ||
) |
Get and return the next object.
<method>Next</method> returns 1 (true), if the next object matching one of the Correlate criteria is found and successfully imported.
<method>Next</method> returns 0 (false) and a Status of $$$OK in sc after all objects have been imported.
<method>Next</method> returns 0 (false) and an error Status in sc, if an error has occurred importing this object.
The namespace argument indicates the default namespace for this XML file.
_.Library.Status OpenURL | ( | _.Library.String | xmlsource, |
_.Library.String | format, | ||
_.Net.HttpRequest | httprequest | ||
) |
Import XML source from a URL using XML.Document.
If httprequest argument is specified, then this will be used as the Net.HttpRequest object to open the URL.
To open https URLs: set reader=##class(XML.Reader).New() set httprequest=##class(Net.HttpRequest).New() set httprequest.SSLConfiguration="...." set status=reader.OpenURL("https://.....",,httprequest)
Rewind | ( | ) |
Restart reading at the beginning of the XML document.
All correlations are cleared and Correlate must be called again for the required elements.
CheckRequired |
Checking the existence of REQUIRED properties is off by default in XML.Reader.
To turn on REQUIRED property checking. set the CheckRequired property to 1 (default is 0).
EntityResolver |
This property should be set to an instance of XML.SAX.EntityResolver OR a user-defined.
subclass IF the default EntityResolver is not required
Format |
The format of the XML document: "literal", "encoded" or "encoded12".
This parameter may be overriden by the Open... format parameter.
IgnoreNull |
The runtime specification of the XMLIGNORENULL parameter to XML.Adaptor.
<property>IgnoreNull</property> specifies the value of XMLIGNORENULL at runtime as either 0, 1 or inputonly.
IgnoreNull="inputonly" is equivalent to IgnoreNull=1.
IgnoreSAXWarnings |
If true (1), then any warnings from the SAX parser will be not be reported and ignored.
Current node in tree representation of XML document.
Note that 0 means the document itself, i.e. the parent of the root element.
|
private |
The internal format to be used for XMLImport.
This property is set during Open.
SAXFlags |
This property should be set to a combination of flags (see occSAX.inc for details) if.
the default behavior of the parser is required to be modified
SAXMask |
The SAXMask property is kept for compatibility only.
The best mask is now computed
and this property ignored.
SAXSchemaSpec |
This property specifies the schema specifications that should be used when validating the.
document. See XML.SAX.Parser for a full description of this property.
SSLConfiguration |
The name of the activated TLS/SSL configuration to use for https requests.
by the entity resolver.
Summary |
If true (1), then only the summary fields should be imported by the XML.Adaptor.
UsePPGHandler |
If UsePPGHandler is true (1), then force document parsing to use PPG memory.
If UsePPGHandler is false (0), then force document parsing to use local array memory. If UsePPGHandler is not set ( or = ""), then use default memory – usually local array memory.