OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   schema keyref to other schema.

[ Lists Home | Date Index | Thread Index ]

Hi

I defined two schemas somewhat like a RDB model. One holds a primary key 
and the other one a foreign key pointing to the primary key. Now the 
schemas are valid (in Stylus Studio XML) but i can't get the xml file to 
validate. How can i tell the "slave"-xml file to include the "master" 
file? Any help is really appreciated!

key.xsd
-------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:test="http://www.test.com/test"; 
targetNamespace="http://www.test.com/test"; 
elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="root">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="primary" type="xs:string">
                    <xs:key name="PrimaryKey">
                        <xs:selector xpath="./primary"/>
                        <xs:field xpath="."/>
                    </xs:key>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

foreignKey.xsd
--------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:test="http://www.test.com/test"; elementFormDefault="qualified" 
attributeFormDefault="unqualified">
    <xs:import namespace="http://www.test.com/test"; 
schemaLocation="Key.xsd"/>
    <xs:element name="root">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="foreignKey" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
        <xs:keyref name="ForeignKeyRef" refer="test:PrimaryKey">
            <xs:selector xpath="./foreignKey"/>
            <xs:field xpath="."/>
        </xs:keyref>
    </xs:element>
</xs:schema>

TestKey.xml -> valid!
------------
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.test.com/test";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://www.test.com/test D:\Temp\FK\Key.xsd">

    <primary>Primary</primary>
</root>

TestForeignKey.xml Error: The keyref 'ForeignKeyRef' refers to a 
key/unique that is out of scope.
------------------
<?xml version="1.0" encoding="UTF-8"?>
<root     xmlns:test="http://www.test.com/test";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:noNamespaceSchemaLocation="D:\Temp\FK\ForeignKey.xsd">
    <foreignKey>Primary</foreignKey>
</root>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS