Java Reference
In-Depth Information
A local element or type is one that is nested within another element or type. A local element
cannot be reused elsewhere.
Now let's look at the patterns.
Russian Doll
In real life, a Russian doll is a wooden shell that acts as a container for several other identical-
looking dolls, each of which is also a shell containing the next smaller doll. Opening the top
of the outermost doll reveals the next smaller doll.
This design pattern is perfectly named, and therefore easy to remember. The pattern is to cre-
ate a single global root element that contains, like its namesake, all of its constituent types; all
other elements beside this single global element are local. All element declarations are nested
inside the root element, and can therefore only be used once, within that context. The root ele-
ment is the only one that gets to use the global namespace.
Russian Doll has the following characteristics:
▪ It has a single global root element.
▪ All types are local, i.e., nested within the root element.
▪ It supports only schemas designed entirely in a single file.
▪ It has high cohesion with minimal coupling.
▪ Because types are not exposed, the schema is fully encapsulated.
▪ It is the easiest pattern to read and write.
Do not use Russian Doll if you need to reuse types.
Example 2-1 demonstrates the Russian Doll design pattern.
Example2-1.Book.xsd using the Russian Doll schema design pattern
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://ns.soacookbook.com/russiandoll"
xmlns:tns="http://ns.soacookbook.com/russiandoll"
elementFormDefault="unqualified">
<xsd:annotation>
<xsd:documentation>
Book schema as Russian Doll design.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="book">
<xsd:complexType>
<xsd:sequence>
Search WWH ::




Custom Search