Intellij IDEA: How to Validate XML SCHEMA 1

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

This is the XML schema code that I got from the 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 the element 'openContent'. One of the '{" 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 ": everything," http: // www .w3.org / 2001 / XMLSchema ": selection," 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 an 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 any way to check this or update the validator used by IDEA?

+4
source share
2 answers

Try adding xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"and vc:minVersion="1.1"at <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>

Tells IDEA that you are using an XSD 1.1 schema.

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

0
source

If your XML validator supports XSD 1.0 and 1.1 (not just one version), but cannot automatically recognize the XSD version, you need to add attributes (e.g. the ones mentioned by @helderdarocha)

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

"schema" , .

XML- XSD 1.0, , , minVersion .

:

  • XML Validator ".Net 4.0 (XSD 1.0)" , , ;

  • XML Validator "Xerces 2.11.0" XSD, :

    2.1 XSD 1.0, , "minVersion" . ​​ minVersion, 1.1.

    2.2 XSD 1.1, "minVersion" .

, , IDEA: , . XML , , XML .

0

Source: https://habr.com/ru/post/1530641/


All Articles