Project

Profile

Help

Bug #4092

closed

java.lang.ArrayIndexOutOfBoundsException when validating with XSD 1.1 with assertion on preceding-sibling

Added by Daniel Zimmel over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Schema conformance
Sprint/Milestone:
-
Start date:
2019-01-14
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

When validating the following XML with Schema 1.1 (see below), I get the following error message:

java.lang.ArrayIndexOutOfBoundsException: 7
	at net.sf.saxon.tree.tiny.PrecedingSiblingEnumeration.next(PrecedingSiblingEnumeration.java:45)

XML:

<?xml version="1.0" encoding="UTF-8"?>
<produkt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ESV.xsd">
  <abschnitt>
    <abschnitt.meta>
      <meta>
<!--        <taxonomie haupt="true" name="b" wert="TEST"/>-->
        <taxonomie haupt="false" name="b" wert="TEST"/>
      </meta>
    </abschnitt.meta>
  </abschnitt>
  <abschnitt>
    <abschnitt.meta>
      <meta>
        <taxonomie name="a" wert="TEST"/>
      </meta>
    </abschnitt.meta>
    <abschnitt>
      <abschnitt.meta>
        <meta>
          <taxonomie name="b" wert="TEST"/>
        </meta>
      </abschnitt.meta>
    </abschnitt>
  </abschnitt>
</produkt>

ESV.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/">
    <xs:element name="produkt">
        <xs:complexType>
            <xs:sequence>
                <xs:choice maxOccurs="unbounded">
                    <xs:element ref="dokument"/>
                    <xs:element ref="abschnitt"/>
                </xs:choice>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="abschnitt">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="abschnitt.meta" minOccurs="0"/>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element ref="abschnitt"/>
                    <xs:element name="test" type="xs:string"/>
                </xs:choice>
            </xs:sequence>
            <xs:assert test="*"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="abschnitt.meta">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="meta" type="dokumentmeta.type" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="dokument">
        <xs:complexType>
            <xs:attribute name="href" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="dokumentmeta.type">
        <xs:all>
            <xs:element ref="taxonomie" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element ref="metaeintrag" minOccurs="0" maxOccurs="unbounded"/>
        </xs:all>
        <xs:assert test="not(taxonomie[@haupt=true()][@name = (preceding-sibling::taxonomie/@name,following-sibling::taxonomie/@name)])"/>
    </xs:complexType>
    <xs:element name="taxonomie">
        <xs:complexType>
            <xs:attribute name="name" use="required">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="a"/>
                        <xs:enumeration value="b"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="haupt" type="xs:boolean" default="true"/>
            <xs:attribute name="wert" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="metaeintrag">
        <xs:complexType>
            <xs:attribute name="wert" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

Please note the testing for * which might seem a bit silly here, but still is valid XSD 1.1 according to the Saxon validation so it should never trigger an exception.

The validation works ok if you remove either one of the two assertions in the XSD, or one of /produkt/descendant::taxonomie[position() gt 1] in the XML.


Related issues

Is duplicate of Saxon - Bug #3665: ArrayIndexOutOfBounds in PrecedingSiblingIterator during schema validationClosedMichael Kay2018-02-10

Actions

Please register to edit this issue

Also available in: Atom PDF