[DFDL-WG] Pseudocode in null-default-optional proposal

Simon Parker simon.parker at polarlake.com
Wed Oct 31 11:49:51 CDT 2007


I said I would try to simplify this pseudocode in section 6.2 of the
proposal:
 
for $child in original sequence children declarations
  for $i = 1 to length of array
     if array[$i].name = $child.name // including namespace comparison
     then add array[$i] to $matches
     if array[$i].name != $child.name // including namespace comparison
     then break;                      // stop at first non-match
  assert( $child.minOccurs <= $matches.size ) // processing error
otherwise
  assert( $child.maxOccurs >= $matches.size ) // ditto
  append $matches to $result
return $result
 
 
I came up with this:
 
int $index = 1
for each $child in schema
 int $count = 0
 while $index <= array.size
 and array[$index].name = $child.name
  increment $index
  increment $count
 end
 assert( $child.minOccurs <= $count ) // processing error otherwise
 assert( $child.maxOccurs >= $count ) // ditto
end
return array

... but I'm not convinced this programming exercise added to the
readability of the specification. I'll keep trying to find a better
style, but I'm not sure I understand it well enough yet.
 
 Simon
 
Simon Parker
Software Consultant
PolarLake
80 Harcourt Street
Dublin 2, Ireland
 
Phone  +353 1 449-1075
Fax    +353 1 449-1011
Web    http://www.polarlake.com/
 
The information transmitted in this email is intended for the addressee
only and may contain confidential and/or privileged material. Any
review, retransmission, dissemination, reliance upon or other use of
this information by persons or entities other than the addressee is
prohibited. If you think, for any reason, that this message may have
been addressed to you in error, we would ask you to notify the sender
immediately by return email and delete the material. PolarLake Limited |
Registered in Dublin, Ireland | Number 357324 | Registered office as
above.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ogf.org/pipermail/dfdl-wg/attachments/20071031/33489c3d/attachment.html 


More information about the dfdl-wg mailing list