XML schema basics for wildcard elements

You can use the xs:any element to extend the XML document with elements not specified by the schema. You can use xs:sequence or xs:choice as parent elements for the wildcard elements.

For Infor BODs, the wildcard element is used in the complex type UserAreaType which is used for all UserArea elements. The complex type UserAreaType is defined in this generic schema:

..\..\Resources\Components\Common\Fields.xsd

This table shows the description of the namespace and processContents attributes:

Attribute Description
namespace

Optionally, use this attribute to specify the namespaces containing the elements to use.

You can set this attribute to one of these:

  • ##any for elements from any namespace is allowed

  • ##other for elements from any namespace that is not the namespace of the parent element can be present

  • ##local for elements must come from no namespace

  • ##targetNamespace for elements from the namespace of the parent element can be present

  • List of {URI references of namespaces, ##targetNamespace, ##local} for elements from a space-delimited list of the namespaces that can be present

ProcessContents

Optionally, use this attribute to specify how the XML processor should handle validation against the elements specified by this any element.

You can set this attribute to one of these:

  • strict: the XML processor must obtain the schema for the required namespaces and validate the elements. This is the default.

  • lax: the same as strict, but if you cannot obtain the schema, then no errors occur.

  • skip: the XML processor does not attempt to validate any elements from the specified namespaces.

Mapper and mapper runtime only support namespace="##any" and processContents="strict". You can use any element defined in any namespace as replacement element. The replacement element must be declared in the schema for the default namespace or in any other custom namespace with a custom schema that is referenced from the instance document.

To validate the instance document, it must have a reference to its schema. The attribute xmlns in this example specifies the default namespace declaration:

xmlns="http://schema.infor.com/InforOAGIS/2"

This declaration tells the schema-validator that all non-prefixed elements used in this XML document are declared in the namespace "http://schema.infor.com/InforOAGIS/2".

When you have the XML Schema Instance namespace available xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" you can use the attribute xsi:schemaLocation


xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 
http://schema.infor.com/2.6.4/InforOAGIS/BODs/Developer/SyncProductionOrder.xsd"
. This attribute has two values separated by a space. The first value is the namespace to use. The second value is the location of the XML schema to use for that namespace, for example:

The schema-validator can validate all elements that belong to the default namespace, that is, non-prefixed elements, and elements that belong to other namespaces defined in the schema.

To use a replacement element that is not declared in the referenced schema, you must declare the replacement element in a custom namespace. Then, give a reference to the custom schema for that namespace.

You can use several custom namespaces in an Instance document.

  1. Specify the custom namespace declaration.

    You connect the custom namespace with a prefix, for example xmlns:cust="http://schema.infor.com/InforOAGIS/Custom".

    In this example, the prefix "cust" is used for all elements that are declared in the custom namespace "http://schema.infor.com/InforOAGIS/Custom". This attribute has two values separated by a space. The first value is the name.

  2. Add the location of the custom schema for the custom namespace in the attribute "xsi:schemaLocation".

    Follow this code:

    
    xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 
    http://schema.infor.com/2.6.4/InforOAGIS/BODs/Developer/SyncProductionOrder.xsd 
    http://schema.infor.com/InforOAGIS/Custom CustomHeader.xsd"

The schema-validator can find schemas for both the default namespace and for the custom namespaces provided that the URLs for the schema files are correct.

You can have several custom namespaces in an Instance document. You can also have several custom schemas for one custom namespace, using replacement elements declared in the same custom namespace, but from different custom schemas. The custom namespaces and custom schemas are listed as pairs in the xsi:schemaLocation attribute value.

This is an example of a root tag for an Infor BOD where you have one custom namespace and two custom schemas:


<SyncProductionOrder xmlns="http://schema.infor.com/InforOAGIS/2" 
xmlns:cust="http://schema.infor.com/InforOAGIS/Custom" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 
http://schema.infor.com/2.6.4/InforOAGIS/BODs/Developer/SyncProductionOrder.xsd 
http://schema.infor.com/InforOAGIS/Custom 
custom/UserAreaExtensions/Ferrari/CustomHeader.xsd 
http://schema.infor.com/InforOAGIS/Custom 
custom/UserAreaExtensions/Ferrari/CustomDetail.xsd" releaseID="9.2" versionID="2.6.4">

This is the corresponding CustomHeader schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schema.infor.com/InforOAGIS/Custom" 
targetNamespace="http://schema.infor.com/InforOAGIS/Custom" elementFormDefault="qualified" 
attributeFormDefault="unqualified">
	<xs:element name="AdditionalInformation">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="ReceivingWarehouse" type="xs:string"/>
				<xs:element name="SoldToBPName" minOccurs="0" maxOccurs="unbounded">
					<xs:complexType>
						<xs:simpleContent>
							<xs:extension base="xs:string">
								<xs:attribute name="languageID"/>
							</xs:extension>
						</xs:simpleContent>
					</xs:complexType>
				</xs:element>
				<xs:element name="ShipToBPName" minOccurs="0" maxOccurs="unbounded">
					<xs:complexType>
						<xs:simpleContent>
							<xs:extension base="xs:string">
								<xs:attribute name="languageID"/>
							</xs:extension>
						</xs:simpleContent>
					</xs:complexType>
				</xs:element>
				<xs:element name="InterfaceUpdate" type="xs:string"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>
Note: The custom namespace must be declared as target namespace in all custom schemas.

In this BOD instance example, the replacement element "Property" is declared in the default namespace, while the replacement element "AdditionalInformation" is declared in the custom namespace "http://schema.infor.com/InforOAGIS/Custom" and uses the prefix "cust".

The replacement element "Property" is defined in the standard BOD schema, and the replacement element "cust:AdditionalInformation" is defined in the CustomHeader schema.


<UserArea>
	<Property>
		<NameValue name="ln.Priority" type="NumericType">999</NameValue>
	</Property>
	<Property>
		<NameValue name="ln.Owner" type="StringType">SFC</NameValue>
	</Property>
	<Property>
		<NameValue name="ln.Routing" type="StringType">001</NameValue>
	</Property>
	<cust:AdditionalInformation>
		<cust:ReceivingWarehouse>WHAMS1</cust:ReceivingWarehouse>
		<cust:SoldToBPName/>
		<cust:SoldToBPName languageID=""/>
		<cust:ShipToBPName/>
		<cust:ShipToBPName languageID=""/>
		<cust:InterfaceUpdate>No</cust:InterfaceUpdate>
	</cust:AdditionalInformation>
</UserArea>

Instead of defining the structure of an XML document only in one schema for the default namespace, the instance document can also use additional custom namespaces and provide references to custom schemas.