[en] Filters on Hierarchical Structures
[en] When you are setting filters on your content, you need to be aware of how filters work on hierarchical structures, otherwise you may get unexpected results. A "hierarchical structure" is any structure that consists of a top-level "parent" element and lower-level "child" elements. These include lists, procedures, tables, and admonitions.
[en] The important rules with filters on hierarchical structures are:
-
[en] If a parent element is set to be excluded from a published output, the entire structure is excluded.
[en] For example, you can't instruct Paligo to exclude a procedure element but include a step inside the procedure. If you filter out the procedure, the entire procedure is excluded, irrespective of the filters on the child elements in the structure.
-
[en] If you want to filter out parts of a structure, make sure you apply:
-
[en] The filters you want to use for each individual child item, such as a list item or a row in a table.
-
[en] The same filters to the parent element that represents the hierarchical structure as a whole, such as
procedure
orinformaltable
. Set the parent element to have all of the filters and filter values of the child elements.
[en] We have included an example to show how this works.
-
[en] When you understand the rules for using filters on hierarchical structures, you can use them in your content. For instructions on adding filters, see
[en] Let's say you have a table with three rows and two columns, like this:
[en] Model |
[en] Operating system |
---|---|
[en] Acme 100 |
[en] Android |
[en] Acme 200 |
[en] Android, iOS |
[en] Acme 300 |
[en] Android, iOS, Windows |
[en] The underlying code for the table looks like this:
<informaltable width="50%" xinfo:market="Europe"> <colgroup> <col></col> <col></col> </colgroup> <thead> <tr> <th> <para xinfo:text="260458">Model</para> </th> <th> <para xinfo:text="260459">Operating system</para> </th> </tr> </thead> <tbody> <tr xinfo:market="Europe"> <td> <para xinfo:text="260460">Acme 100</para> </td> <td> <para xinfo:text="260461">Android</para> </td> </tr> <tr> <td> <para xinfo:text="260462">Acme 200</para> </td> <td> <para xinfo:text="260463">Android, iOS</para> </td> </tr> <tr xinfo:market="USA"> <td> <para xinfo:text="260464">Acme 300</para> </td> <td> <para xinfo:text="260465">Android, iOS, Windows</para> </td> </tr> </tbody> </informaltable>
[en] Look at the informaltable
element, which is the parent element (container for the entire table). It has this market filter:
xinfo:market="Europe"
[en] Look at the first row (tr
) in the table. It also has this market filter:
xinfo:market="Europe"
[en] Next, look at the second row (tr
) in the table. It has no filter.
[en] Finally, look at the code for the final row in the table. The tr
has a filter set to:
xinfo:market="USA"
[en] Now let's see how these filters work when you apply the filters and publish.
[en] Publish and include xinfo:market:Europe
[en] You publish the topic containing the table and, in the publishing settings, choose to include xinfo:market:Europe
. Paligo publishes the table as:
[en] The third row for Acme 300 is not included. This is because:
-
[en] The
informaltable
element hasxinfo:market:Europe
, and so is included. -
[en] The first row's
tr
hasxinfo:market:Europe
, and so is included. -
[en] The second row has no
xinfo:market
filter at all, and so is included. -
[en] The third row's
tr
hasxinfo:market:USA
. You did not set this to be included, so this row does not appear in the output.
[en] Publish and include xinfo:market: USA
[en] You publish the topic containing the table again. This time, you choose to include xinfo:market:USA
. Paligo publishes the topic, but it does not contain a table.
[en] This is because:
-
[en] You told Paligo to include content that has
xinfo:market:USA
. -
[en] The
informaltable
has the filterxinfo:market:Europe
, and so the entire table container is excluded. -
[en] Paligo cannot publish a child element if its parent is not included.
[en] Just as you can't publish a paragraph without its parent topic, you can't publish a table row without its parent table structure. This same principle applies to all hierarchical structures, including lists and admonitions.
[en] How would you get the table to publish with only the row for the USA market? Let's take a look.
[en] Add xinfo:market:USA to the table and publish again
[en] You need the table structure to appear when the xinfo:market
value is Europe or USA. There are two ways to do this:
-
[en] Remove the
xinfo:market:Europe
filter from theinformaltable
element -
[en] Add the USA filter value to the
xinfo:market
filter.
[en] Here, we'll add the USA filter value.
[en] You edit the table so that the informaltable
element has two filter values: xinfo:market:Europe;USA
.
[en] You publish the table and again choose to include xinfo:market:USA
. This produces:
[en] This is because:
-
[en] The
informaltable
element hasxinfo:market:Europe;USA
. You set Paligo to include any content that hasxinfo:market:USA
, so the table is a match. It has one of the two specified values. -
[en] The first row (Acme 100) from the original table is excluded. It had
xinfo:market:Europe
and you told Paligo to only include content withxinfo:market:USA
. -
[en] The second row from the original table is included as it has no
xinfo:market
filter. -
[en] The third row from the original table has
xinfo:market:USA
and so is included.