Altova MapForce 2023 Basic Edition

Returns true if the element node has the xsi:nil attribute set to true.

mf-func-is-xsi-nil

 

Languages

Built-in, C++, C#, Java, XQuery, XSLT 1.0, XSLT 2.0, XSLT 3.0.

 

Parameters

Argument

Description

element

Mandatory parameter. Must be connected to the source node that is to be checked.

 

Example

The mapping design illustrated below copies data from a source to a target XML file conditionally, and also illustrates the usage of several functions, including is-xsi-nil. This mapping is called HandlingXsiNil.mfd and can be found in the <Documents>\Altova\MapForce2023\MapForceExamples\ directory.

mf-func-is-xsi-nil-example

As illustrated above, the is-xsi-nil function checks whether the xsi:nil attribute is "true" for the state item in the source file. If this attribute is "false", the filter will copy the parent Address element to the target. The source XML file looks as follows (excluding the XML and namespace declarations):

 

<BranchOffices>
  <Name>Nanonull</Name>
  <Office>
    <Name>Nanonull Research Outpost</Name>
    <EMail>sp@nanonull.com</EMail>
    <Fax xsi:nil="true"/>
    <Phone>+8817 3141 5926</Phone>
    <Address>
        <city>South Pole</city>
        <state xsi:nil="true"/>
        <street xsi:nil="true"/>
        <zip xsi:nil="true"/>
    </Address>
    <Contact>
        <first>Scott</first>
        <last>Amundsen</last>
    </Contact>
  </Office>
</BranchOffices>

 

The result of the mapping is that no Address is copied to the target at all, because there is only one Address in the source, and the xsi:nil attribute is set to "true" for the state element. Consequently, the mapping output is as follows:

 

<BranchOffices>
  <Name>Nanonull</Name>
  <Office>
    <Name>Nanonull Research Outpost</Name>
    <EMail xsi:nil="true"/>
    <Fax>n/a</Fax>
    <Phone>+8817 3141 5926</Phone>
    <Contact>
        <first>Scott</first>
        <last>Amundsen</last>
    </Contact>
  </Office>
</BranchOffices>

© 2017-2023 Altova GmbH