[NTG-context] packed lists in XML

Hans Hagen pragma at wxs.nl
Mon Mar 23 13:01:22 CET 2015


On 3/22/2015 1:39 PM, Pablo Rodriguez wrote:
> Dear list,
>
> I have the following sample:
>
>      \startbuffer[demo]
>      <doc>
>          <p>standard list:</p>
>          <ul>
>              <li>
>                  <p>item from loose list</p>
>              </li>
>              <li>
>                  <p>item from loose list</p>
>              </li>
>          </ul>
>          <p>packed list:</p>
>          <ul>
>              <li>item from tight list</li>
>              <li>item from tight list</li>
>          </ul>
>      </doc>
>      \stopbuffer
>
>      \startxmlsetups xml:initialize
>          \xmlsetsetup{#1}{ul|li|p}{xml:*}
>      \stopxmlsetups
>
>      \xmlregistersetup{xml:initialize}
>
>      \startxmlsetups xml:ul
>          \startitemize
>              \xmlflush{#1}
>          \stopitemize
>      \stopxmlsetups
>
>      \startxmlsetups xml:ul:packed
>          \startitemize[packed]
>              \xmlflush{#1}
>          \stopitemize
>      \stopxmlsetups
>
>      \startxmlsetups xml:li
>          \startitem
>              \xmlflush{#1}
>          \stopitem
>      \stopxmlsetups
>
>      \startxmlsetups xml:p
>          \xmldoifnotselfempty {#1} {
>              \dontleavehmode
>              \ignorespaces
>              \xmlflush{#1}
>              \removeunwantedspaces
>          }
>          \par
>      \stopxmlsetups
>
>      \starttext
>           \xmlprocessbuffer{main}{demo}{}
>      \stoptext
>
> Standard lists are defined in XML code with ul/li/p and packed lists
> remove the final /p from the path.
>
> How can I associate the each XML list to its right ConTeXt code?

\startxmlsetups xml:ul
     \xmldoifelse{#1}{/li/p}{
         \startitemize
             \xmlflush{#1}
         \stopitemize
     } {
         \startitemize[packed]
             \xmlflush{#1}
         \stopitemize
     }
\stopxmlsetups



-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list