This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 17040 - [XQ30] Clarification on using defined prefixes in serialization and validate expr
Summary: [XQ30] Clarification on using defined prefixes in serialization and validate ...
Status: RESOLVED INVALID
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Linux
: P2 major
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-11 16:44 UTC by Cezar Andrei
Modified: 2012-05-29 19:39 UTC (History)
2 users (show)

See Also:


Attachments

Description Cezar Andrei 2012-05-11 16:44:05 UTC
Should the declared prefixes be serialized?

Ex 1: explicit declaration
  declare namespace cat ='mycat'; 
  <a t='cat:miau'>42</a>
Should result in:
  <a t='cat:miau'>42</a>
or
  <a xmlns:cat='mycat' t='cat:miau'>42</a>

Ex 2: implicit declaration of xsi and xs prefix
  <a xsi:type='xs:integer'>42</a>
Should result in:
  <a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:integer">42</a>
or
  <a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xsi:type="xs:integer">42</a>


Should the validate expression take into account the declared prefixes?

Ex 3: validate
  validate lax { <a xsi:type='xs:integer'>42</a> }
Should result in:
  Error: xs prefix not declared for QName value 'xs:integer'.
or
  <a xsi:type='xs:integer'>42</a> with 'xs:integer' being a valid QName and 42 being an integer in PSVI.
Comment 1 Michael Kay 2012-05-22 20:39:48 UTC
I believe this is really a request for interpretation of the XQuery 1.0 specification, rather than a comment on 3.0. Correct me if I am wrong.

Note first that the serializer makes no decision about which namespaces to output. If a namespace is present in the result tree then it is serialized, if it is not present in the result tree, it is not serialized. The question concerns element construction and the namespace nodes/bindings that are added to elements during tree construction, which is largely covered in section 3.7.4 of the specification, and has nothing to do with serialization.

For the first example

declare namespace cat ='mycat'; 
  <a t='cat:miau'>42</a>

none of the conditions for creating a namespace binding for cat="mycat" is satisfied; therefore it is not created. (If you want it created, write <a t='cat:miau' xmlns:cat='mycat'>42</a>)

In the second example, the required conditions are satisifed for the xsi namespace (specifically, the namespace is used in the name of an attribtue), but not for the xs namespace.

As far as validation is concerned, the tree is constructed first, then validation takes place. The only namespaces known to the validator are those that are present on the tree being validated. If tree construction did not add a namespace to the element in question, then the validator will complain if it encounters QName-valued content that uses a prefix for which no binding is present on the tree.
Comment 2 Jonathan Robie 2012-05-25 21:15:31 UTC
Hi Cezar,

Do you agree with Mike Kay's analysis? Is there a bug in the XQuery 3.0 specificaiton that we should be aware of?  If not, I'd like to close this BZ.
Comment 3 Jonathan Robie 2012-05-29 15:17:13 UTC
Hi Cezar, 

I'm resolving this as invalid, because it does not mention a specific problem with the XQuery 3.0 specification. If I missed something, please reopen, and clearly state the problem that you see in the specification.
Comment 4 Cezar Andrei 2012-05-29 17:52:28 UTC
This is how I interpreted the first time, without these examples. But from an usability standpoint, in these cases, it's not the best answer. In the same time, the spec has to cover all cases, it's good that this is clarified now.
Comment 5 Cezar Andrei 2012-05-29 18:27:24 UTC
It would be really useful to have a set of tests added to the TCK for this matter.
Comment 6 Michael Kay 2012-05-29 19:39:52 UTC
Thanks for the suggestion. I am adding these examples as tests to the QT3 test suite. In fact it appears there are currently no tests for a validate expression relying on xsi:type, so this is a welcome addition!