keyref refer to another xsd's "key"

jacksuyu

Usenet Archive
Joined
Feb 4, 2005
Messages
28
Reaction score
0
I have two xsd files, in one xsd file, I defined a "key", I'd like to use "keyref" to refer to that "key" from another xsd file. But I always get attribute is empty error.

my.xsd is my first xsd file with "key", myphone.xsd is the keyref file which need to refer to the "key"

Thanks.

my.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.fisc.com" xmlns:fs="http://www.fisc.com" targetNamespace="http://www.fisc.com" elementFormDefault="qualified"> <xs:element name="name" type="xs:string"/> <xs:element name="cubic"> <xs:complexType> <xs:sequence> <xs:element ref="name"/> <xs:element name="devices" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="office"> <xs:complexType> <xs:sequence> <xs:element ref="cubic" minOccurs="2" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:key name="test0"> <xs:selector xpath="fs:cubic/fs:name"/> <xs:field xpath="."/> </xs:key> </xs:element> </xs:schema>

myphone.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:yb="http://www.yellowbook.com" targetNamespace="http://www.yellowbook.com" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:fs="http://www.fisc.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fisc.com C:\proj\xmlschema\my.xsd"> <xs:element name="phone"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="shareWith" type="xs:string"/> <xs:element name="phoneNumber" type="xs:integer"/> </xs:sequence> </xs:complexType> <xs:keyref name="shareWithKeyRef" refer="fs:test0"> <xs:selector xpath="yb:phone/yb:shareWith"/> <xs:field xpath="."/> </xs:keyref> </xs:element> </xs:schema>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top