workflows-xml.tex /size: 2312 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/workflows
2
3\environment workflows-style
4
5\startcomponent workflows-xml
6
7\startluacode
8  for i=1,10 do
9    local filename = string.formatters["temp-%02i.xml"](i)
10    local filedata = string.formatters["<?xml version='1.0'?><p>snippet %i</p>"](i)
11    io.savedata(filename,filedata)
12  end
13\stopluacode
14
15\startchapter[title={XML}]
16
17When you have an \XML\ project with many files involved, finding the right spot
18of something that went wrong can be a pain. In one of our project the production
19of some 50 books involves 60.000 \XML\ files and 20.000 images. \footnote {In the
20meantime we could trim this down a lot.} Say that we have the following file:
21
22\startbuffer[demo]
23<?xml version='1.0'?>
24<document>
25  <include name="temp-01.xml"/> <include name="temp-02.xml"/>
26  <include name="temp-03.xml"/> <include name="temp-04.xml"/>
27  <include name="temp-05.xml"/> <include name="temp-06.xml"/>
28  <include name="temp-07.xml"/> <include name="temp-08.xml"/>
29  <include name="temp-09.xml"/> <include name="temp-10.xml"/>
30</document>
31\stopbuffer
32
33\typebuffer[demo]
34
35Before we process this file we will merge the content of the files defined as
36includes into it. When this happens the filename is automatically registered so
37it can be accessed later.
38
39\startbuffer
40\startxmlsetups xml:initialize
41    \xmlincludeoptions{#1}{include}{filename|name}{recurse,basename}
42    \xmlsetsetup{#1}{p|document}{xml:*}
43\stopxmlsetups
44
45\startxmlsetups xml:document
46    \xmlflush{#1}
47\stopxmlsetups
48
49\startxmlsetups xml:p
50    \inleftmargin{\infofont\xmlinclusion{#1}}
51    \xmlflush{#1}
52    \par
53\stopxmlsetups
54
55\xmlregistersetup{xml:initialize}
56
57\xmlprocessbuffer{main}{demo}{}
58\stopbuffer
59
60\typebuffer
61
62In this case we put the name of the file in the margin. Depending on when and how
63elements are flushed other solutions, like overlays, can be used.
64
65\startpacked
66\getbuffer
67\stoppacked
68
69At any moment you can see what the current node contains. The whole (merged)
70document is also available:
71
72\startbuffer
73\xmlshow{main}
74\stopbuffer
75
76\typebuffer
77
78A small font is used to typeset the (sub)tree:
79
80\blank \getbuffer \blank
81
82You can also save the tree:
83
84\startbuffer
85\xmlsave{main}{temp.xml}
86\stopbuffer
87
88\typebuffer \getbuffer
89
90This file looks like:
91
92\typefile{temp.xml}
93
94\stopchapter
95
96\stopcomponent
97