Unmarshal methods
An unmarshal method populates an object with data from an XML document instance. The methods throw an rwsf::XmlParseException when the XML document contains serious structural problems. The methods ignore minor defects. For example, an unmarshal method silently ignores attributes not mentioned in the schema, but throws an exception if a required attribute is not present.
HydraExpress creates two static unmarshal methods, and two instance unmarshal methods. The static methods allow HydraExpress to unmarshal a derived class as a base class without determining the precise type of the class ahead of time.
The first static unmarshal method unmarshals XML content from an input string, using the specific (but optional) element name:
 
static void
unmarshal(const std::string& input, elementType& element,
const rwsf::XmlName& elementName = DefaultElementName);
This method unmarshals content into the element provided, using the elementName provided.
The elementType is the type of the class that contains the method. The type of the input argument is the type mapped to xsd:string. For example, in classes generated with the ‑SourcePro flag, the method accepts an RWCString as the first argument.
The second static unmarshal method unmarshals an element from the provided rwsf::XmlReader into the provided element:
 
static void
unmarshal(rwsf::XmlReader& reader, elementType& element,
const rwsf::XmlName& elementName = DefaultElementName);
This method unmarshals content from the reader into the element provided, using the elementName provided. The elementType is the type of the class that contains the method.
The instance unmarshal methods have signatures similar to the static functions. Instance methods simply forward *this and the parameters provided to the static methods.
HydraExpress unmarshal methods convert the contents of the XML document to UTF-8, regardless of the original encoding of the document. The parser determines the original encoding of the document via the encoding declaration in the prolog, or by inspecting the first few bytes of the document if no encoding is declared.
Note that if HydraExpress determines that the document is UTF-8, then the parser does not perform character conversion on the document. See the class reference entry on rwsf::XmlReader for details on the character sets that HydraExpress supports.