|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ws4d.java.schema.ElementContainer
public abstract class ElementContainer
This class represents the model group part of XML Schema.
http://www.w3.org/ TR/xmlschema11-1/#Model_Groups
It allows to add elements, groups and other containers.
It is possible to create nested container structures like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org"> <element name="nested" type="nestedType" /> <xs:complexType name="nestedType"> <xs:all> <xs:element name="a" type="xs:string" /> <xs:element name="b" type="xs:string" /> <xs:sequence> <xs:element name="c" type="xs:string" /> <xs:element name="d" type="xs:string" /> <xs:choice> <xs:element name="e" type="xs:string" /> <xs:element name="f" type="xs:string" /> </xs:choice> </xs:sequence> </xs:all> </xs:complexType> </xs:schema>
// get primitive data types Type xsString = SchemaUtil.getSchemaType("string"); // create inner elements Element a = new Element(new QName("a", "http://www.example.org"), xsString); Element b = new Element(new QName("b", "http://www.example.org"), xsString); Element c = new Element(new QName("c", "http://www.example.org"), xsString); Element d = new Element(new QName("d", "http://www.example.org"), xsString); Element e = new Element(new QName("f", "http://www.example.org"), xsString); // create the nested structure (bottom-up) ChoiceContainer choice = new ChoiceContainer(); choice.addElement(e); choice.addElement(f); SequenceContainer sequence = new SequenceContainer(); sequence.add(c); sequence.add(d); sequence.addContainer(choice); // create the complex type ComplexType nestedType = new ComplexType(new QName("nestedType", "http://www.example.org"), ComplexType.CONTAINER_ALL); nestedType.addElement(a); nestedType.addElement(b); // get the enclosed container and add the other container AllContainer all = nestedType.getContainer(); all.addContainer(sequence);
Field Summary |
---|
Fields inherited from interface org.ws4d.java.schema.Any |
---|
ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_VALUE_FALSE, ATTRIBUTE_VALUE_TRUE, TAG_ANY, TAG_ANYATTRIBUTE |
Method Summary | |
---|---|
void |
addAnyElement(AnyElement e)
Adds an any element to the container. |
void |
addContainer(ElementContainer container)
Adds another container to this container. |
void |
addElement(Element e)
Adds an element to the container. |
void |
addGroup(Group g)
Adds a group of elements to the container. |
Iterator |
all()
|
Iterator |
allElements()
Returns an iterator of elements from this container and all elements from nested containers. |
Iterator |
containers()
Returns an iterator of containers inside this container. |
Iterator |
getContainerContent()
|
abstract int |
getContainerType()
Returns the information about the type of this container. |
Element |
getElementByName(QName name)
Returns an element from the container with matching name. |
Element |
getElementByName(java.lang.String name)
Returns an element with matching name from the container. |
int |
getElementCount()
Returns the element count of the enclosed containers. |
Element |
getFirstElement()
|
int |
getInnerContainerCount()
Returns the number of containers inside this container. |
Element |
getLocalElementByName(QName name)
Returns a local element (i.e. one that is directly contained by this container) from the container with matching name. |
Element |
getLocalElementByName(java.lang.String name)
Returns a local element (i.e. one that is directly contained by this container) with matching name from the container. |
int |
getMaxOccurs()
Returns the maximum occurrence for the container. |
int |
getMinOccurs()
Returns the minimum occurrence for the container. |
boolean |
hasElements()
Returns true if the container has element definitions,
false otherwise. |
Iterator |
listAll()
|
void |
mergeContainer(ElementContainer container)
Merge one container into this container. |
Iterator |
ownElements()
Returns an iterator of elements from this container. |
void |
setMaxOccurs(int max)
Sets the maximum occurrence for the container. |
void |
setMinOccurs(int min)
Sets the minimum occurrence for the container. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.ws4d.java.schema.Any |
---|
getSchemaIdentifier |
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public int getMinOccurs()
The "minOccurs" attribute in XML Schema describes the minimum occurrence of the container inside the created XML instance document.
public int getMaxOccurs()
The "maxOccurs" attribute in XML Schema describes the maximum occurrence of the container inside the created XML instance document.
public void setMinOccurs(int min)
The "minOccurs" attribute in XML Schema describes the minimum occurrence of the container inside the created XML instance document.
min
- the minimum occurrence for the container.public void setMaxOccurs(int max)
The "maxOccurs" attribute in XML Schema describes the maximum occurrence of the container inside the created XML instance document.
max
- the maximum occurrence for the container.public void mergeContainer(ElementContainer container)
container
- the container which should be merged with this one.public int getInnerContainerCount()
public void addContainer(ElementContainer container)
container
- the container to add.public void addElement(Element e)
e
- the element to add.public void addAnyElement(AnyElement e)
e
- the element to add.public void addGroup(Group g)
g
- the group to add.public int getElementCount()
public Element getElementByName(QName name)
name
- the qualified name of the element which should be returned.
public Element getLocalElementByName(QName name)
name
- the qualified name of the element which should be returned.
public Element getElementByName(java.lang.String name)
This method will NOT verify the namespace.
name
- the name of the element which should be returned.
public Element getLocalElementByName(java.lang.String name)
This method will NOT verify the namespace.
name
- the name of the element which should be returned.
public Iterator listAll()
public Iterator containers()
public Iterator all()
public Element getFirstElement()
public Iterator ownElements()
public Iterator allElements()
public Iterator getContainerContent()
public boolean hasElements()
true
if the container has element definitions,
false
otherwise.
true
if the container has element definitions,
false
otherwise.public abstract int getContainerType()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |