# @dtf:xquery-function Annotation

Specifies that a user-defined Java method (non-abstract) method in a DTF file can be invoked from queries (written in the XQuery language).

Syntax

@dtf:xquery-function

Remarks

In the following example, the @dtf:xquery-function annotation defines that the Java method calculateTotalPrice that can be invoked from a query during run time:

    /**
     * @dtf:xquery-function
     */
    public float calculateTotalPrice(float taxRate, int quantity, float price, boolean fillOrder)
    {
    	float totalTax, costNoTax, totalCost;
    	if (fillOrder)
    	{
    		// Calculate the total tax
    		totalTax = taxRate * quantity * price;
    		// Calculate the total cost without tax
    		costNoTax = quantity * price;
    		// Add the tax and the cost to get the total cost
    		totalCost = totalTax + costNoTax;
    	}
    	else
    	{
    		totalCost = 0;
    	}
    	return totalCost;
    }

Related Topics

See "Invoking Functions or Operators in a Query" in Modifying Links Using the Target Expression Tab in the Guide to Data Transformation.

See "Create a User-Defined Java Method to Invoke From the Join Query" in Step 4: Mapping Repeating Elements—Creating a Join in the Tutorial: Building Your First Data Transformation.