以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  xml schema keyref 跨文件外键关联  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=71141)


--  作者:geek87
--  发布时间:1/6/2009 10:36:00 AM

--  xml schema keyref 跨文件外键关联
stu.xsd
-----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cla="http://www.power.com/class" >
<xs:import namespace="http://www.power.com/class" schemaLocation="class.xsd"/>
    <xs:element name="student">
        <xs:complexType>
            <xs:all>
                <xs:element name="stu_id" type="xs:int"/>
                <xs:element name="name" type="xs:string"/>
                <xs:element name="class_id" type="xs:int"/>
            </xs:all>
        </xs:complexType>
        <xs:key name="key_sut">
            <xs:selector xpath=".//stu_id"></xs:selector>
            <xs:field xpath="."></xs:field>
        </xs:key>
        <xs:keyref refer="cla:key_class" name="keyref_class">
            <xs:selector xpath=".//class_id"></xs:selector>
            <xs:field xpath="."></xs:field>
        </xs:keyref>
    </xs:element>
</xs:schema>

class.xsd
-----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cla="http://www.power.com/class" targetNamespace="http://www.power.com/class">
    <xs:element name="class">
        <xs:complexType>
            <xs:all>
                <xs:element name="class_id" type="xs:int"/>
                <xs:element name="class_name" type="xs:string"/>
            </xs:all>
        </xs:complexType>
        <xs:key name="key_class">
            <xs:selector xpath=".//class_id"></xs:selector>
            <xs:field xpath="."></xs:field>
        </xs:key>
    </xs:element>
</xs:schema>

错误区域:
-----------------------------------------------------------------------------------------------------
<xs:keyref refer="cla:key_class" name="keyref_class">
    <xs:selector xpath=".//class_id"> </xs:selector>
    <xs:field xpath="."> </xs:field>
</xs:keyref>

不知道如何是好,才能达到跨文件外键关联。。


--  作者:hexun831012
--  发布时间:1/21/2009 11:11:00 PM

--  
就我所知keyref是MSXML的特例,不推荐
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms