Using XML Parameter Values - Amazon Mechanical Turk

Using XML Parameter Values

The HTMLQuestion,ExternalQuestion, QuestionForm, QuestionFormAnswers, and AnswerKey data structures are used as parameter values in service requests, and as return values in service responses. Unlike other data structures described in this API reference, these XML structures are not part of the service API directly, but rather are used as string values going in and out of the service. This article describes the encoding methods needed to use XML data as parameter and return values.

XML Data as a Parameter

Data must be URL encoded to appear as a single parameter value in the request. Characters that are part of URL syntax, such as question marks (?) and ampersands (&), must be replaced with the corresponding URL character codes.

Note

XML data should only be URL encoded, not XML escaped.

In service responses, this data will be XML escaped.

Namespaces for XML Parameter Values

XML data in parameter values must have a namespace specified for all elements. The easiest way to do this is to include an xmlns attribute in the root element equal to the appropriate namespace.

The namespace for a HTMLQuestion,ExternalQuestion, QuestionForm, QuestionFormAnswers, or AnswerKey element is identical to the URL of the corresponding schema document, including the version date. While XML namespaces need not be URLs according to the XML specification, this convention ensures that the consumer of the value knows which version of the schema is being used for the data.

For the locations of the schema documents, as well as instructions on how to include the version date in the URL, see Schema Locations.