keyref refer to another xsd's "key"

Discussion in 'XML' started by jacksuyu@gmail.com, Sep 19, 2005.

  1. Guest

    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>
     
    , Sep 19, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marek Malowidzki

    Key/keyref validation in schema?

    Marek Malowidzki, Aug 18, 2003, in forum: XML
    Replies:
    1
    Views:
    538
    Mark Preston
    Aug 19, 2003
  2. J E E
    Replies:
    0
    Views:
    394
    J E E
    Nov 7, 2003
  3. peterpeter
    Replies:
    0
    Views:
    965
    peterpeter
    Feb 11, 2004
  4. Kent B

    XSD keyRef

    Kent B, Nov 15, 2005, in forum: XML
    Replies:
    0
    Views:
    903
    Kent B
    Nov 15, 2005
  5. boeledi

    XSD: key and keyref problem

    boeledi, Oct 15, 2007, in forum: XML
    Replies:
    4
    Views:
    1,180
    Kris824
    Sep 6, 2012
Loading...

Share This Page