├── .gitmodules
├── LICENSE
├── README.md
├── idml2xml.sh
├── idml2xml.xpr
├── sample
├── hello-world.idml
└── hello-world.xml
├── xmlcatalog
└── catalog.xml
└── xpl
└── idml2xml-frontend.xpl
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "calabash"]
2 | path = calabash
3 | url = https://github.com/transpect/calabash-frontend
4 | [submodule "xproc-util"]
5 | path = xproc-util
6 | url = https://github.com/transpect/xproc-util
7 | [submodule "xslt-util"]
8 | path = xslt-util
9 | url = https://github.com/transpect/xslt-util
10 | [submodule "idml2xml"]
11 | path = idml2xml
12 | url = https://github.com/transpect/idml2xml
13 | [submodule "schema/hub"]
14 | path = schema/hub
15 | url = https://github.com/le-tex/Hub
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) 2017, transpect.io
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # idml2xml
2 |
3 | Converts InDesign IDML to XML. Based on the transpect module [idml2xml](https://github.com/transpect/idml2xml).
4 |
5 | ## Introduction
6 |
7 | Considering this [hello world example](https://github.com/transpect/idml2xml-frontend/tree/master/sample), idml2xml will generate flat [Hub XML with CSSa XML attributes](http://publishinggeekly.com/wp-content/uploads/2013/01/CSSa.pdf).
8 |
9 | ```xml
10 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
28 |
29 |
30 | hello world
31 |
32 | ```
33 |
34 | ## Requirements
35 |
36 | At least Java 1.7 is required.
37 |
38 | ## Clone this project
39 |
40 | This project depends on Git submodules. Therefore you have to clone it with the `--recurse-submodules` option to get the submodules, too:
41 |
42 | ```
43 | git clone https://github.com/transpect/idml2xml-frontend --recurse-submodules
44 | ```
45 |
46 | ## Invocation
47 |
48 | ### Bash
49 |
50 | For convenient use on command line, we provide a simple Bash script. You can run it in this way:
51 | ```
52 | ./idml2xml.sh sample/hello-world.idml
53 | ```
54 |
55 | ### Calabash
56 |
57 | We provide also Bash and Windows Batch scripts to invoke the XProc pipeline directly:
58 |
59 | ```
60 | ./calabash.sh -o result=sample/hello-world.xml xpl/idml2xml-frontend.xpl idml=sample/hello-world.idml
61 | ```
62 |
63 | ## Include idml2xml in your XProc project
64 |
65 | Please refer to this [tutorial](http://transpect.github.io/getting-started.html) for a more extensive documentation.
66 |
--------------------------------------------------------------------------------
/idml2xml.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | function usage {
4 | echo ""
5 | echo "idml2xml"
6 | echo ""
7 | echo "Usage: idml2xml.sh [options ...] "
8 | echo ""
9 | echo "Options:"
10 | echo " -o relative or absolute path to custom output directory"
11 | echo " -d debug mode"
12 | 1>&2; exit 1;
13 | }
14 | function exitonerror {
15 | echo "[ERROR] $2. Exited with code $1."
16 | echo "For details see $LOG"
17 | exit 1
18 | }
19 | function log {
20 | 2>&1 2>>$OUT_DIR/$BASENAME.d2h.log
21 | }
22 |
23 | # cygwin check
24 | cygwin=false;
25 | case "`uname`" in
26 | CYGWIN*) cygwin=true;
27 | esac
28 |
29 | # script directory
30 | DIR="$( cd -P "$(dirname $( readlink -f "$0" ))" && pwd )"
31 | PWD=$(readlink -f .)
32 | CALABASH=$DIR/calabash/calabash.sh
33 | HEAP=1024m
34 |
35 | # specify options
36 | while getopts ":o:d" opt; do
37 | case "${opt}" in
38 | o)
39 | OUT_DIR=${OPTARG}
40 | ;;
41 | d)
42 | DEBUG=yes
43 | ;;
44 | \?)
45 | echo "Invalid option: -$OPTARG" >&2
46 | usage
47 | ;;
48 | :)
49 | echo "Option -$OPTARG requires an argument." >&2
50 | usage
51 | ;;
52 | esac
53 | done
54 | shift $((OPTIND-1))
55 | # check if argument for file is set
56 | if [ -z $1 ]; then
57 | usage
58 | fi
59 |
60 | FILE=$(readlink -f $1)
61 | BASENAME=$(basename $FILE .idml)
62 | if [[ -z "$OUT_DIR" ]]; then
63 | OUT_DIR="$(dirname $(readlink -f "$FILE" ))"
64 | else
65 | if [[ "$OUT_DIR" != /* ]]; then
66 | OUT_DIR="$PWD/$OUT_DIR"
67 | fi
68 | fi
69 |
70 | mkdir -p $OUT_DIR
71 |
72 | # set log
73 | LOG=$OUT_DIR/$BASENAME.log
74 | # remove log from previous runs
75 | if [ -e $LOG ]; then
76 | rm $LOG
77 | fi
78 |
79 | # debugging
80 | DEBUG_DIR=$OUT_DIR/$BASENAME.debug
81 |
82 | # make absolute paths
83 | if $cygwin; then
84 | FILE=$(cygpath -ma "$FILE")
85 | DIR=$(cygpath -ma "$DIR")
86 | OUT_DIR=$(cygpath -ma "$OUT_DIR")
87 | DEBUG_DIR_URI=file:/$(cygpath -ma "$DEBUG_DIR" )
88 | else
89 | DEBUG_DIR_URI=file:$(readlink -f $DEBUG_DIR)
90 | fi
91 |
92 | # check if file exists
93 | if [ ! -f $FILE ]; then
94 | exitonerror 1 "input file not found: $FILE"
95 | fi
96 |
97 | echo "starting idml2xml"
98 |
99 | if [ "$DEBUG" = "yes" ]; then
100 | echo "debug mode: $DEBUG"
101 | echo "storing debug files to $DEBUG_DIR"
102 | echo ""
103 | echo "Parameters"
104 | echo " workdir: $DIR"
105 | echo " outdir: $OUT_DIR"
106 | echo " file: $FILE"
107 | echo ""
108 | fi
109 |
110 | # idml2xml xproc pipeline
111 | HEAP=$HEAP $CALABASH \
112 | -o result=$OUT_DIR/$BASENAME.xml \
113 | $DIR/xpl/idml2xml-frontend.xpl \
114 | idml=$FILE \
115 | debug=$DEBUG \
116 | debug-dir-uri=$DEBUG_DIR_URI \
117 | status-dir-uri=$DEBUG_DIR_URI/status 2>&1 2>>$LOG || exitonerror $? xproc
118 |
119 |
120 | # delete temp files
121 | if [ "$DEBUG" != "yes" ]; then
122 | rm -rf $FILE.tmp $DEBUG_DIR
123 | fi
124 |
125 | echo "writing xml => $OUT_DIR/$BASENAME.xml"
126 |
127 | echo "idml2xml finished, for details see $LOG"
128 | echo ""
129 |
--------------------------------------------------------------------------------
/idml2xml.xpr:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/sample/hello-world.idml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/transpect/idml2xml-frontend/acfe9abcdb09200a491ee0579cf3e5ed543e251d/sample/hello-world.idml
--------------------------------------------------------------------------------
/sample/hello-world.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 | hello-world
9 | file:/C:/cygwin64/home/kraetke/idml2xml-frontend/sample/hello-world.idml.tmp/
10 | file:/C:/cygwin64/home/kraetke/idml2xml-frontend/sample/
11 | false
12 | true
13 | true
14 | idml
15 | Inhalt
16 | 523.275590551
17 |
18 |
19 |
23 |
24 |
25 | hello world
26 |
27 |
--------------------------------------------------------------------------------
/xmlcatalog/catalog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/xpl/idml2xml-frontend.xpl:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | Frontend pipeline which implements the idml2xml library.
9 | This step takes an IDML file from InDesign and transform it
10 | to Hub XML.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------