1%D \module 2%D [ file=publ-xml, 3%D version=2013.12.24, 4%D title=\CONTEXT\ Publication Support, 5%D subtitle=XML, 6%D author=Hans Hagen, 7%D date=\currentdate, 8%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] 9%C 10%C This module is part of the \CONTEXT\ macro||package and is 11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 12%C details. 13 14\writestatus{loading}{ConTeXt Publication Support / XML} 15 16\unprotect 17 18\unexpanded\def 19 {\dosingleempty\publ_convert_to_xml} 20 21\def\publ_convert_to_xml[#1]% 22 {{\iffirstargument#1\else\s!default\fi}} % or current when not empty 23 24% \startxmlsetups btx:initialize 25% \xmlregistereddocumentsetups{#1}{} 26% \xmlsetsetup{#1}{bibtex|entry|field}{btx:*} 27% \xmlmain{#1} 28% \stopxmlsetups 29 30 btx:initialize 31 {#1}{bibtex|entry|field}{btx:*} 32 {#1} 33 34 35% \startxmlsetups btx:entry 36% \xmlflush{#1} 37% \stopxmlsetups 38 39 btx:field 40 {#1} 41 42 43\protect \endinput 44 45% \startxmlsetups bibtex:entry:getkeys 46% \xmladdsortentry{bibtex}{#1}{\xmlfilter{#1}{/field[@name='author']/text()}} 47% \xmladdsortentry{bibtex}{#1}{\xmlfilter{#1}{/field[@name='year' ]/text()}} 48% \xmladdsortentry{bibtex}{#1}{\xmlatt{#1}{tag}} 49% \stopxmlsetups 50 51% \startbuffer 52% \startxmlsetups xml:bibtex:sorter 53% \xmlresetsorter{bibtex} 54% % \xmlfilter{#1}{entry/command(bibtex:entry:getkeys)} 55% \xmlfilter{#1}{ 56% bibtex 57% /entry[@category='article'] 58% /field[@name='author' and find(text(),'Knuth')] 59% /../command(bibtex:entry:getkeys)} 60% \xmlsortentries{bibtex} 61% \xmlflushsorter{bibtex}{bibtex:entry:flush} 62% \stopxmlsetups 63% \stopbuffer 64 65% \bgroup 66% \setups[bibtex-commands] 67% \getbuffer 68% \egroup 69 70% \startxmlsetups bibtex:entry:flush 71% \xmlfilter{#1}{/field[@name='author']/context()} / % 72% \xmlfilter{#1}{/field[@name='year' ]/context()} / % 73% \xmlatt{#1}{tag}\par 74% \stopxmlsetups 75 76% \startpacked 77% \getbuffer 78% \stoppacked 79 80 81% \unexpanded\def\btx_xml_list_handle_entry 82% {\begingroup 83% \ignorespaces 84% \xmlfilter{btx:\currentbtxrendering}{/bibtex/entry[@tag='\currentbtxtag']/command(btx:format)}% 85% \removeunwantedspaces 86% \endgroup} 87 88% \startxmlsetups btx:format 89% \btxlistparameter\c!before\relax % prevents lookahead 90% \edef\currentbibxmlnode {#1} 91% \edef\currentbibxmltag {\xmlatt{#1}{tag}} 92% \edef\currentbtxcategory{\xmlatt{#1}{category}} 93% \ignorespaces 94% \xmlcommand{#1}{.}{btx:\currentbtxformat:\currentbibxmlcategory} 95% \removeunwantedspaces 96% \btxlistparameter\c!after\relax % prevents lookahead 97% \stopxmlsetups 98 99% \startxmlsetups btx:list 100% \xmlfilter{#1}{/bibtex/entry/command(bibtex:format)} 101% \stopxmlsetups 102 103% \startxmlsetups btx:btx 104% \xmlfilter{#1}{/entry/command(btx:format)} 105% \stopxmlsetups 106 107% \unexpanded\def\btx_xml_doifelse#1{\xmldoifelse\currentbibxmlnode{/field[@name='#1']}} 108% \unexpanded\def\btx_xml_doif #1{\xmldoif \currentbibxmlnode{/field[@name='#1']}} 109% \unexpanded\def\btx_xml_doifnot #1{\xmldoifnot \currentbibxmlnode{/field[@name='#1']}} 110% \def\btx_xml_flush #1{\xmlcontext \currentbibxmlnode{/field[@name='#1']}} 111% \def\btx_xml_setup {\xmlsetup \currentbibxmlnode} % {#1} 112% \unexpanded\def\btx_xml_todo #1{[#1]} 113 114% \xmlfilter{#1}{/field[@name='\currentbtxfield']/btxconcat('\currentbtxfield')} 115 |