ConTeXt XML: Configureable Titleblock
If the document has only one title and one author, you can use xmlfilter
to filter out that information before flushing the rest of the content. For example:
\startbuffer[test]
<?xml version='1.0' standalone='yes?>
<document>
<title>The Title</title>
<author>The author</author>
<p>This is a first sentence</p>
</document>
\stopbuffer
\startxmlsetups xml:setup
\xmlsetsetup{\xmldocument}{*}{-}
\xmlsetsetup{\xmldocument}{document|p}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:setup}
\startxmlsetups xml:document
\xmlfilter{#1}{/title/command(xml:title)}
\xmlfilter{#1}{/author/command(xml:author)}
\startdocument
\xmlflush{#1}
\stopdocument
\stopxmlsetups
\startxmlsetups xml:title
\setupdocument[title={\xmlflush{#1}}]
\stopxmlsetups
\startxmlsetups xml:author
\setupdocument[author={\xmlflush{#1}}]
\stopxmlsetups
\startxmlsetups xml:p
\xmlflush{#1}\par
\stopxmlsetups
\startsetups document:start
\startalignment[middle]
{\ssbfa\setupinterlinespace
\documentvariable{title}\endgraf}
\blank[medium]
\documentvariable{author}
\stopalignment
\blank[big]
\stopsetups
\xmlprocessbuffer{main}{test}{}
which gives
With this approach, it doesn't matter where the <title>
and <author>
block appear. For example, the following will also work:
\startbuffer[test]
<?xml version='1.0' standalone='yes?>
<document>
<p>This is a first sentence</p>
<title>The Title</title>
<author>The author</author>
</document>
\stopbuffer