Use XPath expressions to locate values that are otherwise difficult to specify with name-value pairs.
value_name.value
value_name.xpath=/XmlNode/Child[@attrName="value"]/XmlNode/@matchAttrName
The table provides descriptions of the XPath expression elements and are provided as a guide to create a basic XPath expression.
See the WC3 documentation on XPath language: World Wide Web Consortium (WC3).
XPath expression element | Description |
---|---|
value_name.value | Assigns a value_name to the value that you want to locate in a data file. |
value_name.xpath | Assigns the same value_name to the XPath expression. |
.xpath | Query to locate that attribute whose value is to be replaced by value_name |
/XmlNode/ | Selects an element node named XmlNode in the XML data file. |
/XmlNode/Child | Selects an element node named Child with a parent named XmlNode. |
/XmlNode[@attrName="value"] | Selects an element node of type XmlNode with an attribute of attrName that has a specific value. |
The following is an example of an XPath expression that locates and updates a value in the jdbc.xml data file.
The example XPath expression looks for a DataSource with the name widgetDB and updates the J2EEResourceProperty attribute to 50000 where the name attribute is portNumber.
dbport.value=50000
dbport.xpath=//DataSource[@name='widgetDB']/J2EEResourcePropertySet/J2EEResourceProperty
[@name='portNumber']/@value
The XML data file in the following example shows an excerpt from the jdbc.xml file with the updated port number value.
<jdbc>
<RAFW_JDBCDataSources>
<DataSource
name="widgetDB"
>
<J2EEResourcePropertySet
WASKey="propertySet"
>
<J2EEResourceProperty
WASKey="resourceProperties"
name="portNumber"
required="false"
type="java.lang.Integer"
value="50000"
>
</J2EEResourceProperty>
</J2EEResourcePropertySet>
</DataSource>
</RAFW_JDBCDataSources>
</jdbc>
<DataSource
name="widgetDB"
>
<J2EEResourcePropertySet
WASKey="propertySet"
>
<J2EEResourceProperty
WASKey="resourceProperties"
name="portNumber"
required="false"
type="java.lang.Integer"
value="50000"
>
</J2EEResourceProperty>
</J2EEResourcePropertySet>
</DataSource>
The following example is set in an IBM UrbanCode Deploy environment.
The example uses a WebSphere Application Server configuration file, cache.xml.
The changes produced by running the configuration process are shown in the WebSphere Application Server console, as the following example shows for objCache.
You can also import the configuration data from the cell to see the changed contents of cache.xml. Note the highlighted changes.