Reference of XSD properties and types

The following table lists the types and properties that Gosu creates from an XSD. For this topic, schema represents the fully qualified path to the schema, elementName represents an element name, and parentName and childName represent names of parent and child elements.

For a property, the rightmost column indicates whether the property can appear more than once, in which case the property becomes a list property. If the rightmost column contains “Yes”, the property has type java.util.List parameterized on the type that the property has when it is singular. For example, suppose a child element is declared in the XSD with the type xsd:int:

  • If its maxOccurs is 1, the property’s type is Integer.
  • If its maxOccurs is greater than 1, the property’s type is List<Integer>, which is a list of integers.

There are other circumstances in which a property becomes a list. For example, suppose there is a XSD choice (<xsd:choice>) in an XSD that has maxOccurs attribute value greater than 1. Any child elements become list properties. For example, if the choice defines child elements with names "elementA" and "elementB", Gosu creates properties called ElementA and ElementB, both declared as lists. Be aware that Gosu exposes shortcuts for inserting items.

Notes about generated types containing the text anonymous in the fully qualified type name:

  • Although the package includes the word anonymous, this does not imply that these elements have no defined names. The important quality that distinguishes these types is that the object is defined at a lower level than the top level of the schema. By analogy, this is similar to how Gosu and Java define inner classes within the namespace of another class.
  • Several rows contain a reference to the path from root as the placeholder text PathFromRoot. The path from root is a generated name that embeds the path from the root of the XSD, with names separated by underscore characters. The intermediate layers may be element names or group names. See each row for examples.

The following table lists XML definitions and the syntax for accessing an item that the definition describes.

Definition

New item

Syntax...

An element at the top level

Type

schema.ElementName

Important: However, Gosu behaves slightly differently if the top-level element is declared in a web service definition language (WSDL) document. Instead, Gosu creates the type name as schema.elements.ElementName.

An element lower than the top level

Type

schema.anonymous.elements.PathFromRoot_ElementName

For example, suppose the top level group A that contains an element called B, which contains an element called C. The PathFromRoot is A_B and the fully qualified type is schema.anonymous.elements.A_B_C.

A complex type at the top level

Type

schema.types.complex.TypeName

A complex type lower than the top level

Type

schema.anonymous.types.complex.PathFromRoot

For example, suppose a top level element A contains an embedded complex type. The PathFromRoot is A. Note that complex types defined at a level lower than the top level never have names.

A simple type at the top level

Type

schema.types.simple.TypeName

A simple type lower than the top level

Type

schema.anonymous.types.simple.PathFromRoot

For example, suppose a top level element A contains element B, which contains an embedded simple type. The path from root is A_B. Simple types defined at a level lower than the top level never have names.

An attribute at the top level

Type

schema.attributes.AttributeName

An attribute

Type

schema.anonymous.attributes.PathFromRoot

For example, suppose a top level element A contains element B, which has the attribute C. The pathPathFromRoot is A_B and the fully qualified type is schema.anonymous.attributes.A_B_C.

An attribute lower than the top level

Property

element.AttributeName

Unlike most other generated properties on XSD types, an attribute property never transforms into a list property.

A common pattern converts a simpleType to simpleContent to add attributes to an element with a simple type. To support this pattern, Gosu provides the ChildName and ChildName_elem properties for every child element that has either a simple type or both a complex type and simple content. The property with the _elem suffix on its name contains the element object instance. The property without the _elem suffix contains the element value. Because of this design, if you later decide to add attributes to a simpleType element, the change does not require modification of your existing XML code.

The following table lists XML definitions for child elements and the syntax for accessing an item that the definition describes. These items can occur anywhere in the schema.

Definition

New item

Syntax...

A child element with either of:

  • A simple type
  • A complex type and a simple content

Property

element.ChildName_elem

The property type is as follows:

  • If element is defined at top-level, schema.ElementName
  • If element is defined at lower levels, schema.anonymous.elements.PathFromRoot_ElementName.
Important: If this property can appear more than once, it transforms into a list type.

The value of a child element with either of:

  • A simple type
  • A complex type and a simple content

Property

element.ChildName

The property type is as follows:

  • If element is defined at top-level, schema.ElementName
  • If element is defined at lower levels, schema.anonymous.elements.PathFromRoot_ElementName.
Important: If this property can appear more than once, it transforms into a list type.

A child element with a complex type and no simple content

Property

element.ChildName

The property type is as follows:

  • If element is defined at top-level, schema.ElementName
  • If element is defined at lower levels, schema.anonymous.elements.PathFromRoot_ElementName.
Important: If this property can appear more than once, it transforms into a list type.

The following table lists the XML definition and the syntax for accessing an XML schema.

Definition

New item

Syntax...

Schema

definition

Schema access object

schema.util.SchemaAccess

This special utility object provides access to the original schema that produced this type hierarchy. This object represents this schema. Use this object if you need one schema to include another schema.

See also