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
Actions #1

Updated by Michael Kay over 5 years ago

I've reproduced the problem on 9.7 and have confirmed that it doesn't occur on 9.8 or 9.9.

Is there anything holding you up from moving to a more recent release?

Actions #2

Updated by Michael Kay over 5 years ago

  • Is duplicate of Bug #3665: ArrayIndexOutOfBounds in PrecedingSiblingIterator during schema validation added
Actions #3

Updated by Michael Kay over 5 years ago

  • Status changed from New to In Progress
  • Assignee set to Michael Kay

Looks like a duplicate of

https://saxonica.plan.io/issues/3665

Actions #4

Updated by Daniel Zimmel over 5 years ago

Thanks for the update. For the moment, I am stuck with the 9.7 version that comes bundled with Oxygen, because I do not have another EE license available in my organization.

Glad to see it is fixed though.

Actions #5

Updated by Michael Kay over 5 years ago

  • Status changed from In Progress to Closed

Closing this as a duplicate.

Please register to edit this issue

Also available in: Atom PDF