xs:date
속성이있는 스키마가 있습니다. 스키마는 날짜를 포함하거나 비어있는 방식으로 정의됩니다. 나는이 요소를 조회하려고 할 때xs : date 목록이 비어있을 수있는 요소를 xQuery하는 방법?
는하지만 오류
"XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xs:date *'"
어떤 제안을 얻을?
단계
create xml schema collection dbo.[test] AS
N'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="PACKAGE" >
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="CUSTOMER">
<xs:complexType>
<xs:sequence>
<xs:element name="BIRTHDAY" >
<xs:annotation>
<xs:documentation>Date of Birth</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction>
<xs:simpleType>
<xs:list itemType="xs:date" />
</xs:simpleType>
<xs:minLength value="0" />
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>';
go
declare @xml xml(dbo.[test]);
set @xml =
'<PACKAGE>
<CUSTOMER>
<BIRTHDAY></BIRTHDAY>
</CUSTOMER>
<CUSTOMER>
<BIRTHDAY>2010-01-01</BIRTHDAY>
</CUSTOMER>
</PACKAGE>'
select
BIRTHDAY = t.cust.value('(BIRTHDAY)[1]', 'date')
FROM @xml.nodes('/PACKAGE/CUSTOMER') as t(cust)
go
drop xml schema collection dbo.[test]
네 글자 만 ... ~ 고맙습니다. –