# The w2x command-line utility

If the `.dmg` distribution has been used to install XMLmind Word To XML on the Mac, the `w2x` command-line utility is found in `WordToXML.app/Contents/Resources/w2x/bin/`.

Usage:

    w2x [-version] [-v|-vv|-vvv] [Options]
        in_docx_file out_file
        | -batch out_spec in_docx_file1 ... in_docx_fileN
        | -printenv
        | -liststeps

-v
-vv
-vvv
  Verbose. More Vs means more verbose.
-version
  Print version number and exit.
-batch out_spec in_docx_file1 … in_docx_fileN
  Convert all specified input DOCX files. out_spec specifies the absolute or relative path of the output files. It may contain the following variables: @{name}, basename of the input file without any extension, @{parent}, absolute path of the directory containing the input file. Example:

      C:\Users\jane> w2x -o docbook5 -batch pub\@{name}.xml Documents\*.docx

  Same example but this time, convert all DOCX files in place:

      C:\Users\jane> w2x -o docbook5 -batch @{parent}\@{name}.xml Documents\*.docx

-printenv
  Print supported environment variables/system properties and exit. Example:

      C:\> w2x -printenv
      W2X_TRACE=
      (Supported values are: "image", "math" or "all".)

      W2X_IMAGE_CONVERSIONS=
      .wmf.svg java:com.xmlmind.w2x_ext.wmf_converter.WMFConverterFactory;
      .emf.png.wmf.png java:com.xmlmind.w2x_ext.emf2png.EMF2PNG;
      .bmp.jpg.bmp.jpeg.bmp.png.gif.jpg.gif.jpeg.gif.png
      .jpeg.png.jpg.png.png.jpg.png.jpeg.tif.jpg.tif.jpeg
      .tif.png.tiff.jpg.tiff.jpeg.tiff.png.wbmp.jpg.wbmp.jpeg
      .wbmp.png java:com.xmlmind.w2x.docx.image.ImageConverterFactoryImpl

-liststeps
  List the conversion steps to be executed and exit. This option is useful to determine how to customize the conversion steps. Example:

      $ w2x -o bookmap -liststeps
      -step:com.xmlmind.w2x.processor.ConvertStep:convert
      -p convert.create-mathml-object no
      -p convert.set-column-number yes
      -step:com.xmlmind.w2x.processor.EditStep:edit
      -p edit.xed-url-or-file file:/opt/w2x/xed/main.xed
      -step:com.xmlmind.w2x.processor.TransformStep:transform
      -p transform.out-file %{~pnO}.dita
      -p transform.single-topic no
      -p transform.xslt-url-or-file file:/opt/w2x/xslt/topic.xslt
      -step:com.xmlmind.w2x.processor.TransformStep:transform2
      -p transform2.xslt-url-or-file file:/opt/w2x/xslt/bookmap.xslt
      -p transform2.topic-type %{transform.topic-type}
      -p transform2.output-path %{~po}
      -step:com.xmlmind.w2x.processor.DeleteFilesStep:cleanUp
      -p cleanUp.files %{~pnO}.dita

  The `-liststeps` option is also useful when developing a plugin. It may be used to learn how a stock conversion (e.g. bookmap) is implemented to get some inspiration when developing your own plugin.

Other options are:

-o format
  This option automatically adds all the steps needed to convert input DOCX file to an output file having specified format.
  Possible formats: `docbook`, `docbook5`, `assembly` (DocBook V5.1 assembly), `topic`, `map`, `bookmap`, `xhtml_css` (single-page styled HTML, that is, single-page XHTML+CSS), `xhtml_strict`, `xhtml_loose`, `xhtml1_1`, `xhtml5`, `frameset` (multi-page styled HTML), `frameset_strict` (multi-page XHTML 1.0 Strict), `frameset_loose` (multi-page XHTML 1.0 Transitional), `frameset1_1` (multi-page XHTML 1.1), `frameset5` (multi-page XHTML 5.0), `webhelp` (Web Help containing styled HTML), `webhelp_strict` (Web Help containing XHTML 1.0 Strict), `webhelp_loose` (Web Help containing XHTML 1.0 Transitional), `webhelp1_1` (Web Help containing XHTML 1.1), `webhelp5` (Web Help containing XHTML 5.0), `epub` (EPUB 2 containing styled XHTML 1.1), `epub1_1` (EPUB 2 containing semantic XHTML 1.1).
  The default output format is: `xhtml_css` (single-page styled HTML, that is, single-page XHTML+CSS).
-p name value
  Set parameter name to value.
  Use parameter `step_name.param_name` to parametrize the step called step_name.
  Because they are used to parameterize named steps, the order of `–p` and `–pu` options relatively to options specifying conversions steps (`-c`, `-e`, `-t`, `-step`, etc) is not significant. For example: “`-p convert.charset UTF-8 -c`” is equivalent to “`-c -p convert.charset UTF-8`”.
-pu name URL_or_file
  Same as `-p`, except that parameter value URL_or_file is first converted to an URL.
  URL_or_file is an absolute or relative URL (relative to current `-f` options file if any, to current working directory otherwise) or the filename of an existing file or directory.
-c
  Add or replace “convert” step. This step converts input DOCX file to an in-memory XHTML +CSS document.
-l
  Add or replace “load” step. This step, mainly used to test XED scripts, loads input XML file.
-e xed_URL_or_file
  Add or replace “edit” step. This step edits in place input XHTML document using XED script xed_URL_or_file.
-e2 xed_URL_or_file
  Add or replace “edit2” step. This step edits in place input XHTML document using XED script xed_URL_or_file.
-t xslt_URL_or_file
  Add or replace “transform” step. This step transforms input XML document or file using XSLT stylesheet xslt_URL_or_file.
  The output file is specified by parameter `transform.out-file`.
-t2 xslt_URL_or_file
  Add or replace “transform2” step. This step transforms input XML document or file using XSLT stylesheet xslt_URL_or_file.
  The output file is specified by parameter `transform2.out-file`.
-s
  Add or replace “save” step. This step saves to disk input XHTML document.
  The output file is specified by parameter `save.out-file`.
-step:java_class_name:step_name
  Add or replace step called step_name by an instance of Java™ class java_class_name deriving from `com.xmlmind.w2x.processor.ProcessStep`.
-f options_URL_or_file
  Load one or more of the above options from options_URL_or_file, a plain UTF-8 text file