[ http://issues.apache.org/jira/browse/DERBY-1759?page=all ]
A B updated DERBY-1759: ----------------------- Derby Info: [Patch Available] I ran derbyall against insane jars with ibm142 on Red Hat Linux and there were no new failures. So the d1759_v1.patch is ready for review/commit. > XMLSERIALIZE operator doesn't follow SQL/XML spec in some areas when > serializing a sequence. > -------------------------------------------------------------------------------------------- > > Key: DERBY-1759 > URL: http://issues.apache.org/jira/browse/DERBY-1759 > Project: Derby > Issue Type: Bug > Affects Versions: 10.2.1.0, 10.2.2.0, 10.3.0.0 > Reporter: A B > Assigned To: A B > Fix For: 10.2.2.0, 10.3.0.0 > > Attachments: d1759_v1.patch, d1759_v1.stat > > > The SQL/XML specification dictates that, when serializing a sequence of XML > items, the XMLSERIALIZE operator must first "normalize" the sequence based on > the rules defined here: > http://www.w3.org/TR/xslt-xquery-serialization/#serdm > The current Derby implementation doesn't perform such normalization, which > leads to two ways in which the results of an XMLSERIALIZE operator may not > agree with the required behavior: > 1. Sequences of atomic values will not have spaces between, but > the space is required as part of step 3 of the normalization > rules at the above link. > 2. Derby will allow serialization of a sequence even if it has > a top-level Attribute node in it, but the rules of normalization > dictate that an error should be thrown instead (step 7). > Both of these behaviors can be seen with the following query. > values > xmlserialize( > xmlquery('/ageinfo/@*' passing by ref > xmlparse( > document '<ageinfo age="48" birthdate="1900-02-08"/>' > preserve whitespace > ) > empty on empty > ) > as char(50) > ) > Derby will currently return the following result from this statement: > 1 > -------------------------------------------------- > 481900-02-08 > This result does not abide by SQL/XML specification because a) Derby allowed > serialization of a sequence having a top-level attribute node (actually, the > sequence had two), and b) the atomic values produced from the attributes were > displayed without a space between them. > The correct behavior for the above example is to return a serialization error > caused by the presence of an Attribute node in the sequence. > If the example was rewritten as, say: > - xmlquery('/ageinfo/@*' passing by ref > + xmlquery('fn:data(/ageinfo/@*)' passing by ref > then the attribute nodes are no longer present--we only have their atomic > values, which is allowed. Thus the correct result should then be: > 1 > -------------------------------------------------- > 48 1900-02-08 > Note, though, that Xalan doesn't appear to support the "fn:data" function, so > this rewritten query won't actually work. I tried using Xalan's built-in > string function, as follows: > - xmlquery('/ageinfo/@*' passing by ref > + xmlquery('string(/ageinfo/@*)' passing by ref > but Xalan only returns the first attribute in that case; it doesn't return > the second one. So part of this Jira issue is probably going to involve > figuring out how to allow a user to retrieve a sequence of attribute *values* > (as opposed to attribute nodes) using Xalan and still abide by the SQL/XML > rules. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira