Java Reference
In-Depth Information
Listing 7.7
Variable-content containers can delay type bindings
.
.
<xsd:element name= "InventoryItem"
type="i:InventoryItemType" />
.
.
O Defining the
namespace
O No schema
location in the
import!
<xsd:import namespace="http://www.inventoryItem.org" />
.
.
<xsd:element name= "InventoryList">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="InventoryItem"
type="i:InventoryItemType"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</schema>
O Use the imported
type in another
namespace.
Listing 7.7 shows this approach is appropriately called the dangling type. We'll
bind to the schema location in the instance document. Using this approach,
we delay binding of the types until runtime. We can then let individual
instances define types appropriate to their application. We gain all of the bene-
fits of the first three approaches, and we enjoy the additional benefit of com-
plete type freedom. Unfortunately, as I am finishing Bitter Java , the dangling
type is not yet implemented in the major schema validators. The way around
this is to use anyType :
<xsd:element name= "InventoryItem"
type="anyType " />
7.6.4
XML versioning
In the section “Creating multiple interfaces,” we mentioned that we might
want to collect different versions of the same interface to preserve compatibil-
ity. With XML , we can avoid some of the problems that lead to interface ver-
sioning, but sometimes we're faced with incompatible versions of the same
schema. Here's how we can provide better versioning support:
Search WWH ::




Custom Search