KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Avoiding illegal XML names
PRODUCT: 4D | VERSION: 2003 | PLATFORM: Mac & Win
Published On: December 18, 2003

The rules for naming 4th Dimension objects and XML entities differ, notably spaces are allowed in 4th Dimension and forbidden in XML. An XML file or message containing bad names is not well-formed and is therefore unparsable. 4th Dimension can create XML names in three common situations, two of which allow a developer to publish illegal XML names:

1- Exporting data in XML format.
2- Offering a method as a Web Service.
3- Publishing a variable, array or parameter as a SOAP input.

Exporting Data
The Export Editor automatically renames fields during export to make them legal XML names. For example, a field named First Name in 4th Dimension is exported as First_Name in XML.

Offering a Method as a Web Service
The names of methods offered as Web Services become the basis of XML names used in SOAP requests made to the method. For example, a method named Get Sales Report becomes the basis for two XML message names: Get Sales ReportRequest and Get Sales ReportResponse. These are illegal XML names because they include space characters. 4th Dimension does not automatically prevent this error so developers should rename published methods to conform to the rules for XML names.

Publishing a Value
Methods offered as Web services may publish parameters, process arrays, and process variables as SOAP input and/or output values. The SOAP DECLARATION command enables developers to define the XML name for the value, as in the example shown below:

SOAP DECLARATION(soapInput;Is Text ;SOAP Input ;"Incoming Text")

In the preceding example, the code defines the name Incoming Text, illegal XML because of the space character. 4th Dimension does not automatically prevent this error so developers should make sure to double-check their calls to SOAP DECLARATION.

A few key rules for XML names are listed below:

- XML names are case-sensitive, 4th Dimension names are not.
- XML names may not contain whitespace of any kind, notably the space character.
- XML names have no length limit.
- XML names starting with XML in any case combination are reserved.