User bio
404 bio not found
Member since Jul 25, 2017
Replies:

I'm not sure, do I understand you correctly... 
If you had a class and copied that class to a new class with some more properties, something like this

Class DC.OldData Extends %Persistent
{
Property FirstName As %String;
Property LastName As %String;

/// Redirect the %Open(), %OpenId() to the new class
///
ClassMethod %OnDetermineClass(oid As %ObjectIdentity, ByRef class As %String) As %Status [ ServerOnly = 1 ]
{
	Set class="DC.NewData"
	Quit $$$OK
}

/// Prevent creating a new instance of the old class
Method %OnNew() As %Status [ Private, ServerOnly = 1 ]
{
	Quit '$$$OK
}
}

Class DC.NewData Extends %Persistent
{
Property FirstName As %String;
Property LastName As %String;
Property MartialStatus As %String;
}

Assuming, your XML stream never has more  then MAXSTRING characters AND if you can live with a "quick-and-dirty" solution then try this one

Class DC.XML.abc Extends (%RegisteredObject, %XML.Adaptor)
{
Property def As %String;
Property ghi As %String;
Property jkl As jkl;
ClassMethod Test(str)
{
    if $isobject(str) { set:str.Rewind() xml=str.Read(str.Size) } else { set xml=str }
    for{set i=$f(xml,"<![CDATA[",$g(i)) q:'i
        set j=$f(xml,"]]>",i) zt:'j "XMLE"
        set $e(xml,j-3,j-1)="", $e(xml,i-9,i-1)="", i=i-9
    }
    
    set rdr=##class(%XML.Reader).%New()
    if 'rdr.OpenString(xml) write "OpenErr",! quit
    do rdr.Correlate("abc","DC.XML.abc")
    while rdr.Next(.abc,.st) { zzdo abc }
}
}

Class DC.XML.jkl Extends (%RegisteredObject, %XML.Adaptor)
{
Property mno As mno;
}

Class DC.XML.mno Extends (%RegisteredObject, %XML.Adaptor)
{
Property pqr As %String;
Property stu As %String;
}

And some tests...

set s1="<abc><def>010203</def><ghi>040506</ghi><jkl><mno><pqr>070809</pqr><stu>101112</stu></mno></jkl></abc>"
set s2="<abc><def>010203</def><ghi>040506</ghi><jkl><![CDATA[<mno><pqr>070809</pqr><stu>101112</stu></mno>]]></jkl></abc>"
do ##class(DC.XML.abc).Test(s1)
def................................: 010203
ghi................................: 040506
jkl.mno.pqr........................: 070809
jkl.mno.stu........................: 101112
do ##class(DC.XML.abc).Test(s2)
def................................: 010203
ghi................................: 040506
jkl.mno.pqr........................: 070809
jkl.mno.stu........................: 101112

Note: the above ZZDO command takes an oref as argument and prints it, you can replace it with a simple zw oref.

Certifications & Credly badges:
Julius has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Following:
Julius has not followed anybody yet.