%D \module %D [ file=lxml-sor, %D version=2009.08.24, %D title=\CONTEXT\ \XML\ Support, %D subtitle=Sorting, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. %D THIS IS VERY EXPERIMENTAL! \writestatus{loading}{ConTeXt XML Support / Sorting} \registerctxluafile{lxml-sor}{} \unprotect % the flusher is unexpandable so that it can be used in tables (noalign % interferences) \unexpanded\def\xmlresetsorter #1{\ctxlxml{sorters.reset("#1")}} \unexpanded\def\xmladdsortentry#1#2#3{\ctxlxml{sorters.add("#1","#2",\!!bs#3\!!es)}} \unexpanded\def\xmlshowsorter #1{\ctxlxml{sorters.show("#1")}} \def\xmlflushsorter #1#2{\ctxlxml{sorters.flush("#1","#2")}} \unexpanded\def\xmlsortentries #1{\ctxlxml{sorters.sort("#1")}} \protect \endinput \startbuffer[test] one alpha alpha indeed one gamma gamma indeed one beta beta indeed two alpha alpha again two gamma gamma again two beta beta again \stopbuffer \startxmlsetups xml:mysetups \xmlsetsetup{\xmldocument}{demo|entry|content}{xml:*} \stopxmlsetups \xmlregistersetup{xml:mysetups} \startxmlsetups xml:demo \xmlresetsorter{demo} \xmlfilter{#1}{entry/command(xml:entry:getkeys)} \blank sortkeys: \blank\xmlshowsorter{demo}\blank \xmlsortentries{demo} \xmlflushsorter{demo}{xml:entry:flush} \stopxmlsetups \startxmlsetups xml:entry:getkeys \xmladdsortentry{demo}{#1}{\xmltext{#1}{category}} \xmladdsortentry{demo}{#1}{\xmltext{#1}{key|entry}} \stopxmlsetups \startxmlsetups xml:entry:flush \xmltext{#1}{content}\par \stopxmlsetups \startxmlsetups xml:entry \xmltext{#1}{content}\par \stopxmlsetups \starttext \xmlprocessbuffer{main}{test}{} \stoptext