Deprecated. XML Maps are deprecated as of the WebLogic Platform 8.1 release. For new code, use XQuery maps. For more information, see Introduction to XQuery Maps.

# <xm:bind> Attribute

Declares a variable within a map and initializes to a variable of the declaration.

## Syntax

    <elementName xm:bind="elementName variableNameVariable is dataStructure.arrayMember[,...]"
    >

## Attributes

bind

A statement declaring a variable and initializing it to a parameter variable.

## Remarks

The <xm:bind> attribute is especially useful when you need to bind the XML value to a member of a data structure, while also assigning it a short variable name. The <xm:bind> attribute also specifies that the object corresponding to the variable you're binding should not be instantiated unless the tag is encountered in the instance document.

In the following example, <xm:bind> makes it possible to declare a new variable a of type Address (which must be a type available in the scope of the code, such as an internal class), then initialize the new variable to the address member of the customerData structure. Using <xm:bind> as an attribute of the <address> tag means that the <address> element's value will be mapped to the new variable. In addition, the new a variable can be used in the <street> and <zip> elements.

    /**
     * @jws:parameter-xml xml-map::
     *  <customer>
     *    <name>{String customerData.name}</name>
     *    <address xm:bind="Address a is customerData.address">
     *      <street>{a.street}</street>
     *      <zip>{a.zip}</zip>
     *    </address>
     *  </customer>
     *  ::
     */
    public void addCustomerData(MyStructure customerData)
    {  System.out.println("Customer name is " + customerData.get("name"));  System.out.println("Customer zipcode is " +        ((Address)customerData.get("address")).zip);
    }

Note that the is operator is a reserved word in the context of the <xm:bind> attribute. This means that using variables or types called "is" in the value of the <xm:bind> attribute will generate an error.

Note: The xm prefix and its URI are declared implicitly in any JWS file. However, you must declare the namespace prefix and URI to use the prefix in XMLMAP files.

Related Topics

Declaring Variables with the <xm:bind> Attribute

Why Use XML Maps?