<xm:value> Tag

Specifies the variable to use when mapping a specific XML element content.

# Syntax

    <xm:value
        obj="[dataType ]elementValueVariable[, ...]"
    />

# Attributes

obj

The portion of the Java declaration to which this element content should be mapped.

# Remarks

Use the <xm:value> tag to assign element content from an XML message to a portion of your Java declaration. The following example maps criterionName and criterionValue to the <name> and <value> elements, respectively.

    /**
     * @jws:operation
     * @jws:parameter-xml xml-map::
     * <query>
     *     <xm:attribute name="max_records" obj="resultSize"/>
     *     <element>
     *         <name><xm:value obj="criterionName"/></name>
     *         <value><xm:value obj="criterionValue"/></value>
     *     </element>
     * </query>
     * ::
     */
    public void searchData(String criterionName, String criterionValue, int resultSize)
    {
        System.out.println("The maximum number of records to return is " + resultSize);
    }

As an alternative to using the <xm:value> tag, you can use curly braces shorthand. The following snippet is equivalent to the preceding example:

    /**
     * @jws:operation
     * @jws:parameter-xml xml-map::
     * <query max_records="{resultSize}">
     *     <element>
     *         <name>{criterionName}</name>
     *         <value>{criterionValue}</value>
     *     </element>
     * </query>
     * ::
     */
    public void searchData(String criterionName, String criterionValue, int resultSize)
    {
        System.out.println("The maximum number of records to return is " + resultSize);
    }

Specify a data type when the variable is not declared with a type elsewhere in the map's context (such as elsewhere in the map, in Java code at the class level, or in the code for the method to which the map applies).

    /**
     * @jws:parameter-xml xml-map::
     * <query max_records="{resultSize}">
     *     <element>
     *         <name>{java.sql.String criterionName}</name>
     *         <value>{java.sql.String criterionValue}</value>
     *     </element>
     * </query>
     * ::
     */
    public void searchData(String criterionName, String criterionValue, int resultSize)
    {
        System.out.println("The maximum number of records to return is " + resultSize);
    }

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. You may change the prefix by declaring another prefix.

Related Topics

How Do XML Maps Work?

Why Use XML Maps?