summaryrefslogtreecommitdiff
path: root/man/man1/xmlif.1
blob: 6d3d7cda7b92193450c356eaf5af36f84e19cea9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'\" t
.\"     Title: xmlif
.\"    Author: Eric S. Raymond <esr@snark.thyrsus.com>
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
.\"      Date: April 2009
.\"    Manual: xmlif
.\"    Source: Linux
.\"  Language: English
.\"
.TH "XMLIF" "1" "April 2009" "Linux" "xmlif"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
xmlif \- conditional processing instructions for XML
.SH "SYNOPSIS"
.HP \w'\fBxmlif\fR\ 'u
\fBxmlif\fR [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
<?xmlif if?>
and its inverse
<?xmlif if not?>,
<?xmlif elif?>
and its inverse
<?xmlif elif not?>,
<?xmlif else?>, and
<?xmlif fi?>\&.
.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\*(Aq happens if an attribute occurs in both the command\-line arguments and the tag, and the values match\&. An `attribute mismatch\*(Aq happens if an attribute occurs in both the command\-line arguments and the tag, but the values do not match\&.
.PP
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; spans between
<?xmlif if not?>
and
<?xmlif elif not?>
and the next conditional processing instruction are passed otherwise\&. 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\&.
<?xmlif if?>
and
<?xmlif fi?>
(and their `not\*(Aq variants) change the current nesting level;
<?xmlif else?>
and
<?xmlif elif?>
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=\*(Aqred|blue\*(Aq on the command line enables conditions red and blue\&. Saying color=\*(Aqblack|white\*(Aq in a tag matches command\-line conditions color=\*(Aqblack\*(Aq and color=\*(Aqwhite\*(Aq\&.
.PP
Here is an example:
.sp
.if n \{\
.RS 4
.\}
.nf
Always issue this text\&.
<?xmlif if condition=\*(Aqhtml\*(Aq?>
Issue this text if \*(Aqcondition=html\*(Aq is given on the command line\&.
<?xmlif elif condition=\*(Aqpdf|ps\*(Aq?>
Issue this text if \*(Aqcondition=pdf\*(Aq or \*(Aqcondition=ps\*(Aq
is given on the command line\&.
<?xmlif else?>
Otherwise issue this text\&.
<?xmlif fi?>
Always issue this text\&.
.fi
.if n \{\
.RE
.\}
.SH "AUTHOR"
.PP
\fBEric S\&. Raymond\fR <\&esr@snark\&.thyrsus\&.com\&>
.RS 4
Author of xmlif program
.RE