Validate in place applied on non-root element produces an invalid xdm instance

Bug #912579 reported by Federico Cavalieri
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
High
Federico Cavalieri

Bug Description

If validate-in-place is called on a non-root element the resulting xdm instance can be invalid since it may contain typed nodes as descendant of untyped nodes.

Schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 targetNamespace="http://www.zorba-xquery.org/schema" xmlns="http://www.zorba-xquery.org/schema"
 elementFormDefault="qualified">

 <xs:element name="root" type="rootType"/>

 <xs:complexType name="rootType">
  <xs:sequence>
   <xs:element name="root" type="rootType" minOccurs="0"/>
   <xs:element name="a" type="xs:string"/>
   <xs:element name="b" type="xs:string"/>
   <xs:element name="c" type="xs:string"/>
  </xs:sequence>
  <xs:attribute name="attr" type="xs:string"/>
 </xs:complexType>

</xs:schema>

Query
import module namespace schema = "http://www.zorba-xquery.com/modules/schema";
import module namespace doc = "http://www.zorba-xquery.com/modules/store/dynamic/documents";
import schema namespace d="http://www.zorba-xquery.org/schema" at "val-inplace-err2.xsd";

declare revalidation lax;
declare construction strip;

declare variable $doc2:=<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.zorba-xquery.org/schema">
    <root>
        <a/>
        <b/>
        <c/>
    </root>
    <a/>
    <b/>
    <c/>
</root>;

schema:validate-in-place($doc2/d:root);

(schema:schema-type($doc2), schema:schema-type($doc2/d:root))

Result
xs:untyped rootType

Related branches

Changed in zorba:
status: New → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.