|
| Trouble with XQuery and attributes |
 |
Tue, 11 Dec 2007 08:12:23 -060 |
Hi,
I've got the following table:
$ db2 describe table li.organization
Column Type Type
name schema name Length
Scale Nulls
------------------------------ --------- ------------------ --------
----- ------
O_START_DATE SYSIBM DATE 4
0 No
O_END_DATE SYSIBM DATE 4
0 No
O_STRUCTURE SYSIBM XML 0
0 No
3 record(s) selected.
...into which I'm performing the following insert:
xmlvalidate(xmlparse (document '<?xml version="1.0"
encoding="UTF-8"?>
<Organization
xmlns:org="http://aixhome.austin.ibm.com/data/schemas"
xmlns="http://aixhome.austin.ibm.com/data/schemas"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://aixhome.austin.ibm.com/data/schemas
organization.xsd ">
<employee name="Terry J Hoffman"
serial="123456897">
<employee name="Kenneth Stephen"
serial="3D4316897" />
<employee name="John Sullivan"
serial="3X4316897" />
</employee>
<employee name="Jessica Murillo"
serial="3A4316897">
<employee name="Carl Jones"
serial="223456897">
<employee name="Atul D Patel"
serial="3E4316897">
<employee name="Penny
Smith-Kerker"
serial="3Y4316897" />
</employee>
</employee>
</employee>
</Organization>' preserve whitespace)
according to xmlschema id organization), current date, '9999-12-31'
);
....where the "organization" xmlschema was registered from this
definition:
<?xml version="1.0" encoding="UTF-8"?>
<schema
targetNamespace="http://aixhome.austin.ibm.com/data/schemas"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:org="http://aixhome.austin.ibm.com/data/schemas"
elementFormDefault="qualified">
<complexType name="EmployeeType">
<sequence>
<element name="employee"
type="org:EmployeeType"
minOccurs="0" maxOccurs="unbounded" />
</sequence>
<attribute name="serial"
type="org:SerialNumberType" />
<attribute name="name" type="string" />
</complexType>
<simpleType name="SerialNumberType">
<restriction base="string">
<length value="9"></length>
</restriction>
</simpleType>
<element name="Organization">
<complexType>
<sequence>
<element name="employee"
type="org:EmployeeType" minOccurs="1"
maxOccurs="unbounded" />
</sequence>
</complexType>
</element>
</schema>
The following XQuery fails:
xquery
declare default element namespace
'http://aixhome.austin.ibm.com/data/schemas';
declare boundary-space preserve;
for $org in db2-fn:xmlcolumn('LI.ORGANIZATION.O_STRUCTURE')/Organization
return <container>{$org/employee/@name}</container>
!
....with this error:
SQL16016N The attribute name "name" cannot be used more than once in
an
element constructor. Error QName=err:XQDY0025. SQLSTATE=10503
....when executed as:
db2 -td! -vf org.xquery
Any ideas why?
Thanks,
|
| Post Reply
|
|
|
|
|
|
|
|
|
|