[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: schema keyref to other schema.
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@s...] > Sent: 22 February 2005 10:46 > To: xml-dev@l... > Subject: 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> > >
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|