ng:trim

ng:trim

The built-in function, ng:trim trims any leading and trailing blanks from a string, which is the input for the function.

 

It is similar to the standard XPath function, normalize-space(), but the ng:trim() function only trims leading and trailing spaces.

 

Example:

 

If you use this XPath command in a text, then the output will be 'abc' - not '   abc   ':

 

NG2BuiltInFunctionsTrim0001

 

You can also see the difference, if you combine this function with the concat function, which concatenates multiple strings:

 

This expression outputs: '<abc>':

 

NG2BuiltInFunctionsTrim0002

 

 

This outputs: '<   abc   >':

 

NG2BuiltInFunctionsTrim0003

 

 

 

Required cardinality of first argument of <function()> is zero or one; supplied value contains <x> items

This section concerns the error: "Required cardinality of first argument of <function()> is zero or one; supplied value contains <x> items".

 

You can see this error message in the XPath editors (both in the designer and workflow) if the parameter of the ng:trim() function is not a string as expected but a nodeset.

 

If you e.g. have an input XML file with multiple Document nodes each with their own DocumentNo nodes, then you will see the error message, if you insert the expression below:

 

NG2BuiltInFunctionsTrim0004

 

One way to avoid this error message is to specify the specific node number to use, if there are multiple nodes with the same name. In this case we can change the expression into this instead:

ng:trim(/Root/Document[1]/DocumentNo)

 

Here we have chosen to use the DocumentNo value of the first Document node. The editor now also does not show any error:

 

NG2BuiltInFunctionsTrim0005

 

Another way is to transform the argument for the ng:trim function into a string like below:

 

ng:trim(string(/Root/Document/DocumentNo))

 

This works fine for the rendered result, but you will still get a warning in the editor:

 

NG2BuiltInFunctionsTrim0006

    Notice: Help Center Transition Update

    As of January 13, 2025, we are excited to announce that our new Help Center is in the final stages of development. While the Knowledge Base is already accessible, our current JIRA system will continue to manage support tickets during this transition period. For assistance with InterForm Output Management Software, please refer to the Support for InterForm Output Management Software.

    We appreciate your patience and understanding as we work to enhance your support experience. If you have any questions or encounter any issues, please do not hesitate to reach out via the existing support channels.

    Best regards,
    The InterForm Support Team


      • Related Articles

      • ng:spoolMap

        The built-in function, ng:spoolMap is only available in InterFormNG2, if you are running InterFormNG2 on the IBM i platform. With this function you can map data from an input spooled file in the designer, and extract information from the spooled file ...
      • ng:spoolMapRel

        The built-in function, ng:spoolMapRel is only available in InterFormNG2, if you are running InterFormNG2 on the IBM i platform, or have activated the AS400 option in InterFormNG2. This function only supports spooled files loaded in the version 2 ...
      • ng:databaseLookup

        You can execute an SQL lookup anywhere in InterFormNG2 (including in the designer) with the built-in Xpath function, ng:databaseLookup. An alternative to this function is the xent files, which can be used for lookup in the workflow only. Other ...
      • ng:resourceExist

        ng:resourceExist(resource,path) This function checks, if a resource in InterFormNG2 exists or not. The function returns a boolean: true or false. The ng:resourceExist Xpath function has this format: ng:resourceExist(resource,path), where: resource ...
      • ng:decrypt

        The built-in function, ng:decrypt is linked with the encryption functions: ng:encrypt and the workflow component, Set secure workflow variable. The function, ng:decrypt can decrypt contents, that was previously encrypted with these functions. The ...