Examining Namespaces and Classes
The class %XML.NamespacesOpens in a new tab provides two class methods that you can use to examine XML namespaces and the classes contained in them:
classmethod GetNextClass(namespace As %String,
class As %String) as %String
Returns the next class (alphabetically) after the given class, in the given XML namespace. This method returns null when there are no more classes.
classmethod GetNextNamespace(namespace As %String) as %String
Returns the next namespace (alphabetically) after the given namespace. This method returns null when there are no more namespaces.
In both cases, only the current Caché namespace is considered. Also, mapped classes are ignored.
For example, the following method lists the XML namespaces and their classes, for the current Caché namespace:
ClassMethod WriteNamespacesAndClasses()
{
Set ns=""
Set ns=##class(%XML.Namespaces).GetNextNamespace(ns)
While ns '=""
{
Write !, "The namespace ",ns, " contains these classes:"
Set cls=""
Set cls=##class(%XML.Namespaces).GetNextClass(ns,cls)
While cls '=""
{
Write !, " ",cls
Set cls=##class(%XML.Namespaces).GetNextClass(ns,cls)
}
Set ns=##class(%XML.Namespaces).GetNextNamespace(ns)
}
}
When executed in the Terminal, this method generates output like the following:
The namespace http://www.address.org contains these classes:
ElRef.NS.Address
GXML.AddressNS
MyApp4.Obj.Address
MyAppNS.AddressNS
Obj.Attr.Address
Obj.Ns.Address
Obj.Ns.AddressClass
The namespace http://www.doctor.com contains these classes:
GXML.DoctorNS
The namespace http://www.one.org contains these classes:
GXML.AddressNSOne
GXML.DoctorNSOne
GXML.PersonNSOne
...