XMLIF(1)
π
XMLIF(1) β like, the xmlif page, bestie β¨
okay so welcome to the xmlif manual, section 1 of the manual, and honestly? this one's a lil gem. it's in the xmlif corner of the man pages and we're about to make it make sense π«Ά
πΈ NAME πΈ
xmlif β conditional processing instructions for XML. yes bestie, it's giving "if statements but make it XML" π
π SYNOPSIS π
xmlif [attrib=value...]
like. that's it. that's the whole vibe. you pass it attrib=value pairs and it does the thing β¨
π¦ DESCRIPTION π¦
so here's the tea β β xmlif filters XML according to conditionalizing markup. lowkey iconic behaviour. it's useful when you wanna format one of several versions of an XML document depending on conditions you pass to the command. one source file, many outputs, main character energy fr fr π
the attribute/value pairs you give on the command line get matched against the attributes associated with certain processing instructions in the document. and the instructions in question? let me list them for you, no skips, no cap:
<?xmlif if?>and its inverse<?xmlif if not?><?xmlif elif?>and its inverse<?xmlif elif not?><?xmlif else?><?xmlif fi?>
not me listing every single one because i respect the source material ππ
π§ the matching rules (this is the important part, stay with me)
argument/value pairs given on the command line get checked against the value of corresponding attributes in the conditional processing instructions. so:
- 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 β
periodt. that's the whole matching mechanic π
π what actually gets passed through
spans between <?xmlif if?> or <?xmlif elif?> 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. slay.
spans between <?xmlif if not?> and <?xmlif elif not?> and the next conditional processing instruction are passed otherwise. (yes, inverse behaviour, we love a flip π)
spans between <?xmlif else?> and the next conditional-processing tag are passed through only if no previous span at the same level has been passed through. it's the fallback bestie, it only shows up when nobody else did π
nesting levels, real quick:
<?xmlif if?>and<?xmlif fi?>(and theirnotvariants) change the current nesting level π<?xmlif else?>and<?xmlif elif?>do not change it π«
β¨ and then what happens to the tags
all these processing instructions will be removed from the output produced. gone. deleted. not in the final cut π
aside from the conditionalization, all other input is passed through untouched. and in particular β and this is highkey important β entity references are not resolved. not resolved. leave them alone. that's the rule π₯
β value matching (the | thing, iykyk)
value matching is by string equality, except that "|" in an attribute value is interpreted as an alternation character. so like:
- saying
foo='red|blue'on the command line enables conditionsredandblueπ - saying
color='black|white'in a tag matches command-line conditionscolor='black'andcolor='white'π€π€
it's giving "or" but make it a pipe character. obsessed.
π«Ά the example, verbatim, because it eats
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.
see how the always-text is always there? iconic. the conditional stuff in between does the picking. the fi closes it out like a good little closer π
π AUTHOR π
Eric S. Raymond <esr@snark.thyrsus.com>
- Author of
xmlifprogram
the legend himself, we stan π
π SEE ALSO π
(nothing listed in this one bestie, this page is a solo act π )
and that's the whole page!! this XMLIF(1) beauty comes to us from the xmlif manual, sourced from Linux, dated April 2009 β and honestly it aged like fine wine fr fr. mwah, bye bestie ππ¦β¨
π¦ where this page comes from
- alpine 3.22: xmlto-doc 0.0.29-r0 Β· GPL-2.0-or-later
- alpine 3.23: xmlto-doc 0.0.29-r0 Β· GPL-2.0-or-later
- alpine 3.24: xmlto-doc 0.0.29-r0 Β· GPL-2.0-or-later
- arch rolling: xmlto 0.0.29-1 Β· GPL
- fedora 43: xmlto 0.0.29-3.fc43 Β· GPL-2.0-or-later
- fedora 44: xmlto 0.0.29-5.fc44 Β· GPL-2.0-or-later
- nixos 26.05: xmlto 0.0.29
- nixpkgs unstable: xmlto 0.0.29
- ubuntu questing: xmlto 0.0.29-2
- ubuntu resolute: xmlto 0.0.29-3 Β· GPL-2.0-or-later
- ubuntu stonking: xmlto 0.0.29-3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms