ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Wolfgang Schuster" <schuster.wolfgang@googlemail.com>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: xml question
Date: Fri, 6 Jun 2008 10:19:34 +0200	[thread overview]
Message-ID: <115224fb0806060119h6407c9f6nee180fd469a59d77@mail.gmail.com> (raw)

Hi,

I played with a little bit with the docbook syntax and came to a
problem with headers.

The text for chapter headers is written between the title elements, to
get the text I use
the \xmlfirst command but this did not prevent the text in the element
to appear again
in the normal document text. As a workaround I introduced the
\ifheading to flush the
content only in chapter headers, is there a better way to do this?

It is also possible to place the title elements outside of the chapter
group where it
is used as a header by itself, I did this now by another test
\ifchapter where I test if
it called within a chapter or not but a better solution is welcome.

My last question is what I the preferef method to define entities in MkIV,
\defineXMLentity is a MkII command and did not fit in the MkIV
xmlsetup commands.

\startbuffer[test]
<?xml version='1.0'?>

<book>

<title>Document with &ConTeXt;</title>

<chapter id="first"><title>The first Chapter</title>

<para>Normal Text.</para>
<para>Normal Text.</para>

</chapter>

<chapter id="second"><title>Another Chapter</title>

<para>Normal Text.</para>
<para>Normal Text.</para>

</chapter>

</book>
\stopbuffer

\unprotect

\startxmlsetups setup
  \xmlsetsetup{\xmldocument}{title}{*}
  \xmlsetsetup{\xmldocument}{chapter}{*}
  \xmlsetsetup{\xmldocument}{para}{*}
\stopxmlsetups

\xmlregistersetup{setup}

\newif\ifheading
\newif\ifchapter

\startxmlsetups title
  \ifchapter
    \ifheading\xmlflush{#1}\fi
   \else
     \title{\xmlflush{#1}}
   \fi
\stopxmlsetups

\startxmlsetups chapter
  \headingtrue
  \chaptertrue
  \chapter[\xmlatt{#1}{id}]{\xmlfirst{#1}{title}}
  \headingfalse
  \xmlflush{#1}
  \chapterfalse
\stopxmlsetups

\startxmlsetups para
  \xmlflush{#1}\par
\stopxmlsetups

\defineXMLentity [ConTeXt] \ConTeXt

\protect

\starttext
\xmlprocessbuffer{main}{test}{}
\stoptext

Wolfgang
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


             reply	other threads:[~2008-06-06  8:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06  8:19 Wolfgang Schuster [this message]
2008-06-06  9:03 ` Hans Hagen
2008-06-06  9:07   ` Wolfgang Schuster
2008-06-06  9:56     ` Hans Hagen

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=115224fb0806060119h6407c9f6nee180fd469a59d77@mail.gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --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).