XMLIF(1) xmlif XMLIF(1)

.SH "NAME" xmlif - conditional processing instructions for XML

.SH "SYNOPSIS"

.HP 144u

**xmlif** \[attrib=value...]

.SH "DESCRIPTION"

.PP xmlif filters XML according to conditionalizing markup. This can be useful for formatting one of several versions of an XML document depending on conditions passed to the command.

.PP Attribute/value pairs from the command line are matched against the attributes associated with certain processing instructions in the document. The instructions are &lt;?xmlif if?&gt; and its inverse &lt;?xmlif if not?&gt;, &lt;?xmlif elif?&gt; and its inverse &lt;?xmlif elif not?&gt;, &lt;?xmlif else?&gt;, and &lt;?xmlif fi?&gt;.

.PP Argument/value pairs given on the command line are checked against the value of corresponding attributes in the conditional processing instructions. An \`attribute match' happens if an attribute occurs in both the command-line arguments and the tag, and the values match. An \`attribute mismatch' happens if an attribute occurs in both the command-line arguments and the tag, but the values do not match.

.PP Spans between &lt;?xmlif if?&gt; or &lt;?xmlif elif?&gt; and the next conditional processing instruction at the same nesting level are passed through unaltered if there is at least one attribute match and no attribute mismatch; spans between &lt;?xmlif if not?&gt; and &lt;?xmlif elif not?&gt; and the next conditional processing instruction are passed otherwise. Spans between &lt;?xmlif else?&gt; and the next conditional-processing tag are passed through only if no previous span at the same level has been passed through. &lt;?xmlif if?&gt; and &lt;?xmlif fi?&gt; (and their \`not' variants) change the current nesting level; &lt;?xmlif else?&gt; and &lt;?xmlif elif?&gt; do not.

.PP All these processing instructions will be removed from the output produced. Aside from the conditionalization, all other input is passed through untouched; in particular, entity references are not resolved.

.PP Value matching is by string equality, except that "|" in an attribute value is interpreted as an alternation character. Thus, saying foo='red|blue' on the command line enables conditions red and blue. Saying color='black|white' in a tag matches command-line conditions color='black' and color='white'.

.PP Here is an example:

```
Always issue this text.
<?xmlif if condition='html'?>
Issue this text if 'condition=html' is given on the command line.
<?xmlif elif condition='pdf|ps'?>
Issue this text if 'condition=pdf' or 'condition=ps'
is given on the command line.
<?xmlif else?>
Otherwise issue this text.
<?xmlif fi?>
Always issue this text.
```

# [AUTHOR](#AUTHOR)

**Eric S. Raymond** &lt;esr@snark.thyrsus.com&gt;

Author of xmlif program

April 2009 Linux

---

Document: xmlif(1) from xmlto 0.0.29-r9 (Chainguard OS)
Source: https://pagure.io/xmlto.git
