summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-xml.mkiv
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
committerMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
commit85b7bc695629926641c7cb752fd478adfdf374f3 (patch)
tree80293f5aaa7b95a500a78392c39688d8ee7a32fc /tex/context/base/strc-xml.mkiv
downloadcontext-85b7bc695629926641c7cb752fd478adfdf374f3.tar.gz
stable 2010-05-24 13:10
Diffstat (limited to 'tex/context/base/strc-xml.mkiv')
-rw-r--r--tex/context/base/strc-xml.mkiv144
1 files changed, 144 insertions, 0 deletions
diff --git a/tex/context/base/strc-xml.mkiv b/tex/context/base/strc-xml.mkiv
new file mode 100644
index 000000000..7a0099585
--- /dev/null
+++ b/tex/context/base/strc-xml.mkiv
@@ -0,0 +1,144 @@
+%D \module
+%D [ file=strc-xml,
+%D version=2008.10.20,
+%D title=\CONTEXT\ Structure Macros,
+%D subtitle=XML Processing,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=PRAGMA-ADE / Hans Hagen]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Structure Macros / XML Processing}
+
+\unprotect
+
+\startxmlsetups xml:ctx:internal:setup
+ \xmlsetsetup{\xmldocument}{ctx:genericentry} {xml:ctx:genericentry}
+ \xmlsetsetup{\xmldocument}{ctx:sectionentry} {xml:ctx:sectionentry}
+ \xmlsetsetup{\xmldocument}{ctx:registerentry}{xml:ctx:registerentry}
+\stopxmlsetups
+
+\xmlregistersetup{xml:ctx:internal:setup}
+
+\startxmlsetups xml:ctx:genericentry
+ \xmlflush{#1}
+\stopxmlsetups
+
+\startxmlsetups xml:ctx:sectionentry
+ \xmlflush{#1}
+\stopxmlsetups
+
+\startxmlsetups xml:ctx:registerentry
+ \xmlflush{#1}
+\stopxmlsetups
+
+\protect \endinput
+
+% test.xml
+
+<?xml version='1.0' standalone='yes?>
+
+<document>
+ <section>
+ <title>Some <b>bold</b> title <b>bold <i>bold</i> oeps</b> and more</title>
+ <content>
+ <p>a paragraph of text</p>
+ <p>another paragraph of text</p>
+ </content>
+ </section>
+ <section>
+ <title>Another <b>bold</b> title <b>bold <i>bold</i> oeps</b> and more</title>
+ <content>
+ <p>a paragraph of text</p>
+ <p>another paragraph of text</p>
+ </content>
+ </section>
+</document>
+
+% test.tex
+
+\setupstructurehead[chapter][expansion=xml]
+
+\startxmlsetups xml:demo:define:base
+ \xmlsetsetup{demo}{document|section|p|b|i}{xml:demo:*}
+\stopxmlsetups
+
+\xmlregisterdocumentsetup{demo}{xml:demo:define:base}
+
+\startxmlsetups xml:demo:document
+ \title{Contents}
+ \placelist[chapter]
+ \page
+ \xmlflush{#1}
+\stopxmlsetups
+
+\startxmlsetups xml:demo:section
+ \chapter{\xmltext{#1}{/title}}
+ \xmlfirst{#1}{/content}
+\stopxmlsetups
+
+\startxmlsetups xml:demo:p
+ \xmlflush{#1}\endgraf
+\stopxmlsetups
+
+\startxmlsetups xml:demo:b
+ \bgroup\bf\xmlflush{#1}\egroup
+\stopxmlsetups
+
+\startxmlsetups xml:demo:i
+ \bgroup\it\xmlflush{#1}\egroup
+\stopxmlsetups
+
+\starttext
+ \xmlprocessfile{demo}{oeps.xml}{}
+\stoptext
+
+% example by thomas:
+
+\startbuffer[test]
+<auth>
+ <section>
+ <title><emph>MyTitle</emph></title>
+ <content>
+ Hello world
+ </content>
+ </section>
+</auth>
+\stopbuffer
+
+\startxmlsetups xml:mysetups
+ \xmlsetsetup{\xmldocument}{auth|section|title|content|emph}{xml:*}
+\stopxmlsetups
+
+\xmlregistersetup{xml:mysetups}
+
+\startxmlsetups xml:auth
+ \xmlflush{#1}
+\stopxmlsetups
+
+\startxmlsetups xml:section
+ \xmlflush{#1}\par \midaligned{\hl[5]}
+\stopxmlsetups
+
+\startxmlsetups xml:title
+ \section{\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:content
+ \xmlflush{#1}\par
+\stopxmlsetups
+
+\startxmlsetups xml:emph
+ {\bgroup\em \xmlflush{#1}\egroup}
+\stopxmlsetups
+
+\setuphead
+ [section]
+ [style=normal,number=no,expansion=yes,page=yes]
+
+\starttext
+ \xmlprocessbuffer{main}{test}{}
+\stoptext