beautypg.com

HP e-CommerceXML Accelerator sa7150 User Manual

Page 35

background image

C H A P T E R 3

XML Operations

25

required arguments. Wrong numbers of arguments or arguments not
of the required type result in errors. The result of the FunctionCall
expression is the result returned by the function.

.

Function

Description

starts-with(value,
substring)

The starts-with function tests whether the string value of value starts the
specified substring. value can be either an element, attribute, or function
call that returns a string value. substring must be a literal value enclosed
in single or double quotes.

contains(value,
substring)

The contains function tests whether value contains the specified
substring. value can be either an element, attribute, or function call that
returns a string value. substring must be a literal value enclosed in single
or double quotes.

translate(value,
fromString,
toString)

The translate function replaces characters in the value string if they
appear in the fromString with the corresponding characters in the
toString. If a character appears in fromString but not in the corresponding
position in toString, the character will be dropped from the value string.
The result string is returned. value can be either an element, attribute, or
function call that returns a string value. Both fromString and toString
have to be a literal value enclosed in single or double quotes.

Function Calls

Sample Pattern

Description

//Order[starts-with
(PartNumber, “001”)]

Matches if there is an Order element with a value of a PartNumber
child element starting with “001.”

//Part[contains
(@PartNumber, ‘12345’)]

Matches if there is a Part element with the value of a PartNumber
attribute containing “12345.”

//Part[contains(translate
(@Description,’abcdefg
hijklmnopqrstuvwxyz’,
‘ABCDEFGHIJKLMNOP
QRSTUVWXYZ’),
‘ENGINE’)]

Matches if there is a Part element with the value of a Description
attribute containing “ENGINE.” All characters in the Description
attribute are converted to uppercase before being passed to the
contains function.

Function Call Examples