XPath wizard

XPath wizard

When you in InterFormNG2 insert a value in a field, then you for most have these options:

1.You can insert a fixed text.

2.You can type a dynamic XPath expression where you need to remember each XPath function and the matching parameters.

3.For some you can also use the XPath wizard for finding XPath functions and keep the correct syntax. The wizard also includes a description of each parameter. The wizard option is only available for some entry fields.

 

This section of the manual shows how you can use the XPath wizard, when you enter an XPath expression. Apart from the wizard you may also find help in the example of the XPath section.

 

For the XPath wizard there are these features:

 

Enable XPath and verify if the Wizard is available for the entry field

One way to find out if the XPath wizard runs for a specific entry field it to first set it in XPath mode. For the contents of a text element you first need to select Expression and then ensure that the magnifying glass is shown on the right as below:

 



Then you can use the XPath wizard by entering a part of the XPath function, that you want to insert. If you e.g. type string, then you will see a list like below:

 


 

Now we are sure, that the XPath wizard is available for this entry field.

 

Search for an XPath function

If you want to search for an XPath function, then you simply type a part of the function name. The text that you search for does not need to be the leading part of the function name. The search result contains any built-in function (which are the functions, that starts with ng:) or standard XPath function which contains the search text. That means, that if you e.g. search for string, then you see all functions, that is related to string.

 

If you e.g. search for number, then you see all functions, that contains number:

 


 

 

List all XPath functions

If you want to list all available functions, then you can just enter a text and then delete it again and you will see this:

 


On the right there is a slider (marked with the arrow) that can be dragged down to see them all.

 

Description and help for the functions

If you are in doubt as to which function to select, then you just place the mouse over any of the functions listed above. Then a description of the function and parameters are shown:

 


(Above we have placed the mouse on the substring() function).

 

Insert the function

When you have found the function, that you want to insert, then you can simply click on it to insert it. When you have inserted it you can consider to prompt it.

If you instead prefer to type in the expression yourself, then you can just type it in instead of clicking on a function.

 

Prompt an inserted XPath function

After you have inserted an XPath function it is time to insert the parameters. For the parameters it is important that the number of parameters, the sequence and the value of each parameter is correct. The XPath wizard can help you with that.

 

You will see something like below after you have inserted an XPath function:

 

 

Below the function you might see an error message if e.g. parameters are missing.

 

You can prompt the function if you click the this icon on the right:



 

Now another window pops up which shows the function and the parameters. A description is included below the function name and each parameter:

 

 

For each parameter you can on the left see the type of data, which is required. In the middle you can again enter an XPath function, which can also be searched for via the wizard and on the right you can see the calculated value for each parameter. In the example above we are selecting the characters from 1 to 3 of the node: /IF_Type/Settings/ReportID in the input XML file.

 

The value of this expression is in this case INV, which you can see if you click Apply all:

 

 

As you can see above the input field for the function locked, so you cannot directly change the parameters from this screen. If you want to still use the wizard you can click this icon on the right to prompt the command again:

 


 

Alternatively you can switch to manual entry.

 

Switch to manual entry and back

If you want to use the XPath wizard for searching and prompting, then you need to stick to the XPath wizard. The alternative to the XPath Wizard is, that you type in all the functions yourself. This is called manual entry.

 

If you want to switch from the XPath wizard into manual entry, then you just click the marked <> icon on the right:


 

Then you have full freedom when you type in the expression:

 


But now you are on your own and the XPath wizard is pretty much not available. If you click the E icon on the right, then you request the editor to go back to the XPath Wizard, but currently that only works for a simple function without any parameters, so for most you will just get an empty entry field if you click this icon and you need to build up the expression again with the wizard. If you immediately regret the change you can of course click cancel or roll back the last change of the template.

 

Limitation of the XPath wizard

The XPath wizard is a great tool, but as you can see in the section, Switch to manual entry and back the XPath wizard only works for XPath expressions, that has been entered with the XPath wizard, so you cannot use the wizard for XPath expressions, that has not been entered with the wizard.


    • Related Articles

    • XPath

      In InterFormNG2 you use the language XPath for referencing to data from the XML file. There are many sources of information, if you want to know more about XPath, but you can also simply read the few examples below to have a good idea of how it can ...
    • Using variables in Xpath expressions

      XPath is a strong tool in itself, but you can even use variables in your XPath expressions. The way it works is by referring to a variable as: $variable. You use the variable element to assign a value to a variable. Variables are case sensitive, so ...
    • Dynamic Xpath settings for design elements

      You can set multiple settings as an xpath expression for many of the design elements in the normal template designer (for printed and PDF result). For almost all the physical elements you can setup an Xpath expression for the X- and Y-position of the ...
    • Release log

      This is the list of the InterFormNG2 releases and the major new features in each release: Version 3.5.0 Important: InterFormNG2 now runs on Java 17. So you need to install Java 17 on Linux and the IBM i platform, if you want to InterFormNG2 on either ...
    • ng:page-number

      This section explains the built-in XPath function: ng:page-number() This function outputs the current page number of the output. The function has no parameters. You can use this function with other functions in an XPath expression - unlike the ...