Java Reference
In-Depth Information
Using Chameleon Namespace Design
Problem
You want to design a clever workaround for namespace dependencies within your schemas
and think that using a Chameleon pattern will work within an SOA.
Solution
Don't do this. The Chameleon pattern is very clever. Its approach is to have you design your
common types in a schema with no namespace, called the Chameleon. You then define a
“master” schema that does have a namespace that <include> s the first schema. The common
types from the Chameleon get namespace-coerced and assume the namespace defined in the
master. Examples 2-5 and 2-6 show how this works.
Example2-5.Chameleon customer
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<!-- Defined without namespace -->
<xsd:complexType name="CustomerType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Example2-6.Master invoice schema namespace-coerces the Chameleon
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:Invoice"
xmlns="urn:Invoice"
elementFormDefault="qualified">
<xsd:include schemaLocation="CustomerChameleon.xsd"/>
<!-- Invoice has a Product and a Customer -->
<xsd:element name="Invoice">
<xsd:complexType>
<xsd:sequence>
<!-- Define product here -->
Search WWH ::




Custom Search