Article directory
Chapter 26 Controlling Mapping to XML Schema - Compiler Keywords Affecting Schema
Compiler keywords that affect architecture
required
The keyword affects the schema by removing the minOccurs="0"
attribute. For example, consider the following class:XML
Class Schema.PropKeywords Extends (%RegisteredObject, %XML.Adaptor)
{
Parameter XMLTYPENAMESPACE="mytypes";
Property Property1 As %String;
Property Property2 As %String [ Required ];
}
If we generate the schema for the namespace used here, we see the following:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:s="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" targetNamespace="test">
<complexType name="PropKeywords">
<sequence>
<element minOccurs="0" name="Property1" type="s:string"/>
<element name="Property2" type="s:string"/>
</sequence>
</complexType>
</schema>
Note that the default value for minOccurs
is 1
; that is, Property2
is required.
Note: For compatibility reasons, %XML.Reader
does not check required properties by default, but it can be made to do so; see UsingXML
Check the required elements and attributes in the tool. Also, by default, the IRIS Web
service does not check for required attributes, but you can make it do so; see Checking for Required Elements and Attributes.
No other attribute keywords affect the schema of the data type class.
Parameters that affect XML
mode
IRIS
Data type classes use many parameters. (For a table listing the parameters supported by each data type class, see Defining and Using Data Types in Classes.) In most cases, you can also specify them as attribute parameters.
Influence The parameters of the XML
mode are as follows:
CONTENT
affects how attribute values are escaped; see Handling special XML
characters.
The value "MIXED
" results in a schema change compared to other possible values. Consider the following class:
Class Schema.CONTENT Extends (%RegisteredObject, %XML.Adaptor)
{
Parameter XMLTYPENAMESPACE = "mytypes";
Property Property1 As %String;
Property Property2 As %String(CONTENT = "STRING");
Property Property3 As %String(CONTENT = "ESCAPE");
Property Property4 As %String(CONTENT = "MIXED");
}
If we generate the schema for the namespace used here, we see the following:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:s="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" targetNamespace="mytypes">
<complexType name="CONTENT">
<sequence>
<element minOccurs="0" name="Property1" type="s:string"/>
<element minOccurs="0" name="Property2" type="s:string"/>
<element minOccurs="0" name="Property3" type="s:string"/>
<element name="Property4">
<complexType mixed="true">
<choice maxOccurs="unbounded" minOccurs="0">
<any processContents="lax"/>
</choice>
</complexType>
</element>
</sequence>
</complexType>
</schema>
Note that these three properties have the same type information because XML
handles them the same way. However, IRIS
attributes are handled differently, as described in Handling Special XML Characters.
If the object is used as input or output to a Web
method and SoapBodyUse
is coded for that method, thenIRIS
Will treat mixed content as default string content. That is, if CONTENT
is specified as "MIXED
", the value will be ignored.
DISPLAYLIST
affects the schema if VALUELIST
is also specified and XMLLISTPARAMETER
is equal to "DISPLAYLIST
". See the discussion of these two parameters.
MAXLEN
Control maxLength
An attribute that is an aspect or restriction. Facet
defines the values acceptable for the XML
type. The following examples show a few of them. Consider the following class:
Class Schema.BasicFacets Extends (%RegisteredObject, %XML.Adaptor)
{
Parameter XMLTYPENAMESPACE = "mytypes";
Property Property1 As %Integer (MINVAL=10, MAXVAL=1000);
Property Property2 As %String (MINLEN=20, MAXLEN=100);
}
If we generate the schema for the namespace used here, we see the following:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:s="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="mytypes">
<complexType name="BasicFacets">
<sequence>
<element minOccurs="0" name="Property1">
<simpleType>
<restriction base="s:long">
<maxInclusive value="1000"/>
<minInclusive value="10"/>
</restriction>
</simpleType>
</element>
<element minOccurs="0" name="Property2">
<simpleType>
<restriction base="s:string">
<maxLength value="100"/>
<minLength value="20"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
</schema>
When the SOAP
wizard or the XML
Schema Wizard finds maxLength
restrictions in the schema, it adds Set the MAXLEN
attribute parameters as needed.
MAXVAL
Controls maxInclusive
properties. See the example in MAXLEN
.
MINLEN
Controls minLength
properties. See the example in MAXLEN
.
When the SOAP Wizard or XML Schema Wizard finds a minLength
restriction in the schema, it sets the MINLEN
attribute parameter in the generated class as needed.
MINVAL
Controls minInclusive
properties. See the example in MAXLEN
.