468,537 Members | 1,844 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

Non-Deterministic error in an if-else xml block

I have a schema that defines a programming language for a script that drives a sequentially executing process. It defines the structure of a script that has to interact with a pre-existing, custom-made XML parsing engine. Part of this is an if-else block that has to be defined as:

<if {condition}>
statements...
<else/>
statements...
</if>

The else and subsequent statements are optional. Also, the statements after else can be any of the statements before else.

This is how I have it defined in the schema:

<xs:element name="if">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="general_command"/>
<xs:group ref="macro_control_command"/>
</xs:choice>
<xs:element ref="else" minOccurs="0"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="general_command"/>
<xs:group ref="macro_control_command"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element

When I try to validate, XMLSPY reports a non-deterministic error, which I believe is because general_command and macro_control_command are reqeated in the same element. I'm wondering if there is any way to get around this error so that the schema will validate, without giving up the structure/functionality that I need?

Thanks!
Oct 15 '08 #1
4 2758
Dormilich
8,651 Expert Mod 8TB
do you get the same error when you define only one unique <xs:group> per <xs:element>?
are there any elements in both groups?
Oct 15 '08 #2
You mean like this?

<xs:element name="if">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="general_command"/>
<xs:group ref="macro_control_command"/>
</xs:choice>
<xs:element ref="else" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>

This does work without errors, but it takes away the functionality that I'm looking for. It turns this:

if
statements
else
statements
end if

into this:

if
statements
else
end if
Oct 15 '08 #3
jkmyoung
2,057 Expert 2GB
Put a sequence around the second part of the statement. Make this optional, and the else part required, with respect to the optional sequence.
Expand|Select|Wrap|Line Numbers
  1. <xs:element name="if">
  2.     <xs:complexType>
  3.         <xs:sequence>
  4.             <xs:choice minOccurs="0" maxOccurs="unbounded">
  5.                 <xs:group ref="general_command"/>
  6.                 <xs:group ref="macro_control_command"/>
  7.             </xs:choice>
  8.             <xs:sequence minOccurs="0">
  9.                 <xs:element ref="else"/>
  10.                 <xs:choice minOccurs="0" maxOccurs="unbounded">
  11.                     <xs:group ref="general_command"/>
  12.                     <xs:group ref="macro_control_command"/>
  13.                 </xs:choice>
  14.             </xs:sequence>
  15.         </xs:sequence>
  16.     </xs:complexType>
  17. </xs:element>
  18.  
---
Just to explain the error:
You had it written as:
A. If
B. Stmts (optional)
C. Else (optional)
D. Stmts (optional).


So if we had

If
Stmts.

Does the parser parse the stmts as coming from block B, or block D? It can't tell so the parser craps out.
Oct 15 '08 #4
Worked like a charm!

Thanks a lot jkmyoung!!
Oct 15 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Kartic | last post: by
14 posts views Thread by mirnazim | last post: by
5 posts views Thread by Leif K-Brooks | last post: by
12 posts views Thread by lothar | last post: by
2 posts views Thread by Mark Stijnman | last post: by
4 posts views Thread by bwmiller16 | last post: by
14 posts views Thread by Patrick Kowalzick | last post: by
8 posts views Thread by Rajesh | last post: by
399 posts views Thread by =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post: by
5 posts views Thread by George2 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.