logo back up home forward   further reading more topics »

XES - Programmers Guide - nodeLoop

For information about XES schema see these pages.

Loop

This can represent 'while', 'do-while','for' , and 'enhanced for' types of loop.

Depending on which of these (on the value of code) depends on the selection of preCondition, postCondition, initialiser and step as follows:

XES represents all these as one type 'loop' because all the loop constructs are equivalent in many ways. For instance, 'for' can be implemented using 'while' by implementing the initialiser and step separately, or 'while' can be implemented using 'for' by leaving initialiser and step empty.

The subnodes may include the following:

Since it is not possible to tell from the subnodes which type of loop it is we must use the 'code' attribute to determine the meaning of the subnodes as follows:

If code = "while" then the subnodes are:

  1. preCondition
  2. loopBlock

If code = "do" then the subnodes are:

  1. loopBlock
  2. postCondition

If code = "for" then the subnodes are:

  1. preCondition
  2. initialiser
  3. step
  4. loopBlock

If code = "extfor" then the subnodes are:

  1. array or container to be iterated over.
  2. loopBlock

In this enhanced for case there are two additional attributes:

These define the name and type of parameter which iterates over the array or container.

In addition to these subnodes there may be any number of comments at any place.

Value of code attribute in nodeLoop java example XES example
code = "while" while (true) {
break;
}
<loop code="while">
<constant boolConst="true"/>
<block>
<break identifier="break"/>
</block>
</loop>

code = "do" do {
break;
} while (true);
<loop code="do">
<block>
<break indentifier="break"/>
</block>
<constant boolConst="true"/>
</loop>
code = "for" for (i=0;i<2;i++) {
break;
}
<loop code="for">
<assign operator="=">
<variable name="i"/>
<constant/>
</assign>
<binaryOp operator="&lt;">
<variable name="i"/>
<constant/>
</binaryOp>
<variable name="i"/>
<block>
<break indentifier="break"/>
</block>
</loop>
code = "extfor" for (i : array) {
break;
}
<loop code="extfor" name="i" type="int">
<variable name="array"/>
<block>
<break indentifier="break"/>
</block>
</loop>
     
     
     
	<xs:complexType name="loop">
<xs:sequence>
<xs:element name="preCondition" type="booleanExpressionType"/>
<xs:element name="postCondition" type="booleanExpressionType"/>
<xs:element name="initialiser" type="blockType"/>
<xs:element name="step" type="blockType"/>
<xs:element name="block" type="blockType"/>
</xs:sequence>
<xs:attribute name="code" type="loopSubType"/>
</xs:complexType>
<xs:simpleType name="loopSubType">
<xs:restriction base="xs:string">
<xs:enumeration value="for"/>
<xs:enumeration value="extfor"/>
<xs:enumeration value="do"/>
<xs:enumeration value="while"/>
</xs:restriction>
</xs:simpleType>

metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Processing XML with Java: A Guide to SAX, DOM, JDOM, JAXP, and TrAX

Other Java books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover JBuilder - There is also a free version of Jbuilder at borland website . However its licence conditions are quite restrictive so you may prefer another java IDE.

Can this page be improved?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

for xml encoding: http://sourceforge.net/projects/xes/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.