Setting a prefixed default value for an attribute typed as xs:QName makes Zorba give an incorrect error.

Bug #925366 reported by Ghislain Fourny
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Confirmed
Medium
Cezar Andrei

Bug Description

Upon import of the following schema in a query, Zorba crashes.

schema.xsd
=========
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:my="http://ns.example.com/"
  targetNamespace="http://www.example.com/">
  <xs:element name="element">
    <xs:complexType>
      <xs:attribute name="type-name" type="xs:QName" default="my:default-value"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Query
=====
import schema namespace pul = "http://www.example.com/" at "schema.xsd";
()

It seems to be because the prefix binding of "my" (the default value's prefix) is forgotten outside of the schema (removing this prefix does not lead to a crash).

Tags: schema
Changed in zorba:
milestone: none → 2.5
Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

There is no crash currently in the form that it is in the bug.

But if I modify to:

import schema namespace pul = "http://www.example.com/" at "s.xsd";
validate { <element xmlns='http://www.example.com/'></element> }

There is this error:

$ ./bin/zorba -f -q ../../../xqSample/prefixedDefaultValue/q.xq
<?xml version="1.0" encoding="UTF-8"?>
</media/sdd/dev/repo/bug925366-prefixDefaultValue/build/../../../xqSample/prefixedDefaultValue/q.xq>:3,1: dynamic error [err:XQDY0027]: "Schema validation failed: undefined prefix in QName value 'my:default-value'": unexpected validity property; raised at /home/cezar/dev/repo/bug925366-prefixDefaultValue/src/types/schema/SchemaValidatorFilter.cpp:1590

Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

No crash but incorect error -> Medium Importance

Changed in zorba:
importance: High → Medium
summary: Setting a prefixed default value for an attribute typed as xs:QName
- makes zorba crash.
+ makes zorba give incorect error.
Changed in zorba:
importance: Medium → High
milestone: 2.5 → 2.7
summary: Setting a prefixed default value for an attribute typed as xs:QName
- makes zorba give incorect error.
+ makes zorba give incorrect error.
Chris Hillery (ceejatec)
Changed in zorba:
milestone: 2.7 → none
milestone: none → 2.7
Chris Hillery (ceejatec)
Changed in zorba:
milestone: 2.7 → 3.0
Changed in zorba:
milestone: 3.0 → 2.8
Chris Hillery (ceejatec)
Changed in zorba:
milestone: 2.8 → 2.9
tags: added: schema segfault
tags: removed: segfault
Revision history for this message
Ghislain Fourny (gislenius) wrote : Re: Setting a prefixed default value for an attribute typed as xs:QName makes zorba give incorrect error.

I have the feeling this is not just an incorrect error - the XML element is a valid instance of the schema (the attribute is optional) and the query should return a validated node. Am I missing something?

summary: Setting a prefixed default value for an attribute typed as xs:QName
- makes zorba give incorrect error.
+ makes Zorba raise an error.
Revision history for this message
Ghislain Fourny (gislenius) wrote : Re: Setting a prefixed default value for an attribute typed as xs:QName makes Zorba raise an error.

I investigated and found this in the XML Schema, Part 1 specification:

===========
Note: When a default value of type QName or NOTATION is applied, it is ·implementation-dependent· whether ·namespace fixup· occurs; if it does not, the prefix used in the lexical representation (in [normalized value] or [schema normalized value]) will not necessarily map to the namespace name of the value (in [schema actual value]). To reduce problems and confusion, users may prefer to ensure that the required namespace information item is present in the input infoset.
===========

So, it seems that Zorba/Xerces does not do namespace-fixup in this case, which seems to be acceptable behaviour after all. The error message about the undefined prefix looks correct then.

Namespace-fixup would be nice to have, but I not not sure about the benefits/cost ratio. It would be nice for our XDM serialization framework, which relies on default QName values.

I hope it helps! Will close the bug if I do not hear from you.

summary: Setting a prefixed default value for an attribute typed as xs:QName
- makes Zorba raise an error.
+ makes Zorba give an incorrect error.
Changed in zorba:
status: New → In Progress
Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

The problem here is that Zorba doesn't have the prefix my in the context and Xerces complains about it. There isn't much we can do here. The ideal solution would be to have Xerces generate a new attribute and it's namespace definition.

Revision history for this message
Ghislain Fourny (gislenius) wrote :

Yes, this is what is called "namespace fixup". Since it is not required to be conformant, I think we can lower the severity of this bug or close it.

Changed in zorba:
importance: High → Medium
Changed in zorba:
milestone: 2.9 → 3.0
Chris Hillery (ceejatec)
Changed in zorba:
status: In Progress → Confirmed
milestone: 3.0 → none
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.