Jump to content
Sign in to follow this  
leor

XML Schema Dynamic MaxOccurs conditioned by another element

Recommended Posts

That I am working on?:

I am generating an XML schema that controls the inclusion of a logical expression in a program.
- Unary (now only work with not) (force MaxOccurss=1 of LOGIC_VALUES)
- Binary (and,or) (force MaxOccurss=Unbounded of LOGIC_VALUES)
You can see the visual schema of code:
T8mKD.jpg
Current code, which does not have the requested functionality
<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">


    <xs:element name="LOGIC_EXPRESSION">
        <xs:complexType>
            <xs:all>
                <xs:element name="LOGIC_OPERATOR" type="TYPE_LOGIC_OPERATOR"/>
                <xs:element ref="LOGIC_VALUES"/>
            </xs:all>
        </xs:complexType>
    </xs:element>


    <xs:element name="LOGIC_VALUES">
        <xs:complexType>
            <xs:choice>
                <xs:element name="LOGIC_VALUE" minOccurs="1" maxOccurs="unbounded"/>
            </xs:choice>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="TYPE_LOGIC_OPERATOR">
        <xs:restriction base="xs:string">
            <xs:enumeration value="and"/>
            <xs:enumeration value="or"/>
            <xs:enumeration value="not"/>
        </xs:restriction>
    </xs:simpleType>


</xs:schema>
What do I need?
I need know:
- If possible in the restriction of logic operator you can force the maxOccur of Logic_Values (dynamic change of maxoccurs to other element)
- If it is possible to do, what should I use?
Example of what I want
You are writting the next XML code:
   <?xml version="1.0" encoding="UTF-8"?>
    <LOGIC_EXPRESSION xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:/media/sf_Downloads/xml/Beta.xsd">
    <LOGIC_OPERATOR>not</LOGIC_OPERATOR>
    <LOGIC_VALUES>
      <LOGIC_VALUE>Variable1</LOGIC_VALUE>
        <LOGIC_VALUE>Variable2</LOGIC_VALUE>
    </LOGIC_VALUES>
    </LOGIC_EXPRESSION>
The XML schema should detect that it is a unary operator and you should receive an error.
Thaks a million

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...