码迷,mamicode.com
首页 > 其他好文 > 详细

sedna不支持xml schema

时间:2015-07-08 12:59:51      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:linux   xml   xquery   sedna   数据库   

book.xsd:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:complexType name="book_type">
        <xs:sequence>
            <xs:element name="name" type="xs:string" />
            <xs:element name="author" type="xs:string" />
            <xs:element name="price" type="xs:unsignedInt" />
            <xs:element name="date" type="xs:string" />
        </xs:sequence>
    </xs:complexType>

    <xs:element name="books">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="book" type="book_type" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema> 

book.xml:

<?xml version="1.0" encoding="utf-8" ?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:noNamespaceSchemaLocation="book.xsd" >
    <book>
        <name>The Call Of Wild</name>
        <author>Jack London</author>
        <price>32</price>
        <date>2015-7-6</date>
    </book>
    <book>
        <name>Wuthering Heights</name>
        <author>Emily Bronte</author>
        <price>40</price>
        <date>2015-7-5</date>
    </book>
</books>

用xmllint校验一下book.xml是否遵循book.xsd的规格:

[xuzhina@localhost bin]$ xmllint --schema book.xsd book.xml
<?xml version="1.0" encoding="utf-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd">
	<book>
		<name>The Call Of Wild</name>
		<author>Jack London</author>
		<price>32</price>
		<date>2015-7-6</date>
	</book>
	<book>
		<name>Wuthering Heights</name>
		<author>Emily Bronte</author>
		<price>40</price>
		<date>2015-7-5</date>
	</book>
</books>
book.xml validates

修改一下book.xml的price:

<?xml version="1.0" encoding="utf-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd">
	<book>
		<name>The Call Of Wild</name>
		<author>Jack London</author>
		<price>3w2</price>
		<date>2015-7-6</date>
	</book>
	<book>
		<name>Wuthering Heights</name>
		<author>Emily Bronte</author>
		<price>hello</price>
		<date>2015-7-5</date>
	</book>
</books>

结果:

[xuzhina@localhost bin]$ xmllint --schema book.xsd book.xml
<?xml version="1.0" encoding="utf-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd">
	<book>
		<name>The Call Of Wild</name>
		<author>Jack London</author>
		<price>3w2</price>
		<date>2015-7-6</date>
	</book>
	<book>
		<name>Wuthering Heights</name>
		<author>Emily Bronte</author>
		<price>hello</price>
		<date>2015-7-5</date>
	</book>
</books>
book.xml:7: element price: Schemas validity error : Element 'price': '3w2' is not a valid value of the atomic type 'xs:unsignedInt'.
book.xml:13: element price: Schemas validity error : Element 'price': 'hello' is not a valid value of the atomic type 'xs:unsignedInt'.
book.xml fails to validate

现在把book.xml导入到sedna的books数据库,看看sedna会不会验证xml schema:

[xuzhina@localhost bin]$ ./se_term -query "LOAD 'book.xml' 'book'" books
Bulk load succeeded

结论:sedna不支持xml schema校验。

版权声明:本文为博主原创文章,未经博主允许不得转载。

sedna不支持xml schema

标签:linux   xml   xquery   sedna   数据库   

原文地址:http://blog.csdn.net/xuzhina/article/details/46800803

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!