Returns true if the connected node exists; false otherwise. Since it returns a Boolean value, this function is typically used with filters, to filter out only records which have (or perhaps do not have) a child element or attribute.
Built-in, C++, C#, Java, XQuery, XSLT 1.0, XSLT 2.0, XSLT 3.0.
The node to be tested for existence.
The following mapping illustrates how to filter data with the help of the exists function. This mapping is called PersonListsForAllBranchOffices.mfd and it can be found in the <Documents>\Altova\MapForce2023\MapForceExamples\ directory.
In the source file BranchOffices.xml, there are three Office elements. Notably, one of the offices does not have any Contact child elements. The goal of the mapping is many-fold:
a) for each office, extract a list of contacts that exist in that office
b) for each office, create a separate XML file with the same name as the office
c) do not generate the XML file if the office has no contacts.
To achieve these goals, a filter was added to the mapping. The filter passes on to the target only those Office items where at least one Contact item exists. This Boolean condition is provided by the exists function. If the function's result is true, then the name of the office is concatenated with the string .xml in order to produce the target file name. For more information about generating file names from the mapping, see Processing Multiple Input or Output Files Dynamically .
Another example is the following mapping: <Documents>\Altova\MapForce2023\MapForceExamples\HasMarketingExpenses.mfd. Here, if an expense-item exists in the source XML, then the hasExpenses attribute is set to true in the target XML file.