- From: Gavin Kistner <phrogz@mac.com>
- Date: Fri, 14 Mar 2008 11:45:51 -0700
- To: Michael Kay <mike@saxonica.com>
- Cc: xmlschema-dev@w3.org
On Friday, March 14, 2008, at 01:15AM, "Michael Kay" <mike@saxonica.com> wrote:
>Yes, you can do this. You just use
><xs:attribute ref="foo:msg"/>
>or
><xs:element ref="bar:charlie"/>
>
>In this schema document you need to declare the namespace prefix and do an
>xs:import for the schema document where the other attribute/element is
>declared; then you put the declaration itself in a separate module with a
>different targetNamespace.
Thank you for your help; I had actually tried this, but had made typos in my namespaces and thought I was on the wrong track. Trying it again proved successful.
For the archives, here's a triplet of sample files showing the success:
<!-- foo.xsd -->
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bar="http://www.bar.com" xmlns="http://www.foo.com/">
<xs:import namespace="http://www.bar.com" schemaLocation="bar.xsd"/>
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="native">
<xs:complexType>
<xs:attribute ref="bar:foreign" use="required"/>
</xs:complexType>
</xs:element>
<xs:element ref="bar:jim"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<!-- bar.xsd -->
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.bar.com">
<xs:element name="jim">
<xs:complexType>
<xs:attribute name="whee" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:attribute name="foreign" type="xs:string" fixed="YAY" />
</xs:schema>
<!-- foo_test.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:bar="http://www.bar.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="foo.xsd">
<native bar:foreign="YAY"/>
<bar:jim whee="all good"/>
</root>
Received on Friday, 14 March 2008 18:46:31 UTC