Jostein Ulseth

XML ID/IDREF problem when integrating with .Net (BA 6.5.3-Net)

Discussion created by Jostein Ulseth on Feb 11, 2009



Environment: BA 6.5.3-Net, and using .Net 3.5.


The situation:  

I have created an Xml Bom that serves as the shared domain between the rules services and the application, and to ease the pain of Xml, I have also used the xsd.exe tool to generate class definitions for my schema.


In my schema I have a type ('Item') that is hierarchical. An Item may have 0 or more Items as children. I have solved this using attributes of type ID/IDREF. In BA, this is represented as an Item having an array of XmlObjectHandle, which is derived from an attribute or element definition whose type is xsd:IDREF. So far, all according to the documentation.


The problem:

I am unable to reconcile how BA and xsd.exe handles IDREF/IDREFS.


My first attempt was to create an element in Item like this;

<xs:element Name="Children" type="xs:IDREF" minOccurs="0" maxOccurs="unbounded" />


This is recognized by BA as the aforementioned array of XmlObjectHandle, and I am able to write SRL that appends object references to the array.


The problem with this approach is that the Xml returned from the rules service is not valid according to the Schema. The array of child elements is returned as an attribute, i.e. something like this:

<Item Children="C1 C2" ...>


This is obviously not valid, as "Children" is declared as an element (array element). The parser on the .Net side also informs me of this...


So, to fix this, I tried instead to declare Children like this:

<xs:complexType name="Item" ...>


  <xs:attribute name="Children" type="xs:IDREFS" />



Short note: The reason for using IDREFS is the array part. I also tried to follow the documentation that states that the array declaration should look like this in the schema:

<xs:attribute name="Children" type="xs:IDREF" minOccurs="0" />


But this is not a valid type/attribute definition. minOccurs is not usable in that context, so IDREFS it is (which is an array/list of IDREF).


The problem with the attribute of type IDREFS is that now, nothing is returned from the rules service. It still compiles, but the returned Xml document does not contain the children added to the Item.


Does anyone have a solution to this? I would obviously prefer that my rules service generates valid Xml. In addition to that, I would also prefer that I can solve this using one and only one schema, not one for .Net and not one for BA...


Solutions or suggestions are most welcome!