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
hone/yb:shareWith"/> <xs:field xpath="."/> </xs:keyref> </xs:element> </xs:schema>
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