Syntax | set anObject = aBlob.xmlToClass(); | |||
---|---|---|---|---|
Semantics | The operation takes an XML buffer as blob (aBlob) and tries to map the XML document to anObject. If this is not possible, an error is raised (e.g. XML parser errors, invalid mappings, etc.). By default the following mapping rules apply:
These default rules can be overridden by using <<XMLElement>>, <<XMLAttribute>> , and <<XMLCharacters>> stereotypes on UML class attributes and UML association ends. More about these mapping rules, stereotypes and tagged values (e.g. for number and date & time formatting) can be found in section XML - UML Class Mapping. | |||
Substitutables | aBlob | Can be any variable or object attribute having the type Blob. | ||
anObject | Target object, can be any object. | |||
Error Codes | Find the related error codes on Log Errors of domain XMLLM. | |||
XMLLM/3 | The native XML parser reported a fatal error during parsing. Read more on Troubleshooting XML - UML Class Mapping for more information if you cannot resolve such errors. | |||
Examples | set myAddress = addressASXMLDocument.xmlToClass(); The following action script creates an object of type Address. An output object node named myAddress of type Address needs to be defined in the activity diagram. create myAddress; set myAddress = addressASXMLDocument.xmlToClass(); Below, a sample XML document is shown to illustrate the mapping executed by xmlToClass() operation. The XML document is mapped to an instance of Address as depicted in the class diagram:
Note, that the XML element myAddress is of type Address. This type has the UML attribute id, which corresponds to the XML attribute id. Additionally, the XML elements street and city are mapped to the association ends city respectively street. Both are having the type String. |
The optional parameter of Figure: XML Parse Options Class Be aware that by default, schemas are parsed, but documents are not validated against them. Set the validation attribute to true if you want to enforce validation beyond well-formedness. For example, assume that you want to validate your document against a schema called CustomerData.xsd having the namespace http://example.com/customer . Then, the following xmlOption attributes have to be set: If the XML document refers a schema file (.xsd) with filename (and optional path), it is sufficient to put the schema file into the folder <e2e data>/resource. The E2E Bridge will automatically load this one instead of the specified. Using the administration interface of the Bridge, it is possible to load XML schemas into this folder remotely by using the following dialog: Figure: Uploading XML Schemas Refer to Deploying and Managing Resources in the Bridge User's Guide for more information on uploading of resources to the E2E Bridge. If the XML document refers no schema or you would like to provide another than the referred one, use the XMLParseOptions structure and set externalSchemaLocation (or externalNoNamespaceSchemaLocation) accordingly. As above, missing or relative paths will be redirected to the folder <e2e data>/resource. The same applies also for validating against DTDs. Be aware that validation is turned off by default (see option validation below). The following table lists all available XML options. Default values used when an option is not explicitly set are written in bold. Since the Bridge is using the Xerces parser internally, more information for all options can be found on the Xerces home page by following the read more link in the Description column. validation If this feature is set to true, the document must specify a grammar. validationDynamic validationSchema If set to true, the option namespaces must also be turned on. validationSchemaFullChecking This option checks the schema grammar itself for additional errors that are time-consuming or memory intensive. It does not affect the level of checking performed on document instances that use schema grammars. nonvalidatingLoadExternalDTD This feature is ignored and DTD is always loaded when the option validation is true. standardURIConformant If set to true, malformed URI will be rejected and fatal error will be issued. validationIdentityConstraintChecking validationSchemaSkip-DTDValidation disableDefaultEntityResolution namespaces If the validation option is set to true, then the document must contain a grammar that supports the use of namespaces. namespacePrefixes externalSchemaLocation The XML Schema Recommendation explicitly states that the inclusion of schemaLocation/noNamespaceSchemaLocation attributes in the instance document is only a hint; it does not mandate that these attributes must be used to locate schemas. Similar situation happens to <import> element in schema documents. This property allows the user to specify a list of schemas to use. If the targetNamespace of a schema specified using this method matches the targetNamespace of a schema occurring in the instance document in schemaLocation attribute, or if the targetNamespace matches the namespace attribute of <import> element, the schema specified by the user using this property will be used (i.e., the schemaLocation attribute in the instance document or on the <import> element will be effectively ignored). externalNoNamespaceSchemaLocation The XML Schema Recommendation explicitly states that the inclusion of schemaLocation/noNamespaceSchemaLocation attributes in the instance document is only a hint; it does not mandate that these attributes must be used to locate schemas. This property allows the user to specify the no target namespace XML Schema Location externally. If specified, the instance document's noNamespaceSchemaLocation attribute will be effectively ignored. scannerName This property allows the user to specify the name of the XMLScanner to use for scanning XML documents. Any integer, no default.XML Parsing Options (Validation against a Schema)
xmlToClass()
of type XMLOptions offers various parameters to control schema and DTD location and validation:externalSchemaLocation ="http://example.com/customer CustomerData.xsd";
validation = true;
Option Description Values
If this option is set to false and document specifies a grammar, that grammar might be parsed but no validation of the document contents will be performed.true Report all validation errors. false Do not report validation errors. read more true The parser will validate the document only if a grammar is specified. (validation must be true). false Validation is determined by the state of the validation option. true Enable the parser's schema support. false Disable the parser's schema support. true Enable full schema constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation restriction checking are controlled by this option. false Disable full schema constraint checking. true Load external DTD. false Ignore external DTD completely. true Force standard URI conformance. false Do not force standard URI conformance. read more true Enable identity constraint checking. false Disable identity constraint checking. read more true When validationSchema is true the parser will ignore the DTD, except for entities. false The parser will not ignore DTDs when validating. read more true The parser will not attempt to resolve the entity if the E2E Bridge can't find it. false The parser will attempt to resolve the entity on its own if the E2E Bridge can't find it. true Perform Namespace processing. false Do not perform Namespace processing. read more true Report the original prefixed names and attributes used for Namespace declarations. false Do not report attributes used for Namespace declarations, and optionally do not report original prefixed names. The syntax is the same as for schemaLocation attributes in instance documents: e.g, " http://www.example.com file_name.xsd". The user can specify more than one XML Schema in the list. The syntax is the same as for the noNamespaceSchemaLocation attribute that may occur in an instance document: e.g."file_name.xsd". The recognized scanner names are: WFXMLScanner A scanner that performs well-formedness checking only. DGXMLScanner A scanner that handles XML documents with DTD grammar information. SGXMLScanner A scanner that handles XML documents with XML schema grammar information. IGXMLScanner A scanner that handles XML documents with DTD or/and XML schema grammar information. entityExpansionLimit To mitigate an entity expansion attack (aka "XML bomb" or "the billion laughs" attack) you use this tagged value to limit entity expansion to the specified level.