<call-param>

Function call parameter

Core v2.2.0

Overview

The processor defines a parameter passed to a function when calling it with . Parameters can be simple values or complex expressions. Must be used as a child element of .

Usage Examples

Example 1: Simple parameters

example-1.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<function name="greet">
  <def var="name"><call-param name="userName"/></def>
  <def var="greeting">Hello, ${name}!</def>
  <return>${greeting}</return>
</function>

<def var="message">
  <call name="greet">
    <call-param name="userName">John</call-param>
  </call>
</def>
</config>

Example 2: Complex parameter values

example-2.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<function name="fetchProduct">
  <def var="id"><call-param name="productId"/></def>
  <def var="apiUrl">https://api.example.com/products/${id}</def>
  <def var="response">
    <http url="${apiUrl}"/>
  </def>
  <return>${response}</return>
</function>

<call name="fetchProduct">
  <call-param name="productId">
    <xpath expression="//product/@id">
      <html-to-xml>${catalog}</html-to-xml>
    </xpath>
  </call-param>
</call>
</config>

Example 3: Multiple parameters with types

example-3.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<function name="formatPrice">
  <def var="amount"><call-param name="price"/></def>
  <def var="curr"><call-param name="currency"/></def>
  <def var="decimals"><call-param name="decimalPlaces"/></def>
  
  <return>${curr} ${amount}</return>
</function>

<call name="formatPrice">
  <call-param name="price">19.99</call-param>
  <call-param name="currency">USD</call-param>
  <call-param name="decimalPlaces">2</call-param>
</call>
</config>

Example 4: Passing XML/HTML content

example-4.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<function name="extractLinks">
  <def var="htmlContent"><call-param name="html"/></def>
  <def var="links">
    <xpath expression="//a/@href">
      <html-to-xml>${htmlContent}</html-to-xml>
    </xpath>
  </def>
  <return>${links}</return>
</function>

<call name="extractLinks">
  <call-param name="html">
    <http url="https://example.com"/>
  </call-param>
</call>
</config>

Parameters

Important Notes

Related Processors