Implementing xsd:choice

Right now I'm trying to write some Java code that parses an XML schema and produces XForms.  (Chiba has a tool called Schema2XForms Builder, but it doesn't implement all of the xsd elements that my company's application requires).  I have a solution to implementing xsd:choice, but it's memory requirements can explode exponentially when choices are nested.
 
The solution I'm currently implementing involves an instance structure that is basically as follows:
<myFavoriteLetter>
  <CHOICE>
    <a>
    <b>
    <c>
  <CHOICE>
  <CHOICE_RELEVANT>3</CHOICE_RELEVANT>
</myFavoriteLetter>
 
The choices are inside the <CHOICE> tag, and then I used a binding element to indicate which choice is relevant.  In turn, only the controls pertaining the that choice are displayed on the form.  The index number inside of the <CHOICE_RELEVANT> tag is changed by binding it to an XForms select1 control - each choice is labeled by the element name of the choice.  Later I will flatten the instance data by removing the the CHOICE and CHOICE_RELEVANT tags (as well as other tags that I use for similar purposes) to wind up with something like the following:
<myFavoriteLetter>
  <c>
</myFavoriteLetter>

 
Is there a better way to do this, or am I stuck with exponential space requirements?
 
Chris

		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
--0-1861306899-1129522336=:89808
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<DIV>Right now I'm trying to write some Java code that parses an XML schema and produces XForms.&nbsp; (Chiba has a tool called Schema2XForms Builder, but it doesn't implement all of the xsd elements that my company's application requires).&nbsp; I have a solution to implementing xsd:choice, but it's memory requirements&nbsp;can explode exponentially when choices are nested.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The solution I'm currently implementing involves an instance structure that is basically as follows:</DIV>
<DIV>&lt;myFavoriteLetter&gt;</DIV>
<DIV>&nbsp; &lt;CHOICE&gt;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; &lt;a&gt;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; &lt;b&gt;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; &lt;c&gt;</DIV>
<DIV>&nbsp; &lt;CHOICE&gt;</DIV>
<DIV>&nbsp; &lt;CHOICE_RELEVANT&gt;3&lt;/CHOICE_RELEVANT&gt;</DIV>
<DIV>&lt;/myFavoriteLetter&gt;</DIV>
<DIV>&nbsp;</DIV>
<DIV>The choices are&nbsp;inside the &lt;CHOICE&gt; tag, and then I used a binding element to indicate which choice is relevant.&nbsp; In turn, only the controls pertaining the that choice are displayed on the form.&nbsp; The index number inside of the &lt;CHOICE_RELEVANT&gt; tag&nbsp;is changed by binding it to an XForms select1 control - each choice is labeled by the element name of the choice.&nbsp; Later I will flatten the instance data by removing the the CHOICE and CHOICE_RELEVANT tags (as well as other tags that I use for similar purposes) to wind up with something like the following:</DIV>
<DIV>
<DIV>&lt;myFavoriteLetter&gt;</DIV>
<DIV>&nbsp;&nbsp;&lt;c&gt;</DIV>
<DIV>&lt;/myFavoriteLetter&gt;</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>Is there a better way to do this, or am I stuck with exponential space requirements?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Chris</DIV><p>
		<hr size=1> <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/">Yahoo! Music Unlimited - Access over 1 million songs. Try it free.</a>
--0-1861306899-1129522336=:89808--

Received on Monday, 17 October 2005 04:22:28 UTC