Schema access type

For each XSD that Gosu loads, it creates a SchemaAccess object that represents the loaded XSD. The most important reason to load XSDs is to provide Gosu with additional schemas during XML parsing. SchemaAccess objects have a Schema property, which is the Gosu XML representation of the XSD. The Schema property contains the gw.xsd.w3c.xmlschema.Schema object that represents the XSD.

Example

Suppose you have this XSD loaded as schema.util.SchemaAccess.Schema:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="Element1"/>
  <xsd:element name="Element2"/>
  <xsd:element name="Element3"/>
</xsd:schema>

The following code prints the name of each element in the schema.

var schema = examples.pl.gosu.xml.myschema.util.SchemaAccess.Schema
schema.Element.each(\ el ->print(el.Name))

This code prints the following:

Element1
Element2
Element3

The following example uses the XSD of XSDs to print a list of primitive schema types:

var schema = gw.xsd.w3c.xmlschema.util.SchemaAccess.Schema
print(schema.SimpleType.map(\s -> s.Name))

This code prints the following:

[formChoice, reducedDerivationControl, derivationSet, typeDerivationControl, fullDerivationSet, 
    allNNI, blockSet, namespaceList, public, string, boolean, float, double, decimal, duration, dateTime, 
    time, date, gYearMonth, gYear, gMonthDay, gDay, gMonth, hexBinary, base64Binary, anyURI, QName, 
    NOTATION, normalizedString, token, language, IDREFS, ENTITIES, NMTOKEN, NMTOKENS, Name, NCName, 
    ID, IDREF, ENTITY, integer, nonPositiveInteger, negativeInteger, long, int, short, byte, nonNegativeInteger, 
    unsignedLong, unsignedInt, unsignedShort, unsignedByte, positiveInteger, derivationControl, simpleDerivationSet]

See also