Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > keyref refer to another xsd's "key"

Reply
Thread Tools

keyref refer to another xsd's "key"

 
 
jacksuyu@gmail.com
Guest
Posts: n/a
 
      09-19-2005
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 xmlnss="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 xmlnss="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"
xmlnssi="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="ybhone/yb:shareWith"/>
<xs:field xpath="."/>
</xs:keyref>
</xs:element>
</xs:schema>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Key-keyref to attribute in root element Russell O'Connor XML 5 04-27-2004 08:32 AM
<key><keyref> does not work in XMLSpy Markus Seibold XML 0 02-13-2004 03:30 PM
XML schema - key/keyref and inheritance peterpeter XML 0 02-11-2004 01:38 PM
Can't use key and keyref with an attribute in a group J E E XML 0 11-07-2003 12:42 PM
Key/keyref validation in schema? Marek Malowidzki XML 1 08-19-2003 12:13 PM



Advertisments