Extending and compiling with XMLEnable issue
Hello All,
I hope it's not a silly question.
Here is my issue:
I have 3 simple classes:
Parent class, let's say:
Class ParentClass Extends %RegisteredObject
{
Property a As %String;
}
and two children classes
Class A.Child Extends ParentClass
{
Property b As %String;
}
Class B.Child Extends ParentClass
{
Property c As %String;
}
So no issues - all compiles and seem to work.
But, when I add %XML.Adaptor to my parent class, so:
Class ParentClass Extends (%RegisteredObject, %XML.Adaptor)
{
Property a As %String;
}
I can no longer compile any of the three classes involved and I get this error:
---------------------------
Studio
---------------------------
ERROR #6281: XMLTYPE of class A.Child must be able to differentiate child classes of ParentClass.
> ERROR #5090: An error has occurred while creating projection ParentClass:XMLEnabled.
---------------------------
OK
---------------------------
Please advice if there is a way to workaround this error, or if it's simply cannot work with %XML.Adaptor.
Thank you,
Alex
Comments
Alex,
add Parameter
Parameter XMLTYPE = "A_CHILD";
to one of your child classes
inherited comment is somewhat vague:
/// This parameter provides the default XMLTYPE for the class. If it is
/// empty then the class name will be used to construct a default XML type.
///
/// The default XMLTYPE is used when naming and referencing this type
/// in a schema and the schema context did not provide an XML type name.
documentation is more precise:
For an XML-enabled class or a property that is based on an XML-enabled class, the XML type is determined as follows:
If the class has a value for the XMLTYPE parameter, that is used as the type name.
Otherwise, the short class name is taken as the XML type name.
so you would have 2 different classes with the same type: CHILD
that's not allowed in an XML schema they have to be unique.
It's one of the rather hard to follow rules in XML that converted me into a fan of JSON
Thank you Robert.
That worked, and thank you very much for the explanation. I would not guess something like this. Great to know,
Alex