I'm trying to project a series of objects and nested objects to XML, and I'm having difficulties getting the XML representation exactly the way I need it to be. Here's what I'm working with, nothing complicated:
Class XMLTest Extends (%RegisteredObject, %XML.Adaptor)
{
Property Id As Id
}
Class Id Extends (%RegisteredObject, %XML.Adaptor)
{
Property Value As %String (XMLPROJECTION = "attribute")
}
By default it seem closing tags are used with all elements, as such:
<XMLTest>
<Id Value="D1949EE1-7D03-4666-9548-D1A949E10327"></Id>
</XMLTest>
Whereas I need these elements represented with just the forward slash terminator:
<XMLTest>
<Id Value="D1949EE1-7D03-4666-9548-D1A949E10327"/>
</XMLTest>
Is there a way to configure the XML writer to achieve this, or a property declaration I can use?
Another question I have is around the structure of the classes that are to be projected, rather than the above main snippet, is it possible to use XML projection declarations to define that a simple property is an element with attributes and values? This would be a lot more convenient than creating classes just to hold their attribute values. For example something like:
Class XMLTest Extends (%RegisteredObject, %XML.Adaptor)
{
Property Id As %String (XMLPROJECTION = "element", XMLATTRIBUTE = "value")
}
Any help is much appreciated.
Thanks