Struct Annotations for XML

When converting between XML and Structs using xmlToStruct or structToXml, you can set and retrieve annotations that provide information that guides the conversion (or reverse conversion).

Use the $tags function to set or get the value of an annotation for a specific Struct. For example:

  • Get the value of the xmlClass annotation for Struct member div:
    vClass = MyStruct->div->$tags->xmlClass
  • Set the xmlClass of Struct member div to element:
    MyStruct->div->$tags->xmlClass = "element"
Annotation Tags for XML-Struct Conversions
Tag Values Comments
xmlClass
  • document
  • element
  • attribute
  • process-instruction
  • comment
  • doctype
  • entity-declaration
  • element-declaration
  • attlist-declaration
  • attribute-declaration
  • notation-declaration
  • namespace-declaration
  • CDATA
XML construct from which, or to which, the Struct member is converted.
xmlNamespaceURI Value of the namespace string URI of the namespace of this element or attribute
xmlNamespaceAlias Value of the alias string Alias (or prefix) used on this element to specify the namespace.
xmlVersion Value of the version attribute in the <?xml … ?> declaration On top level Struct only
xmlEncoding Value of the encoding attribute in the <?xml … ?> declaration On top level Struct only; optional.
xmlStandAlone

Value of the standalone attribute in the <?xml … ?> declaration

On top level Struct only; optional.

xmlDataType Data type On Structs for attributes and attribute declarations, unless it is CDATA, which is the default.

Set on elements, only if /schema is specified and the schema has defined a data type for it.

Note:  During conversion from Struct to XML it is possible to influence the output format by setting xmlDataType, unless the schema dictates it.

xmlTypeNamespace Namespace of URI of a schema-defined data type On attributes and elements when /schema is used and the schema has defined the data type with a namespace.
xmlTypeCategory simple 

complex

On attributes and elements when /schema is used and the data type comes from a schema.
xmlAttrMode #IMPLIED

#REQUIRED

#FIXED

On Structs for attribute list declarations
xmlPublicID Formal Public Id used to identify the DTD On Structs for DOCTYPE, entity declarations, and notation declarations
xmlSystemID URI for the file containing the DTD On Structs for DOCTYPE, entity declarations, and notation declarations
xmlNotation Name of notation declaration On Structs for unparsed external entity declaration

Namespace declarations also affect the annotations for elements and attributes. For more information, see XML Namespace Declaration.

Related Topics