weird xquery error
- From: Mark <mmodrall@xxxxxxxxxxxxx>
- Date: Wed, 3 Jan 2007 07:36:01 -0800
Hi...
I've been playing with the xml and schema types and querying on them and I
got some help with xquery from Wei and Han. As I built out more samples in
the collection I ran into a weird error with one xquery:
Msg 9314, Level 16, State 1, Line 3
XQuery [xml_test.xml_col.value()]: Cannot implicitly atomize or apply
'fn:data()'
to complex content elements, found type '{http://ex.org/T2}:age'
within inferred type
'(element({http://ex.org/LogansRun}:age,#anonymous) |
element({http://ex.org/T2}:age,#anonymous)) ?'.
running the query
select xml_col.value('(//*:age)[1]', 'varchar(100)') from xml_test;
(Han recommended this as a very concise form for a query, without all the
namespace declarations)
on the schema collection:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="noContent">
<xsd:restriction base="xsd:string">
<xsd:length value="1" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns="http://ex.org/LogansRun" targetNamespace="http://ex.org/LogansRun">
<xsd:element name="age">
<xsd:simpleType>
<xsd:restriction base="xsd:float">
<xsd:minInclusive value="0" />
<xsd:maxInclusive value="30" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns="http://ex.org/T2" targetNamespace="http://ex.org/T2">
<xsd:element name="age">
<xsd:complexType>
<xsd:complexContent>
<xsd:sequence>
<xsd:element name="birthday" type="xsd:string" />
<xsd:element name="mother" type="xsd:string" minOccurs="0" />
<xsd:element name="father" type="xsd:string" minOccurs="0" />
<xsd:element name="sibling" type="xsd:string" minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns="http://ex.org/T3" targetNamespace="http://ex.org/T3" >
<xsd:element name="person">
<xsd:complexType>
<xsd:complexContent>
<xsd:sequence>
<xsd:element name="age" type="xsd:string" />
<xsd:element name="mother" type="xsd:string" minOccurs="0" />
<xsd:element name="father" type="xsd:string" minOccurs="0" />
<xsd:element name="sibling" type="xsd:string" minOccurs="0"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Each of the schema in the collection has only one definition for an "age"
element. Yes, they're all different but to serialize them as a string it
doesn't seem like the difference is material.
Could someone explain why it's throwing an error? There isn't even any data
in the table, so it's barking at a semantic level, not a data conflict level.
Thanks
-Mark
.
- Follow-Ups:
- Re: weird xquery error
- From: Denis Ruckebusch [MSFT]
- RE: weird xquery error
- From: Wei Lu [MSFT]
- Re: weird xquery error
- Prev by Date: RE: schema collection problem?
- Next by Date: RE: Thoughts on storing address data with XML data type?
- Previous by thread: RE: schema collection problem?
- Next by thread: RE: weird xquery error
- Index(es):
Relevant Pages
|