5

I am trying out XML SCHEMA 1.1 in IDEA 13.02 with JDK 7

This is an XML schema code I got from a tutorial. When I open this file in IntelliJ IDEA and click "Validate" , I get the following errors:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'openContent'. One of '{"http://www.w3.org/2001/XMLSchema":annotation, "http://www.w3.org/2001/XMLSchema":simpleContent, "http://www.w3.org/2001/XMLSchema":complexContent, "http://www.w3.org/2001/XMLSchema":group, "http://www.w3.org/2001/XMLSchema":all, "http://www.w3.org/2001/XMLSchema":choice, "http://www.w3.org/2001/XMLSchema":sequence, "http://www.w3.org/2001/XMLSchema":attribute, "http://www.w3.org/2001/XMLSchema":attributeGroup, "http://www.w3.org/2001/XMLSchema":anyAttribute}' is expected.

This is the XSD File using XML Schema 1.1 enhancements:

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.books.org"
        xmlns:pub="http://www.books.org"
        elementFormDefault="qualified">

    <complexType name="Publication" abstract="true">
        <openContent mode="interleave">
            <any />
        </openContent>
        <sequence>
            <element name="Title" type="string" />
            <element name="Author" type="string" />
            <element name="Date" type="gYear"/>
        </sequence>
    </complexType>

    <complexType name="BookPublication">
        <complexContent>
            <extension base="pub:Publication">
                <openContent mode="none">
                </openContent>
                <sequence>
                    <element name="ISBN" type="string"/>
                    <element name="Publisher" type="string"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

    <element name="BookStore">
        <complexType>
            <sequence>
                <element name="Book" type="pub:BookPublication" maxOccurs="unbounded" />
            </sequence>
        </complexType>
    </element>

</schema>

Is there a way to validate this or upgrade the validator used by IDEA ?

TheEwook
  • 11,037
  • 6
  • 36
  • 55
user193116
  • 3,498
  • 6
  • 39
  • 58
  • Possible duplicate of [How to indicate that an xml schema that requires schema 1.1 features?](https://stackoverflow.com/questions/21555511/how-to-indicate-that-an-xml-schema-that-requires-schema-1-1-features) – Joost Jan 24 '18 at 14:06

2 Answers2

0

Try adding xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" and vc:minVersion="1.1" to <schema>:

<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.books.org"
        xmlns:pub="http://www.books.org"
        elementFormDefault="qualified"
        xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" 
        vc:minVersion="1.1"
>  ... </schema>

It will inform IDEA that you are using a XSD 1.1 Schema.

I've used XSD 1.1 with WebStorm 8, which I believe uses the same parser as IDEA.

helderdarocha
  • 23,209
  • 4
  • 50
  • 65
  • unfortunately Id did not work. Is the url "http://www.w3.org/2007/XMLSchema-versioning" correct ? IDEA errror is (1)"External resource http://www.w3.org/2007/XMLSchema-versioning is not registered" and (2)"Premature end of file". I have registered this but it still doesn't work. – user193116 Mar 07 '14 at 19:19
  • It should be. Check http://www.w3.org/2007/XMLSchema-versioning/ . Maybe there you can upgrade your IDEA. Since XSD 1.1 is quite recent, it's possible that they only support it in recent versions. My WebStorm 8 is Early Access. I'm not sure if it would work on WS 7. – helderdarocha Mar 07 '14 at 19:23
  • But `Premature end of file` looks like something else, a not-well-formed problem. – helderdarocha Mar 07 '14 at 19:25
0

If your XML-validator supports XSD 1.0 and 1.1 (not only one version), but can't recognize version of XSD automatically, you need add attributes (like said @helderdarocha)

    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" 
    vc:minVersion="1.1"

to "schema" tag and validator will know what version need use for check.

But if your XML-validator supports only XSD 1.0, you should remove unsupported items, it's the only way to be validated, reference to minVersion will not working.

As example:

  1. XML Validator ".Net 4.0 (XSD 1.0)" will say about invalid document, no matter whether you have specified a minimum version;

  2. XML Validator "Xerces 2.11.0" supported two version of XSD, but:

    2.1 If you will validate your document on XSD 1.0 mode, validator will say about incorrect document if "minVersion" not specified. If minVersion added, validator will skip checking for items from 1.1 version.

    2.2 If you will validate your document on XSD 1.1 mode, "minVersion" is not required.

So, I want said that the problem is not in the IDEA: if you used another validators checks could pass. I recommend always checking XML on several validators and versions to be sure that your XML is real correctly.

Vika Marquez
  • 353
  • 1
  • 3
  • 12