The operation takes an XML string (
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.
|Substitutables||An XML document as String.|
|Target object, can be any object.|
|This is an optional parameter of type Base Components::Basic Behavior::XML::XMLOptions. This parameter controls the parsing behavior. For example, it defines whether the XML document is validated against an XML schema. The available options are explained below.|
The action script below creates an object of type Address. An output object flow state named myAddress of type Address needs to be defined in the activity diagram.
Beneath, a sample XML document is shown to illustrate the mapping executed by the
Note, that the XML element myAddress is mapped to the object myAddress, which 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 assocition ends city respectivly street. Both are having the type String.
XML Parsing Options (Validation against a Schema)
The optional parameter of
xmlToClass() of type XMLOptions offers various parameters to control schema and DTD location and validation:
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 . 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).
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.
If this feature is set to true, the document must specify a grammar.
|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.|
If set to true, the option namespaces must also be turned on.read more
|true||Enable the parser's schema support.|
|false||Disable the parser's schema support.|
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.read more
|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.|
This feature is ignored and DTD is always loaded when the option validation is true.read more
|true||Load external DTD.|
|false||Ignore external DTD completely.|
If set to true, malformed URI will be rejected and fatal error will be issued.read more
|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.|
If the validation option is set to true, then the document must contain a grammar that supports the use of namespaces.read more
|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 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).read more
|The syntax is the same as for schemaLocation attributes in instance documents: e.g, "file_name.xsd". The user can specify more than one XML Schema in the list.|
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.read more
|The syntax is the same as for the noNamespaceSchemaLocation attribute that may occur in an instance document: e.g."file_name.xsd".|
This property allows the user to specify the name of the XMLScanner to use for scanning XML documents.read more
|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.|
Any integer, no default.