Ошибка проверки схемы xml «Содержимое элемента 'flowPara' не завершено»

Мне нужно проверить XSD для XML-файла.

Это xml-файл.

<?xml version="1.0" encoding="UTF-8"?>
<edge xmlns="http://www.example.org/flow">
<flowPara
        style="letter-spacing:0px;fill:#000000; 
    font-size:9pt;font-family:Arial;text-anchor:start;text-align:start;"
        id="textArea_38">
        Text Flow checking and
        <flowSpan style="fill:#FA0101; ">
            font color change
            text
            <flowSpan style="fill:#C5A2A2; " />
        </flowSpan>
        in
        <flowSpan
            style="font-style:italic;letter-spacing:0px;fill:#000000; 
    font-size:9pt;font-family:Arial;text-anchor:start;text-align:start;">text
            area
        </flowSpan>
        .
        <flowSpan style="letter-spacing:0px;">
            <flowSpan
                style="text-decoration:underline;letter-spacing:0px;fill:#000000; 
    font-size:9pt;font-family:Arial;text-anchor:start;text-align:start;">Text
                Flow
            </flowSpan>
            checking and
            <flowSpan style="fill:#FA0101; ">
                font color
                change text
                <flowSpan style="fill:#C5A2A2; ">
                    <flowSpan style="fill:#000000; 
    ">in text area.</flowSpan>
                </flowSpan>
            </flowSpan>
        </flowSpan>
    </flowPara>
</edge> 

Это файл XSD, который я создал.

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"        targetNamespace="http://www.example.org/flow"
xmlns:tns="http://www.example.org/flow" elementFormDefault="qualified">
<element name="edge">
    <complexType>
        <sequence>
                 <element name="flowPara" maxOccurs="unbounded">
                                        <complexType mixed="true">
                                            <sequence>
                                                <element name="flowspan" maxOccurs="unbounded">
                                                    <complexType mixed="true">
                                                        <sequence>
                                                            <element name="flowspan" maxOccurs="unbounded">
                                                                <complexType mixed="true">
                                                                    <simpleContent>
                                                                        <extension base="string">
                                                                            <attribute name="style" type="string" />
                                                                        </extension>
                                                                    </simpleContent>
                                                                </complexType>
                                                            </element>
                                                        </sequence>
                                                        <attribute name="style" type="string" />
                                                    </complexType>
                                                </element>
                                            </sequence>
                                            <attribute name="style" type="string" />
                                            <attribute name="id" type="string" />
                                        </complexType>

                                    </element>
</sequence>
    </complexType>
</element>
</schema>

я столкнулся с таким исключением

Исключение: cvc-complex-type.2.4.b: содержимое элемента 'flowPara' не является полным. Ожидается один из '{"http://www.example.org/flow":flowspan}' .


person Maheshkumar.V    schedule 18.03.2014    source источник


Ответы (2)


1) В вашей схеме у вас есть flowspan с s в нижнем регистре в нескольких местах. Измените это на flowSpan.

2) Вы объявили содержимое mixed, но ваш элемент flowSpan не является необязательным, поэтому он всегда будет требоваться и не будет проверять его, если содержимое flowSpan не содержит другого flowSpan. Добавьте minOccurs="0", чтобы он стал необязательным.

3) Вам не нужно объявлять простой контент, если у вас есть смешанный контент с необязательным вложенным flowSpan. Ваша схема может быть реорганизована с использованием ссылки на flowSpan, поскольку она используется рекурсивно. Вы можете попробовать это:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"        
        targetNamespace="http://www.example.org/flow"
        xmlns:tns="http://www.example.org/flow" 
        elementFormDefault="qualified">

    <element name="edge">
        <complexType>
            <sequence>
                <element name="flowPara" maxOccurs="unbounded">
                    <complexType mixed="true">
                        <sequence>
                            <element ref="tns:flowSpan" maxOccurs="unbounded"/>
                        </sequence>
                        <attribute name="style" type="string" />
                        <attribute name="id" type="string" />
                    </complexType>
                </element>
            </sequence>
        </complexType>
    </element>

    <element name="flowSpan">
        <complexType mixed="true">
            <sequence>
                <element ref="tns:flowSpan" minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
            <attribute name="style" type="string" />
        </complexType>
    </element>
</schema>
person helderdarocha    schedule 19.03.2014

Вы не сказали minOccurs='0', поэтому он требуется.

person bmargulies    schedule 19.03.2014