Jump to content

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:
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:element name="LOGIC_OPERATOR" type="TYPE_LOGIC_OPERATOR"/>
                <xs:element ref="LOGIC_VALUES"/>

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

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

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">
The XML schema should detect that it is a unary operator and you should receive an error.
Thaks a million
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.

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.

  • Create New...