Retrieving property values from external files
You can specify that a property takes a value from an XML or JSON file over HTTP. Then, when you run the process, the server prompts you with a list of values from that file.
Before you begin
The simplest way to format the file is
to provide a simple list of values for the property, as in the following
examples:
<company>
<employee>Alice</employee>
<employee>Bob</employee>
<employee>Chris</employee>
<company>
For
XML files, you use XPath to specify the path to the values. In the previous XML file, the
Base Path parameter is the XPath expression //company/employee
and parameters Value Path and Label Path are
blank.The following example shows the equivalent file in
JSON:
{
company: {
employee: [
"Alice",
"Bob",
"Chris"
]
}
}
In the previous JSON file, the Base Path parameter is
company.employee
and parameters Value Path and Label
Path are blank.You can include separate label and value information in the file.
For example, the following XML file includes names and ID
numbers.
<company>
<employee>
<name>Alice</name>
<id>1</id>
</employee>
<employee>
<name>Bob</name>
<id>2</id>
</employee>
<employee>
<name>Chris</name>
<id>3</id>
</employee>
</company>
In
this case, the Base Path parameter is the XPath expression
//company/employee
. The Value Path parameter is an XPath
expression that shows the path to the value relative to the base path; in this case the expression
is ./id
. Similarly, the Label Path parameter an XPath
expression that shows the path to the label relative to the base path; in this case the expression
is ./name
.The following JSON file is equivalent to the previous XML
file:
{
company: {
employees: [
{ name: "Alice", employee.id: 1 },
{ name: "Bob", employee.id: 2 },
{ name: "Chris", employee.id: 3}
]
}
}
In
this case, the Base Path parameter is company.employees
. The
Value Path parameter is employee\.id
and the Label
Path parameter is name
. Note: When specify the path for a JSON file,
escape periods in attribute names with backslashes, as in the Value Path
parameter in the previous example.
When you use attributes in an XML file, use the
@
character to specify an attribute in XPath. For example, the following XML file
has values in
attributes:<company>
<employee id="1">Alice</employee>
<employee id="2">Bob</employee>
<employee id="3">Chris</employee>
<company>
In
this case, the Base Path parameter is the XPath expression
//company/employee
. The Value Path parameter is
./@id
and the Label Path parameter is a period
(.
).About this task
Procedure
- Create a property definition.For example, click a component, go to the Configuration tab, click Environment Property Definitions, and click Add Property.
- Specify the Name, Description, Label, Pattern, and Required fields as usual.
- In the Type list, select HTTP
Select for a single property value or select HTTP
Multi Select to allow multiple property values.
Several new fields appear.
- Specify the following fields.These fields are specific to parameters from external files.
- URL
- Specify the URL of the external XML or JSON file.
- Username
- If the URL requires a user name, specify it here.
- Password
- If the URL requires a password, specify it here.
- Data Format
- Specify the type of file: JSON or XML.
- Base Path
- For XML files, specify an XPath expression to the data. For JSON
files, specify the path through the JSON attributes to the data, separating
paths with periods (
.
). See the examples at the top of this page. - Value Path
- Specify the path to the parameter values, relative to the Base Path parameter.
- Label Path
- Specify the path to the parameter labels, relative to the Base Path parameter.
- Default Value
- Specify the default value for the parameter.
- Click Save.