-
Notifications
You must be signed in to change notification settings - Fork 14
/
docx2hub.xpl
executable file
·893 lines (820 loc) · 41 KB
/
docx2hub.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http:https://www.w3.org/ns/xproc"
xmlns:c="http:https://www.w3.org/ns/xproc-step"
xmlns:cx="http:https://xmlcalabash.com/ns/extensions"
xmlns:tr="http:https://transpect.io"
xmlns:xsl="http:https://www.w3.org/1999/XSL/Transform"
xmlns:docx2hub="http:https://transpect.io/docx2hub"
xmlns:w="http:https://schemas.openxmlformats.org/wordprocessingml/2006/main"
version="1.0"
name="docx2hub"
type="docx2hub:convert">
<p:documentation xmlns="http:https://www.w3.org/1999/xhtml">
<p>This script is used to convert docx to Hub XML. By default, the output is stored in the same directory as the input docx
file, with the same basename. It is a library that needs other externals. For standalone operation, please check out the
<a href="https://subversion.le-tex.de/docxtools/trunk/docx2hub_frontend/">front-end project</a>.</p>
<p>From the directory wherey you checked out the front-end project, you invoke it with:</p>
<p><code>calabash/calabash.sh docx2hub/wml2hub.xpl docx=PATH-TO-MY-DOCX-FILE.docx</code></p>
<p>where docx may be an OS path or a file:, http:, or https: URL.</p>
<p>Import it with</p>
<p><code><p:import href="http:https://transpect.io/docx2hub/xpl/wml2hub.xpl" /></code></p>
<p>if you use it from transpect or if you imported this project as svn:external.</p>
<p>In the latter case, include the following line in you project's xmlcatalog/catalog.xml:</p>
<p><code><nextCatalog catalog="../docx2hub/xmlcatalog/catalog.xml"/></code></p>
<p>Experts may override the default conversion rules by supplying custom XSLT (that imports main.xsl) on the 'xslt'
port.</p>
</p:documentation>
<p:input port="xslt">
<p:document href="../xsl/main.xsl"/>
</p:input>
<p:input port="source" primary="true">
<p:documentation>This is to prevent a default readable port connecting to this step’s xslt port.</p:documentation>
<p:empty/>
</p:input>
<p:input port="single-tree-schematron">
<p:document href="../sch/single-tree.sch.xml"/>
<p:documentation>Schematron that will validate the entire Word container document.</p:documentation>
</p:input>
<p:input port="check-tables-schematron">
<p:document href="../sch/check-tables.sch.xml"/>
<p:documentation>Schematron that will validate tables in the document.</p:documentation>
</p:input>
<p:input port="changemarkup-schematron">
<p:document href="../sch/changemarkup.sch.xml"/>
<p:documentation>Schematron that will validate the entire document after applying change markup.</p:documentation>
</p:input>
<p:input port="mathtype2mml-schematron">
<p:document href="../sch/mathtype2mml.sch.xml"/>
<p:documentation>Schematron that will validate the entire document after replacing MathType OLE-Objects by MathML.</p:documentation>
</p:input>
<p:input port="field-functions-schematron">
<p:document href="../sch/field-functions.sch.xml"/>
<p:documentation>Schematron that will validate the intermediate format after merging/splitting Word field functions.</p:documentation>
</p:input>
<p:input port="result-schematron">
<p:document href="../sch/result.sch.xml"/>
<p:documentation>Schematron that will validate the flat Hub. It will chiefly report error messages that were
embedded during conversion.</p:documentation>
</p:input>
<p:input port="custom-font-maps" primary="false" sequence="true">
<p:documentation>See same port in mathtype2mml.xpl.
If you need to match a specific docx font name that is not identical with the base name of the base URI’s file name part,
you can do so by including an attribute /symbols/@docx-name.</p:documentation>
<p:empty/>
</p:input>
<p:output port="result" primary="true"/>
<p:serialization port="result" omit-xml-declaration="false"/>
<p:output port="insert-xpath">
<p:pipe step="single-tree-enhanced" port="result"/>
</p:output>
<p:output port="report" sequence="true">
<p:pipe port="report" step="single-tree-enhanced"/>
<p:pipe port="report" step="add-props"/>
<p:pipe port="report" step="props2atts"/>
<p:pipe port="report" step="remove-redundant-run-atts"/>
<p:pipe port="report" step="join-instrText-runs"/>
<p:pipe port="report" step="field-functions"/>
<p:pipe port="result" step="check-field-functions"/>
<p:pipe port="report" step="wml-to-dbk"/>
<p:pipe port="report" step="join-runs"/>
<p:pipe port="result" step="check-result"/>
<p:pipe port="result" step="rename-errorPI2svrl-reports"/>
<p:pipe port="report" step="check-tables"/>
</p:output>
<p:output port="schema" sequence="true">
<p:pipe port="result" step="decorate-field-functions-schematron"/>
<p:pipe port="result" step="decorate-result-schematron"/>
<p:pipe port="schema" step="single-tree-enhanced"/>
</p:output>
<p:output port="zip-manifest">
<p:pipe port="zip-manifest" step="single-tree-enhanced"/>
</p:output>
<p:option name="docx" required="true">
<p:documentation>OS name (preferably with full path, may not resolve if only a relative path is given), file:, http:, or
https: URL. The file will be fetched first if it is an HTTP URL.</p:documentation>
</p:option>
<p:option name="debug" select="'no'"/>
<p:option name="debug-dir-uri" select="'debug'"/>
<p:option name="status-dir-uri" select="'status'"/>
<p:option name="srcpaths" select="'no'"/>
<p:option name="unwrap-tooltip-links" select="'no'"/>
<p:option name="remove-biblioentry-paragraphs" select="'yes'">
<p:documentation xmlns="http:https://www.w3.org/1999/xhtml">
<p>Remove formatted paragraphs of reference managers from their position in the content flow.</p>
<dl>
<dt>yes (or any other unknown value)</dt>
<dd>Remove from content flow. Replace it with an empty processing instruction
and additionally save the paragraphs in a bibliography at the end of the document.</dd>
<dt>yes-without-pi</dt>
<dd>Same as 'yes', without the processing instruction.</dd>
<dt>no</dt>
<dd>Let paragraphs stay. Additionally saved in bibliography element at the end of the document.</dd>
<dt>no-in-div-wrapped</dt>
<dd>Same as 'no'; the paragraphs are wrapped in an extra div element.</dd>
</dl>
<p><strong>Notice on linked Citavi biblioentry elements:</strong></p>
<p>You have to check for 'Link in-text citations to references in the bibliography'
turned on in the Citavi document settings.</p>
</p:documentation>
</p:option>
<p:option name="mml-space-handling" select="'mspace'">
<p:documentation xmlns="http:https://www.w3.org/1999/xhtml">
<p>Whitespace conversion from OMML to MathML</p>
<dl>
<dt>none</dt>
<dd>All whitespace will be in mtext, without xml:space attributes</dd>
<dt>xml-space</dt>
<dd>Same mtext as for 'none', with xml:space="preserve" attribute when \s at the beginning or end</dd>
<dt>figure-space</dt>
<dd>Each \s char will converted to U+2007, still within mtext. Special handling for tabs and newlines tbd</dd>
<dt>mspace</dt>
<dd>Start and end \s will be converted to mspace with a width of 0.25em for each char</dd>
</dl>
</p:documentation>
</p:option>
<p:option name="mml-version" select="''">
<p:documentation>
MathML 3: leave empty.
MathML 4 Core: '4-core' (not full supported yet)
</p:documentation>
</p:option>
<p:option name="hub-version" select="'1.2'"/>
<p:option name="fail-on-error" select="'no'"/>
<p:option name="field-vars" select="'no'"/>
<p:option name="extract-dir" select="''">
<p:documentation>Directory (OS path, not file: URL) to which the file will be unzipped. If option is empty string, will be
'.tmp' appended to OS file path.
Will be available as extract-dir-uri in the c:param-set document that comes out of single-tree-enhanced on the
params port.</p:documentation>
</p:option>
<p:option name="discard-alternate-choices" select="'yes'">
<p:documentation>Whether to remove mc:AlternateContent/mc:Choice at an early conversion stage (after insert-xpath
though).</p:documentation>
</p:option>
<p:option name="charmap-policy" select="'unicode'">
<p:documentation>Pass a policy for mapping characters from non-unicode fonts:
'unicode' maps characters strictly to their unicode equivalents. Please be aware that
preinstalled fonts may not be able to display uncommon characters correctly.
'msoffice' tries to map each character in a way that it can be displayed with typical MS Office fonts,
even if the appearance of the character doesn't match exactly those of its source.
</p:documentation>
</p:option>
<p:option name="mathtype2mml" required="false" select="'yes'">
<p:documentation xmlns="http:https://www.w3.org/1999/xhtml">
<p>Activates use of mathtype2mml extension.</p>
<p>Should be one of the following String values:</p>
<dl>
<dt>no</dt>
<dd>no conversion happens</dd>
<dt>ole</dt>
<dd>Use the OLE-Object as source for equation.</dd>
<dt>wmf</dt>
<dd>
Use the wmf-image as source for MTEF equation. <br/>
If no equation is found in wmf file, OLE-Object is used as fallback
</dd>
<dt>'wmf+ole' | 'ole+wmf'</dt>
<dd>
Use both, wmf and OLE as source for MTEF equation <br/>
If both are deep-equal, only one MathML equation will be output. <br/>
If they differ, both equations will be output. <br/>
In addition, a processing-instruction will be added after the MathML equation, stating that the MathML equations (from wmf and ole sources) differ. <br/>
The order is defined by the order in the String (wmf+ole makes wmf equation appear first, ole+wmf makes ole equation appear first).
<dt>yes</dt>
<dd>
Same as 'ole'. <br/>
This is the default value for the option.
</dd>
<dt>any other String</dt>
<dd>Is treated as 'yes', but see the next paragraph.</dd>
</dd>
</dl>
<p>Note that both <code>ole</code> and <code>wmf</code> options will only process <code>v:shape</code>
obejcts that contain an <code>o:OLEObject</code>. It may happen that WMF files are just embedded as images,
not with an accompanying OLE object. In this case, append <code>+try-all-pict-wmf</code> to the option.
Example: <code>mathtype2mml=ole+wmf+try-all-pict-wmf</code>.</p>
</p:documentation>
</p:option>
<p:option name="mathtype-source-pi" required="false" select="'no'">
<p:documentation xmlns="http:https://www.w3.org/1999/xhtml">
<p>If not set to 'no', each mml-equation also bears a processing-instruction stating its source (file ending):
<dl>
<dt>M2M_210</dt>
<dd>MathML equation source:ole</dd>
<dt>M2M_211</dt>
<dd>MathML equation source:wmf</dd>
</dl>
</p>
</p:documentation>
</p:option>
<p:option name="apply-changemarkup" required="false" select="'yes'">
<p:documentation xmlns="http:https://www.w3.org/1999/xhtml">
<p>Apply all change markup on the compound word document.</p>
</p:documentation>
</p:option>
<p:option name="use-filename-from-http-response" required="false" select="'no'">
<p:documentation>Use filename that is passed on from http request response instead of
possible filename read from URL in tr:file-uri (for example when using Gdocs URLs:
https://docs.google.com/document/d/1Z5eYyjLoRhB24HYZ-d-wQKAFD3QDWZUsQH4cKHs2eiM/export?format=docx)</p:documentation>
</p:option>
<p:option name="check-tables" required="false" select="'no'">
<p:documentation>If this option is set to 'yes' all tables are normalized with calstable and checked against
schematron</p:documentation>
</p:option>
<p:option name="create-svg" select="'false'">
<p:documentation>Whether to convert DrawingML to SVG. This is an experimental feature. Text in v:textbox
elements will not be retained at the moment.</p:documentation>
</p:option>
<p:option name="include-header-and-footer" required="false" select="'no'">
<p:documentation>Whether to include headers and footers as div at the beginning of the document. Permitted values: yes|no</p:documentation>
</p:option>
<p:option name="insert-document-defaults" required="false" select="'yes'">
<p:documentation>Insert default attributes (i.e. document language and font names). Permitted values: yes|no</p:documentation>
</p:option>
<p:option name="float-nr-check-error-level" select="''"/>
<p:option name="report-referenced-images-in-docx" required="false" select="'no'">
<p:documentation>If set to 'yes' or 'true' schematron checks for referenced images. Useful if your workflow includes processing images from docx rather than from external sources.</p:documentation>
</p:option>
<p:option name="lang-variant" select="'no'">
<p:documentation>When this option is set to 'yes', @xml:lang attributes will include
the language variant, e.g. 'en-GB'. Per default only the short language code
is provided ('en').</p:documentation>
</p:option>
<p:option name="terminate-on-unbalanced-instrTexts" required="false" select="'yes'"/>
<p:option name="keep-paraid" required="false" select="'false'">
<p:documentation>Keep Word created w14:paraId and w14:textId</p:documentation>
</p:option>
<p:option name="heuristic-character-replacements" select="'#all'">
<p:documentation>Replace Cyrillic symbols in formulas with similar-looking Greek ones, replace
small letter 'o' as bullet list marker with U+26AC ('⚬'), etc.
This option accepts space-separated tokens. The list will be extended over time.
The default '#all' will effect that all replacements will done, '#lists' will apply
all list-related replacements, '#formulas' will apply all formula-related replacements,
'bullet-o' will carry out said bullet character replacement, etc.
Search for $heuristic-character-replacement-tokens in the XSLT code in order to find out
which keywords are available.</p:documentation>
</p:option>
<p:option name="table-headers-and-footers-from-tblLook" select="'no'">
<p:documentation>Whether to use the first row and last row feature
of more recent Microsoft Word versions to render <thead> and <tfoot>.
Otherwise <thead> is only generated when you select the
"Repeat as header row at the top of each page" check box in the Table Properties dialog box on the Row tab.
</p:documentation>
</p:option>
<p:option name="normalize-thead" select="'yes'">
<p:documentation>morerows attributes in <thead> can span <tbody> rows, too. Whether to normalize it and make this rows part of the <thead> to avoid unbalanced rows.</p:documentation>
</p:option>
<p:import href="http:https://xmlcalabash.com/extension/steps/library-1.0.xpl"/>
<p:import href="http:https://transpect.io/calabash-extensions/unzip-extension/unzip-declaration.xpl"/>
<p:import href="http:https://transpect.io/xproc-util/file-uri/xpl/file-uri.xpl"/>
<p:import href="http:https://transpect.io/xproc-util/xml-model/xpl/prepend-hub-xml-model.xpl"/>
<p:import href="http:https://transpect.io/xproc-util/xslt-mode/xpl/xslt-mode.xpl"/>
<p:import href="http:https://transpect.io/xproc-util/store-debug/xpl/store-debug.xpl"/>
<p:import href="http:https://transpect.io/xproc-util/simple-progress-msg/xpl/simple-progress-msg.xpl"
use-when="doc-available('http:https://transpect.io/xproc-util/simple-progress-msg/xpl/simple-progress-msg.xpl')"/>
<p:import href="single-tree-enhanced.xpl"/>
<p:import href="mathtype2mml.xpl"/>
<p:import href="apply-changemarkup.xpl"/>
<p:import href="http:https://transpect.io/htmlreports/xpl/errorPI2svrl.xpl"/>
<p:group use-when="doc-available('http:https://transpect.io/xproc-util/simple-progress-msg/xpl/simple-progress-msg.xpl')">
<tr:simple-progress-msg name="start-msg" file="docx2hub-start.txt">
<p:input port="msgs">
<p:inline>
<c:messages>
<c:message xml:lang="en">Starting DOCX to flat Hub XML conversion</c:message>
<c:message xml:lang="de">Beginne Konvertierung von DOCX zu flachem Hub XML</c:message>
</c:messages>
</p:inline>
</p:input>
<p:with-option name="status-dir-uri" select="$status-dir-uri"/>
</tr:simple-progress-msg>
</p:group>
<docx2hub:single-tree-enhanced name="single-tree-enhanced">
<p:with-option name="docx" select="$docx"/>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="status-dir-uri" select="$status-dir-uri"/>
<p:with-option name="srcpaths" select="$srcpaths"/>
<p:with-option name="unwrap-tooltip-links" select="$unwrap-tooltip-links"/>
<p:with-option name="mml-space-handling" select="$mml-space-handling"/>
<p:with-option name="hub-version" select="$hub-version"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-option name="field-vars" select="$field-vars"/>
<p:with-option name="extract-dir" select="$extract-dir"/>
<p:with-option name="remove-biblioentry-paragraphs" select="$remove-biblioentry-paragraphs"/>
<p:with-option name="mathtype2mml" select="$mathtype2mml"/>
<p:with-option name="mathtype-source-pi" select="$mathtype-source-pi"/>
<p:with-option name="use-filename-from-http-response" select="$use-filename-from-http-response"/>
<p:with-option name="apply-changemarkup" select="$apply-changemarkup"/>
<p:with-option name="insert-document-defaults" select="$insert-document-defaults"/>
<p:input port="single-tree-schematron">
<p:pipe step="docx2hub" port="single-tree-schematron"/>
</p:input>
<p:input port="change-markup-schematron">
<p:pipe step="docx2hub" port="changemarkup-schematron"/>
</p:input>
<p:input port="mathtype2mml-schematron">
<p:pipe step="docx2hub" port="mathtype2mml-schematron"/>
</p:input>
<p:input port="xslt">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="custom-font-maps">
<p:pipe port="custom-font-maps" step="docx2hub"/>
</p:input>
</docx2hub:single-tree-enhanced>
<!--<tr:xslt-mode msg="yes" mode="docx2hub:preprocess-styles" name="preprocess-styles">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/03a')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="field-vars" select="$field-vars"/>
<p:with-param name="mathtype2mml" select="$mathtype2mml"/>
</tr:xslt-mode>-->
<tr:xslt-mode msg="yes" mode="docx2hub:resolve-tblBorders" name="resolve-tblBorders">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/03b')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="field-vars" select="$field-vars"/>
<p:with-param name="mathtype2mml" select="$mathtype2mml"/>
</tr:xslt-mode>
<tr:xslt-mode msg="yes" mode="docx2hub:add-props" name="add-props">
<p:input port="source">
<p:pipe port="result" step="resolve-tblBorders"/>
<p:pipe port="custom-font-maps" step="docx2hub"/>
<p:document href="http:https://this.transpect.io/xmlcatalog/catalog.xml"/>
</p:input>
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/04')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="field-vars" select="$field-vars"/>
<p:with-param name="mathtype2mml" select="$mathtype2mml"/>
<p:with-param name="lang-variant" select="$lang-variant"/>
<p:with-param name="discard-alternate-choices" select="$discard-alternate-choices"/>
<p:with-param name="include-header-and-footer" select="$include-header-and-footer"/>
<p:with-param name="float-nr-check-error-level" select="$float-nr-check-error-level"/>
<p:with-param name="create-svg" select="$create-svg"/>
</tr:xslt-mode>
<tr:xslt-mode msg="yes" mode="docx2hub:props2atts" name="props2atts">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/05')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
</tr:xslt-mode>
<tr:xslt-mode msg="yes" mode="docx2hub:remove-redundant-run-atts" name="remove-redundant-run-atts">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/07')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="heuristic-character-replacements" select="$heuristic-character-replacements"/>
</tr:xslt-mode>
<p:sink/>
<p:identity name="join-instrText-runs-input">
<p:input port="source">
<p:pipe port="result" step="remove-redundant-run-atts"/>
<p:pipe port="custom-font-maps" step="docx2hub"/>
<p:document href="http:https://this.transpect.io/xmlcatalog/catalog.xml"/>
</p:input>
</p:identity>
<tr:store-debug name="store-join-instrText-runs-input">
<p:with-option name="pipeline-step"
select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/08-join-instrText-runs-input')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="active" select="$debug"><p:empty/></p:with-option>
<p:with-option name="base-uri" select="$debug-dir-uri"><p:empty/></p:with-option>
</tr:store-debug>
<tr:xslt-mode msg="yes" mode="docx2hub:join-instrText-runs" name="join-instrText-runs">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/08')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"><p:empty/></p:with-option>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"><p:empty/></p:with-option>
<p:with-option name="fail-on-error" select="$fail-on-error"><p:empty/></p:with-option>
<p:with-option name="hub-version" select="$hub-version"><p:empty/></p:with-option>
<p:with-param name="fail-on-error" select="$fail-on-error"><p:empty/></p:with-param>
<p:with-param name="terminate-on-unbalanced-instrTexts" select="'no'"><p:empty/></p:with-param>
</tr:xslt-mode>
<p:viewport name="citavi-viewport"
match="w:instrText[starts-with(@docx2hub:field-function-name, 'CITAVI')]
[not(normalize-space(@docx2hub:field-function-args) = 'ADDIN CITAVI.PLACEHOLDER')]">
<p:documentation>Since there seems to be no other means in XProc 1.0 (with Saxon HE that does not support the
EXPath binary module) to decode base64, we will store these contents to JSON files and read them later using
XPath 3.1 json-doc(). The same for CITAVI.BIBLIOGRAPHY which apparently is base64-encoded XML.</p:documentation>
<p:output port="result" primary="true">
<p:pipe port="result" step="new-Citavi-field-code"/>
</p:output>
<p:variable name="pos" select="p:iteration-position()"/>
<p:variable name="filetype" select="lower-case(replace(/*/@docx2hub:field-function-name, 'CITAVI_', ''))"/>
<p:variable name="filename"
select="concat(/c:param-set/c:param[@name='extract-dir-uri']/@value, 'Citavi/Citavi_', $pos, '.', $filetype)">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:variable>
<p:add-attribute attribute-name="docx2hub:field-function-args" match="/*" name="new-Citavi-field-code">
<p:with-option name="attribute-value" select="$filename"/>
</p:add-attribute>
<p:sink name="citavi-sink1"/>
<p:add-attribute match="/*" name="add-citavi-content-type" attribute-name="content-type">
<p:input port="source">
<p:inline><c:data encoding="base64">dummy</c:data></p:inline>
</p:input>
<p:with-option name="attribute-value" select="concat('application/', $filetype)"/>
</p:add-attribute>
<p:string-replace match="/c:data/text()" name="citavi-base64-to-c_data">
<p:with-option name="replace" select="concat('''', /*/@docx2hub:field-function-args, '''')">
<p:pipe port="current" step="citavi-viewport"/>
</p:with-option>
</p:string-replace>
<p:store cx:decode="true" name="store-citavi-file">
<p:with-option name="href" select="$filename"/>
</p:store>
</p:viewport>
<p:choose>
<p:when test="exists(.//w:instrText[starts-with(@docx2hub:field-function-name, 'CITAVI')])">
<tr:store-debug>
<p:with-option name="pipeline-step"
select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/09-citavi-viewport')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="active" select="$debug"/>
<p:with-option name="base-uri" select="$debug-dir-uri"/>
</tr:store-debug>
</p:when>
<p:otherwise>
<p:identity/>
</p:otherwise>
</p:choose>
<tr:xslt-mode msg="yes" mode="docx2hub:field-functions" name="field-functions">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/14')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
</tr:xslt-mode>
<p:validate-with-schematron assert-valid="false" name="check-field-functions0">
<p:input port="schema">
<p:pipe port="field-functions-schematron" step="docx2hub"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
<p:with-param name="allow-foreign" select="'true'"/>
</p:validate-with-schematron>
<p:sink/>
<p:add-attribute match="/*"
attribute-name="tr:step-name" attribute-value="docx2hub">
<p:input port="source">
<p:pipe port="report" step="check-field-functions0"/>
</p:input>
</p:add-attribute>
<p:add-attribute name="check-field-functions1" match="/*"
attribute-name="tr:rule-family" attribute-value="docx2hub_field-functions">
<p:documentation>Will also check other things such as change markup.</p:documentation>
</p:add-attribute>
<p:insert name="check-field-functions" match="/*" position="first-child">
<p:input port="insertion" select="/*/*:title">
<p:pipe port="field-functions-schematron" step="docx2hub"/>
</p:input>
</p:insert>
<p:sink/>
<p:add-attribute match="/*"
attribute-name="tr:step-name"
attribute-value="docx2hub">
<p:input port="source">
<p:pipe port="field-functions-schematron" step="docx2hub"/>
</p:input>
</p:add-attribute>
<p:add-attribute name="decorate-field-functions-schematron0"
match="/*"
attribute-name="tr:rule-family"
attribute-value="docx2hub">
</p:add-attribute>
<p:insert name="decorate-field-functions-schematron" match="/*" position="first-child">
<p:input port="insertion" select="/*/*:title">
<p:pipe port="field-functions-schematron" step="docx2hub"/>
</p:input>
</p:insert>
<p:sink/>
<p:identity name="wml-to-dbk-input">
<p:input port="source">
<p:pipe port="result" step="field-functions"/>
<p:pipe port="custom-font-maps" step="docx2hub"/>
<p:document href="http:https://this.transpect.io/xmlcatalog/catalog.xml"/>
</p:input>
</p:identity>
<tr:store-debug name="store-wml-to-dbk-input">
<p:with-option name="pipeline-step"
select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/20-wml-to-dbk-input')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="active" select="$debug"><p:empty/></p:with-option>
<p:with-option name="base-uri" select="$debug-dir-uri"><p:empty/></p:with-option>
</tr:store-debug>
<tr:xslt-mode msg="yes" mode="wml-to-dbk" name="wml-to-dbk">
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/20')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"><p:empty/></p:with-option>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"><p:empty/></p:with-option>
<p:with-option name="fail-on-error" select="$fail-on-error"><p:empty/></p:with-option>
<p:with-option name="hub-version" select="$hub-version"><p:empty/></p:with-option>
<p:with-param name="srcpaths" select="$srcpaths"><p:empty/></p:with-param>
<p:with-param name="unwrap-tooltip-links" select="$unwrap-tooltip-links"><p:empty/></p:with-param>
<p:with-param name="fail-on-error" select="$fail-on-error"><p:empty/></p:with-param>
<p:with-param name="field-vars" select="$field-vars"><p:empty/></p:with-param>
<p:with-param name="charmap-policy" select="$charmap-policy"><p:empty/></p:with-param>
<p:with-param name="keep-paraid" select="$keep-paraid"><p:empty/></p:with-param>
<p:with-param name="mml-version" select="$mml-version"><p:empty/></p:with-param>
<p:with-param name="heuristic-character-replacements" select="$heuristic-character-replacements"><p:empty/></p:with-param>
<p:with-param name="table-headers-and-footers-from-tblLook" select="$table-headers-and-footers-from-tblLook"><p:empty/></p:with-param>
</tr:xslt-mode>
<p:sink/>
<tr:xslt-mode msg="yes" mode="docx2hub:join-runs" name="join-runs">
<p:input port="source">
<p:pipe port="result" step="wml-to-dbk"/>
<p:document href="http:https://this.transpect.io/xmlcatalog/catalog.xml"/>
</p:input>
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
<p:input port="stylesheet">
<p:pipe step="docx2hub" port="xslt"/>
</p:input>
<p:input port="models">
<p:empty/>
</p:input>
<p:with-option name="prefix" select="concat('docx2hub/', /c:param-set/c:param[@name='basename']/@value, '/24')">
<p:pipe port="params" step="single-tree-enhanced"/>
</p:with-option>
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="fail-on-error" select="$fail-on-error"/>
<p:with-option name="hub-version" select="$hub-version"/>
<p:with-param name="fail-on-error" select="$fail-on-error"/>
<p:with-param name="heuristic-character-replacements" select="$heuristic-character-replacements"/>
<p:with-param name="normalize-thead" select="$normalize-thead"/>
</tr:xslt-mode>
<p:add-attribute match="/*" attribute-name="xml:base" name="rebase">
<p:with-option name="attribute-value"
select="replace(/c:param-set/c:param[@name='local-href']/@value, '\.do[ct][xm]$', '.hub.xml')">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:with-option>
</p:add-attribute>
<tr:errorPI2svrl name="errorPI2svrl" pi-names="tr" group-by-srcpath="no">
<p:with-option name="debug" select="$debug"/>
<p:with-option name="debug-dir-uri" select="$debug-dir-uri"/>
<p:with-option name="status-dir-uri" select="$status-dir-uri"/>
</tr:errorPI2svrl>
<p:sink/>
<!-- table normalization -->
<p:choose name="check-tables">
<p:when test="$check-tables='yes'">
<p:output port="normalized-tables">
<p:pipe port="result" step="normalize-tables"/>
</p:output>
<p:output port="report" sequence="true">
<p:pipe port="result" step="sch_tables_cals"/>
<p:pipe port="result" step="sch_tables_d2h"/>
</p:output>
<p:validate-with-schematron assert-valid="false" name="sch_tables_d2h-0">
<p:input port="source">
<p:pipe step="single-tree-enhanced" port="result"/>
</p:input>
<p:input port="schema">
<p:pipe port="check-tables-schematron" step="docx2hub"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
<p:with-param name="allow-foreign" select="'true'"/>
</p:validate-with-schematron>
<p:add-attribute match="/*"
attribute-name="tr:step-name" attribute-value="docx2hub">
<p:input port="source">
<p:pipe port="report" step="sch_tables_d2h-0"/>
</p:input>
</p:add-attribute>
<p:add-attribute name="sch_tables_d2h-1" match="/*"
attribute-name="tr:rule-family" attribute-value="docx2hub_tables">
</p:add-attribute>
<p:insert name="sch_tables_d2h" match="/*" position="first-child">
<p:input port="insertion" select="/*/*:title">
<p:pipe port="check-tables-schematron" step="docx2hub"/>
</p:input>
</p:insert>
<p:sink/>
<p:xslt name="normalize-tables">
<p:input port="source">
<p:pipe port="result" step="join-runs"/>
</p:input>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet xmlns:xsl="http:https://www.w3.org/1999/XSL/Transform"
xmlns:calstable="http:https://docs.oasis-open.org/ns/oasis-exchange/table"
version="2.0">
<xsl:import href="http:https://transpect.io/xslt-util/calstable/xsl/normalize.xsl"/>
<xsl:template match="node() | @*" >
<xsl:copy>
<xsl:apply-templates select="@*, node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[*:row]">
<xsl:sequence select="calstable:check-normalized(
calstable:normalize(.),
'no'
)"/>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
<p:input port="parameters">
<p:pipe step="single-tree-enhanced" port="params"/>
</p:input>
</p:xslt>
<p:validate-with-schematron assert-valid="false" name="sch_tables_cals0">
<p:input port="schema">
<p:document href="http:https://transpect.io/xslt-util/calstable/sch/sch_tables.sch.xml"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
<p:with-param name="allow-foreign" select="'true'"/>
</p:validate-with-schematron>
<p:sink/>
<p:add-attribute match="/*"
attribute-name="tr:step-name" attribute-value="docx2hub">
<p:input port="source">
<p:pipe port="report" step="sch_tables_cals0"/>
</p:input>
</p:add-attribute>
<p:add-attribute name="sch_tables-cals1" match="/*"
attribute-name="tr:rule-family" attribute-value="docx2hub_tables">
</p:add-attribute>
<p:insert name="sch_tables_cals" match="/*" position="first-child">
<p:input port="insertion" select="/*/*:title">
<p:document href="http:https://transpect.io/xslt-util/calstable/sch/sch_tables.sch.xml"/>
</p:input>
</p:insert>
</p:when>
<p:otherwise>
<p:output port="normalized-tables">
<p:pipe port="result" step="identity"/>
</p:output>
<p:output port="report">
<p:empty/>
</p:output>
<p:identity name="identity">
<p:input port="source">
<p:pipe port="result" step="join-runs"/>
</p:input>
</p:identity>
</p:otherwise>
</p:choose>
<p:for-each name="rename-errorPI2svrl-reports">
<p:output port="result" primary="true"/>
<p:iteration-source>
<p:pipe port="report" step="errorPI2svrl"/>
</p:iteration-source>
<p:add-attribute attribute-name="tr:rule-family" match="/*" name="rename-errorPI2svrl-reports0">
<p:with-option name="attribute-value" select="replace(/*/@tr:rule-family, '^W2D', 'docx2hub_PI')"/>
</p:add-attribute>
</p:for-each>
<p:sink/>
<tr:prepend-hub-xml-model name="pi">
<p:input port="source">
<p:pipe port="result" step="errorPI2svrl"/>
</p:input>
<p:with-option name="hub-version" select="$hub-version"/>
</tr:prepend-hub-xml-model>
<p:validate-with-schematron assert-valid="false" name="check-result0">
<p:input port="schema">
<p:pipe port="result-schematron" step="docx2hub"/>
</p:input>
<p:input port="parameters"><p:empty/></p:input>
<p:with-param name="allow-foreign" select="'true'"/>
<p:with-param name="report-referenced-images-in-docx" select="$report-referenced-images-in-docx"/>
</p:validate-with-schematron>
<p:sink/>
<p:add-attribute name="check-result1" match="/*"
attribute-name="tr:rule-family" attribute-value="docx2hub_result">
<p:input port="source">
<p:pipe port="report" step="check-result0"/>
</p:input>
</p:add-attribute>
<p:insert name="check-result" match="/*" position="first-child">
<p:input port="insertion" select="/*/*:title">
<p:pipe port="result-schematron" step="docx2hub"/>
</p:input>
</p:insert>
<p:sink/>
<p:add-attribute name="decorate-result-schematron" match="/*"
attribute-name="tr:rule-family" attribute-value="docx2hub">
<p:input port="source">
<p:pipe port="result-schematron" step="docx2hub"/>
</p:input>
</p:add-attribute>
<p:sink/>
<p:identity>
<p:input port="source">
<p:pipe port="result" step="pi"/>
</p:input>
</p:identity>
<p:group use-when="doc-available('http:https://transpect.io/xproc-util/simple-progress-msg/xpl/simple-progress-msg.xpl')">
<tr:simple-progress-msg name="success-msg" file="docx2hub-success.txt">
<p:input port="msgs">
<p:inline>
<c:messages>
<c:message xml:lang="en">Successfully finished DOCX to flat Hub XML conversion</c:message>
<c:message xml:lang="de">Konvertierung von DOCX zu flachem Hub XML erfolgreich abgeschlossen</c:message>
</c:messages>
</p:inline>
</p:input>
<p:with-option name="status-dir-uri" select="$status-dir-uri"/>
</tr:simple-progress-msg>
</p:group>
</p:declare-step>