Loop Tag

X-Application Version: 3.1.2
Tamino Version : 3.1.1
Platform : Win2k
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

I am getting the following error when trying to use the loop tag:
Root cause:
ApplicationException: 999: Application Error! Please contact the X-Application-Team.
com.softwareag.xtools.xapplication.common.PreconditionViolation
the node ‘/Schedules’ does not contain a sub-node identified by the content ‘BalancedSchedule’

I have attached the code from my jsp below…

<bdm:module id=“bdProp”>
<bdm:form module=“bdProp”>
<bdm:directcommand type=‘read’ docid=‘Schedules[@ino:id=2]’ />
</bdm:form>







<bdm:loop module=“bdProp” select=“/Schedules” iterate=“BalancedSchedule” targetbase=“bs”>





</bdm:loop>
Day Interval Type
<bdm:display select=“DAY” /> <bdm:display select=“INTERVAL” /> <bdm:display select=“TYPE” />

</bdm:module>

My document looks like this:


20021027
0015
ENE
<RESOURCE_MW>2822</RESOURCE_MW>
007931728
<PROVIDER_TY>QSE</PROVIDER_TY>
HOUSTON2002
0


20021027
0015
ENE
<RESOURCE_MW>1625</RESOURCE_MW>
007931728
<PROVIDER_TY>QSE</PROVIDER_TY>
NORTH2002
0



I also get an error for invalid attribute if I specify pagesize.
Any ideas?
Thanks, Carl

Hello Carl,

could you post your Schema or the type definition of the element ‘Schedules’?

Then, I can check if owr algorithm to find occurrences has a bug.

Thank you,
Christian.

Thanks, Carl
Schedules.tsd (4.3 KB)

Hello,

with the loop tag of X-Application you can iterate multiplicities (child element / sub-structures with maxOccurs > 1) of a selected node. The iteration is schema-oriented.

In your case a multiplicity is defined for the choice node. In this way you can iterate the alternatives of the choice. In your case the alternatives are
‘BalancedSchedule ResourcePlan’.

The loop for the choice can be defined in the following form:

<xapp:loop select="/Schedules" iterate="BalancedSchedule ResourcePlan" ...>
  ...
</xapp:loop>
</pre><BR><BR>The context node within the loop is the virtual choice node (structure node). If you want to display only the 'BalancedSchedule' nodes, filter the choice nodes via the choice tag:<BR><BR><pre class="ip-ubbcode-code-pre">
<xapp:loop ...>
  <xapp:choice select="." type="BalancedSchedule>
     <tr bgcolor="#DDDDDD" align="left">
     <td width="150"><bdm:display select="./BalancedSchedule/DAY" /></td>
     <td width="300"><bdm:display select="./BalancedSchedule/INTERVAL" /></td>
     <td width="200"><bdm:display select="./BalancedSchedule/TYPE" /></td>
  </xapp:choice>
</xapp:loop>



For choices, we have also a simple examples. If you installed X-Application and started Tomcat, the simple expamles should be accessible via

http://localhost:8080/xapp/simple

There is an example called ‘Choice’.

Bye,
Christian.

Christian,
Thanks…Works Great.
Carl

Christian,
I have changed the schema to incorporate some additional information. I want the additional information to be direct children of the root node “Schedules”. I have updated my schema (see attached), but I am getting the same error I did before with the value “BalancedSchedule ResourcePlan” entered into iterate. What must I change so I can loop through the BalancedSchedule(s) for each document?
Thanks, Carl
Schedulesa.tsd (5.81 KB)

Hello Carl,

when using the ‘iterate’ attribute you must define all the elements which identify an anonymous structure node.

Your anonymous structure node is the choice. It has no name like an element. To identify it, you must add all of its (possible) elements:

<xapp:loop select="/Schedule" 
           iterate="BallancedSchedue ResourcePlan HTIMESTAMP HCoNTEXT HQSECODE HACTION" 
           document="..." targetbase="...">
  <xapp:choice select="." type="BallancedSchedule">
    <xapp:display select="./BallancedSchedule/Day />
    ...
  </xapp:choice>
</xapp:lopp>
</pre><BR><BR>Another way is, to use the 'extselect' attribute of the loop tag instead of the 'iterate' attribute. The 'extselect' expects a "structure path". The documentation contains a chapter about this topic ("Schema Based Operations"). <BR><BR><pre class="ip-ubbcode-code-pre">
<xapp:loop select="/Schedule" extselect="xapp:occ(1)" document="..." targetbase="...">
  <xapp:choice select="." type="BalancedSchdule">
  ...
  </xapp:choice>
</xapp:loop>
</pre><BR><BR>What you can do also is to omit 'iterate' as well as 'extselect'. This is possible because the sequence / choice of the complexType has a multiplicity.<BR><BR><pre class="ip-ubbcode-code-pre">
<xapp:loop select="/Schedule" targetbase="..." document="...">
  <xapp:choice select="." type="BalancedSchedule">
    ...
  </xapp:choice>
</xapp:loop>



All these solutions are schema-based. They have nothing to do with XPath expression where you can define a node set.

Currently, we are looking for a more efficient XPath support where you can define a node set via XPath and this set is the base for an iteration.

Hope, this explantation helps you to solve your problem.

Bye,
Christian.