-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate-example-xinclude.xpl
76 lines (64 loc) · 2.76 KB
/
generate-example-xinclude.xpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:db="http://docbook.org/ns/docbook"
xmlns:exf="http://exproc.org/standard/functions"
name="main" version="1.0">
<p:input port="parameters" kind="parameter"/>
<p:import href="/home/ndw/xmlcalabash.com/extension/steps/library-1.0.xpl"/>
<p:import href="/home/ndw/xmlcalabash.com/library/tee.xpl"/>
<p:directory-list include-filter=".*-1.xml$" name="find1">
<p:with-option name="path" select="exf:cwd()"/>
</p:directory-list>
<p:directory-list include-filter=".*-01.xml$" name="find01">
<p:with-option name="path" select="exf:cwd()"/>
</p:directory-list>
<p:wrap-sequence wrapper="irrelevant">
<p:input port="source">
<p:pipe step="find1" port="result"/>
<p:pipe step="find01" port="result"/>
</p:input>
</p:wrap-sequence>
<p:for-each name="stepout">
<p:iteration-source select="//c:file"/>
<!--
<cx:message>
<p:with-option name="message"
select="if (contains(/*/@name, '-01.xml'))
then concat(substring-before(/*/@name, '-01.xml'),'-.*')
else concat(substring-before(/*/@name, '-1.xml'),'-.*')"/>
</cx:message>
-->
<p:directory-list>
<p:with-option name="path" select="exf:cwd()"/>
<p:with-option name="include-filter"
select="if (contains(/*/@name, '-01.xml'))
then concat(substring-before(/*/@name, '-01.xml'),'-.*')
else concat(substring-before(/*/@name, '-1.xml'),'-.*')"/>
</p:directory-list>
<p:for-each>
<p:iteration-source select="//c:file"/>
<p:string-replace match="/*/@href">
<p:input port="source">
<p:inline xmlns:xi="http://www.w3.org/2001/XInclude"
exclude-inline-prefixes="p c cx xs db exf">
<xi:include href="@@"
xpointer="xpath(/*/node^(^))"/>
</p:inline>
</p:input>
<p:with-option name="replace"
select="concat('"', /*/@name, '"')"/>
</p:string-replace>
</p:for-each>
<p:wrap-sequence wrapper="db:wrapper"/>
<p:store>
<p:with-option name="href"
select="if (contains(/*/@name, '-01.xml'))
then concat(exf:cwd(), '/', substring-before(/*/@name, '-01.xml'),'.xml')
else concat(exf:cwd(), '/', substring-before(/*/@name, '-1.xml'),'.xml')">
<p:pipe step="stepout" port="current"/>
</p:with-option>
</p:store>
</p:for-each>
</p:declare-step>