1

After trying a lot of things to get an error in IntelliJ over a unique constraint I'm starting to wonder if IntelliJ is even recognizing it.

The last schema I gave a try came from this post Unique constraint in XML Schema

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.brabantia.com/XMLSchema/ESBConfig"
        xmlns:tns="http://www.brabantia.com/XMLSchema/ESBConfig"
        elementFormDefault="qualified">
    <element name="authors">
        <complexType>
            <sequence>
                <element name="author" maxOccurs="unbounded" type="string"/>
            </sequence>
        </complexType>
        <unique name="uniqueAuthor">
            <selector xpath="author"/>
            <field xpath="."/>
        </unique>
    </element>
</schema>

Which I used to generate the XML by IntelliJ.

<?xml version="1.0" encoding="UTF-8"?>
<esb:authors xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig">
  <!--1 or more repetitions:-->
  <esb:author>string</esb:author>
  <esb:author>string</esb:author>
  <esb:author>string</esb:author>
</esb:authors>

Which should show an error, but it doesn't.

In the Generate Instance Document From Schema wizard I have checked Enable restriction check and Enable unique check.

All other checks work, like enumeration and pattern.

Could someone tell me if this is something in the schema or something that is simply not supported in IntellJ?

Johan Vergeer
  • 5,208
  • 10
  • 48
  • 105
  • Add `xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig"` and change to `` in your schema – Morfic Feb 28 '18 at 20:50

1 Answers1

3

Add xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig" and change to <selector xpath="esb:author"/> in your schema:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.brabantia.com/XMLSchema/ESBConfig"
        xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig"
        elementFormDefault="qualified">
    <element name="authors">
        <complexType>
            <sequence>
                <element name="author" maxOccurs="unbounded" type="string"/>
            </sequence>
        </complexType>
        <unique name="uniqueAuthor">
            <selector xpath="esb:author"/>
            <field xpath="."/>
        </unique>
    </element>
</schema>

Result:

Validation result

Morfic
  • 15,178
  • 3
  • 51
  • 61