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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] schema keyref to other schema.

[ Lists Home | Date Index | Thread Index ]

The scope of XML Schema validation is a single document.

The only way to do validation across multiple documents is to do a
transformation that assembles them into a single document and then apply
validation to that.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Stephan Dick [mailto:stephan.dick@siemens.com] 
> Sent: 22 February 2005 10:46
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] schema keyref to other schema.
> 
> 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>
> 
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 






 

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

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