[NTG-context] use of preceding-sibling in xmlsetsetup

Thomas A. Schmitz thomas.schmitz at uni-bonn.de
Thu Oct 15 22:27:41 CEST 2015


On 10/14/2015 01:34 PM, massifr at fastwebnet.it wrote:
> I've found a better solution:
>
> \startxmlsetups xml:p
>    \doif{\xmlattribute{#1}{reverse-sibling::p[1]}{class}}{incipit}{\noindent}%
>    \xmlflush{#1}\par
> \stopxmlsetups
>
> Still I did not manage to put that rule in a xmlsetsetup.
> Tried this:
>
> \xmlsetsetup{#1}{p[reverse-sibling::p[1]/attribute('class') == 'incipit']}{xml:p:noindent}
>
> but it does not work.

I'm not sure if the "sibling" part of xpath syntax has been integrated 
into context. The best I can come up with is a hack which may help:

\startbuffer[test]
<text>
   <p class="incipit">Dear list,</p>
   <p>this paragraph should not be indented, because it follows the 
“incipit”
   of the letter.</p>
   <p>This one and the following ones should be indented.</p>
   <p>You may question whether “Dear list,” should be a paragraph of his 
own,
   but my text is already formatted like that and I can’t do anything
   about it.</p>
</text>
\stopbuffer

\startxmlsetups xml:somesetups
   \xmlsetsetup{#1}{text}{xml:text}
   \xmlsetsetup{#1}{p}{xml:p}
\stopxmlsetups

\xmlregistersetup{xml:somesetups}

\startxmlsetups xml:text
   \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:p
	\doifelse {\xmlatt {#1} {class}} {incipit}
	  {\noindentation \xmlflush {#1}\par \noindentation}
	  {\xmlflush {#1}\par \indentation}
\stopxmlsetups

\starttext
   \setupindenting [medium, yes]
   \xmlprocessbuffer{main}{test}{}
\stoptext

This will suppress indentation for paragraphs with class "incipit" and 
the following paragraph.

Thomas


More information about the ntg-context mailing list