ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jano Kula <jano.kula@tiscali.cz>
To: ntg-context@ntg.nl
Subject: index: xml in mkiv
Date: Sat, 25 Sep 2010 16:24:08 +0200	[thread overview]
Message-ID: <i7l0sq$kad$1@dough.gmane.org> (raw)

Hello Hans,

just to remind the other issues. The code from xml-mkiv.pdf doesn't work 
as expected. Only in \TestMode=2 the index is rendered as supposed.

demo.tex + demo.xml below

Jano



%%%%%%%%%%
% demo.tex
\newcount\TestMode
\TestMode=0 % expansion=xml
%\TestMode=1 % expansion=yes, index, setup
%\TestMode=2 % expansion=yes

\startxmlsetups xml:mysetups
   \xmlsetsetup{\xmldocument}{demo|index|content|chapter|title|em}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:mysetups}

% main document
\startxmlsetups xml:demo
   \xmlflush{#1}
   \subject{contents}
   \placelist[chapter][criterium=all]
   \subject{index}
   \placeregister[index][criterium=all]
   \page % else buffer is forgotten when placing header
\stopxmlsetups


\startxmlsetups xml:chapter
   \ifcase \TestMode
     % xml code travels around
     \setuphead[chapter][expansion=xml]
     \startchapter[title=eh: \xmltext{#1}{title}]
   \or
     % index is used for access via setup
     \setuphead[chapter][expansion=yes,xmlsetup=xml:title:flush]
     \startchapter[title=\xmlgetindex{#1}]
   \or
     % tex call to xml using index is used
     \setuphead[chapter][expansion=yes]
     \startchapter[title=hm: \xmlreference{#1}{xml:title:flush}]
   \fi
   \xmlfirst{#1}{content}
   \stopchapter
\stopxmlsetups

\startxmlsetups xml:title:flush
   \xmltext{#1}{title}
\stopxmlsetups

% We need to deal with emphasis and the content of the chapter.
\startxmlsetups xml:em
   \begingroup\em\xmlflush{#1}\endgroup
\stopxmlsetups

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


%A similar approach is followed with the index entries. Watch how we use 
the numbered entries variant (in this case we could also have used just 
entries and keys.
\startxmlsetups xml:index
   \ifcase \TestMode
     \setupregister[index][expansion=xml,xmlsetup=]
     \setstructurepageregister
       [index]
       [entries:1=\xmlfirst{#1}{content},
       keys:1=\xmltext{#1}{key}]
   \or
     \setupregister[index][expansion=yes,xmlsetup=xml:index:flush]
     \setstructurepageregister
       [index]
       [entries:1=\xmlgetindex{#1},
       keys:1=\xmltext{#1}{key}]
   \or
     \setupregister[index][expansion=yes,xmlsetup=]
     \setstructurepageregister
       [index]
       [entries:1=\xmlreference{#1}{xml:index:flush},
       keys:1=\xmltext{#1}{key}]
   \fi
\stopxmlsetups

\startxmlsetups xml:index:flush
   \xmlfirst{#1}{content}
\stopxmlsetups


% The file is processed by:
\starttext
   \xmlprocessfile{main}{demo.xml}{}
\stoptext


% additional control
%\startxmlsetups xml:ctx:sectionentry
%\xmlflush{#1}
%\stopxmlsetups
%\startxmlsetups xml:ctx:registerentry
%\xmlflush{#1}
%\stopxmlsetups


%%%%%%%%%%
% demo.xml
<?xml version='1.0' ?>
<demo>
<chapter>
<title>Some <em>short</em> title</title>
<content>
zeta
<index>
<key>zeta</key>
<content>zeta again</content>
</index>
alpha
<index>
<key>alpha</key>
<content>alpha <em>again</em></content>
</index>
gamma
<index>
<key>gamma</key>
<content>gamma</content>
</index>
beta
<index>
<key>beta</key>
<content>beta</content>
</index>
delta
<index>
<key>delta</key>
<content>delta</content>
</index>
done!
</content>
</chapter>
</demo>



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


                 reply	other threads:[~2010-09-25 14:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='i7l0sq$kad$1@dough.gmane.org' \
    --to=jano.kula@tiscali.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).