xml2dcm(1)
π xml2dcm(1) β OFFIS DCMTK π
πΈ NAME πΈ
xml2dcm β convert XML document to DICOM file or data set. That's the whole vibe, bestie: XML goes in, DICOM comes out, and you look iconic doing it. π
β¨ SYNOPSIS β¨
xml2dcm [options] xmlfile-in dcmfile-out
π¦ DESCRIPTION π¦
Okay so the xml2dcm utility converts the contents of an XML (Extensible Markup Language) document to DICOM file or data set. It's giving converter energy, no cap.
The XML document is expected to validate against the DTD (Document Type Definition) which is described in file dcm2xml.dtd. An appropriate XML file can be created using the dcm2xml tool (option +Wb recommended to include binary data). iykyk β that +Wb is the little binary-data bestie.
π PARAMETERS π
xmlfile-inβ XML input filename to be converted ("-"for stdin). Yes, a literal dash means stdin, bestie.dcmfile-outβ DICOM output filename ("-"for stdout). And another dash means stdout. The dash is lowkey doing main character work.
π OPTIONS π
π general options π
-h,--helpβ print this help text and exit. Helpful icon behavior.--versionβ print version information and exit. Version check, slay.--argumentsβ print expanded command line arguments. So you can see exactly what the shell fed it.-q,--quietβ quiet mode, print no warnings and errors. Shhh era.-v,--verboseβ verbose mode, print processing details. Talkative era.-d,--debugβ debug mode, print debug information. Maximum yapping, but make it diagnostics.-ll,--log-level[l]evel: string constant β(fatal, error, warn, info, debug, trace); use levellfor the logger. Pick your log-level lore.-lc,--log-config[f]ilename: string β use config fileffor the logger. Logger config file moment.
π§ input options π§
π input file format
+f,--read-meta-infoβ read meta information if present (default). Default behavior, bestie.-f,--ignore-meta-infoβ ignore file meta information. Pretend you didn't see it.
π processing options π
π validation
+Vd,--validate-documentβ validate XML document against DTD. DTD vibe check.+Vn,--check-namespaceβ check XML namespace in document root. Namespace inspection, no cap.
π unique identifiers
+Ug,--generate-new-uidsβ generate new Study/Series/SOP Instance UID. Fresh UIDs, fresh era.-Uo,--dont-overwrite-uidsβ do not overwrite existing UIDs (default). Default: leave those UIDs alone.+Uo,--overwrite-uidsβ overwrite existing UIDs. Overwrite mode, handle with care energy.
π₯ output options π₯
πΈ output file format
+F,--write-fileβ write file format (default). Default file format behavior.-F,--write-datasetβ write data set without file meta information. Data set only, no file meta information.+Fu,--update-meta-infoβ update particular file meta information. Meta info gets a little refresh.
π¦ output transfer syntax
+t=,--write-xfer-sameβ write with same TS as input (default). Default: same transfer syntax as the input.+te,--write-xfer-littleβ write with explicit VR little endian TS. Explicit VR little endian TS.+tb,--write-xfer-bigβ write with explicit VR big endian TS. Explicit VR big endian TS.+ti,--write-xfer-implicitβ write with implicit VR little endian TS. Implicit VR little endian TS.+td,--write-xfer-deflatedβ write with deflated explicit VR little endian TS. Deflated explicit VR little endian TS.
π error handling
-E,--stop-on-errorβ do not write if document is invalid (default). Default: invalid document means no write.+E,--ignore-errorsβ attempt to write even if document is invalid. Attempt to write anyway.
β post-1993 value representations
+u,--enable-new-vrβ enable support for new VRs (UN/UT) (default). Default: new VRs are enabled.-u,--disable-new-vrβ disable support for new VRs, convert to OB. New VRs off, convert to OB.
π group length encoding
+g=,--group-length-recalcβ recalculate group lengths if present (default). Default: recalculate if present.+g,--group-length-createβ always write with group length elements. Always include group length elements.-g,--group-length-removeβ always write without group length elements. Always leave group length elements out.
π length encoding in sequences and items π
+e,--length-explicitβ write with explicit lengths (default). Default: explicit lengths.-e,--length-undefinedβ write with undefined lengths. Undefined lengths mode.
π data set trailing padding (not with --write-dataset)
-p=,--padding-retainβ do not change padding (default if not--write-dataset). Default when you're not using--write-dataset: leave padding alone.-p,--padding-offβ no padding (implicit if--write-dataset). No padding; implicit if--write-dataset.+p,--padding-create[f]ile-pad [i]tem-pad: integer β align file on multiple offbytes and items on multiple ofibytes. Alignment math, bestie: file on multiples offbytes, items on multiples ofibytes.
π deflate compression level (only with --write-xfer-deflated)
+cl,--compression-level[l]evel: integer (default: 6) β0=uncompressed,1=fastest,9=best compression. Compression dial:0uncompressed,1fastest,9best compression. Default is6.
β¨ NOTES β¨
okay so the basic structure of the XML input it expects looks like this π
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE file-format SYSTEM "dcm2xml.dtd">
<file-format xmlns="http://dicom.offis.de/dcmtk">
<meta-header xfer="1.2.840.10008.1.2.1" name="Little Endian Explicit">
<element tag="0002,0000" vr="UL" vm="1" len="4"
name="MetaElementGroupLength">
166
</element>
...
<element tag="0002,0013" vr="SH" vm="1" len="16"
name="ImplementationVersionName">
OFFIS_DCMTK_353
</element>
</meta-header>
<data-set xfer="1.2.840.10008.1.2" name="Little Endian Implicit">
<element tag="0008,0005" vr="CS" vm="1" len="10"
name="SpecificCharacterSet">
ISO_IR 100
</element>
...
<sequence tag="0028,3010" vr="SQ" card="2" name="VOILUTSequence">
<item card="3">
<element tag="0028,3002" vr="xs" vm="3" len="6"
name="LUTDescriptor">
256\0\8
</element>
...
</item>
...
</sequence>
...
<element tag="7fe0,0010" vr="OW" vm="1" len="262144"
name="PixelData" loaded="no" binary="hidden">
</element>
</data-set>
</file-format>
and bestie, listen β the "file-format" and "meta-header" tags may be absent for DICOM data sets. they're optional, not mandatory, mwah π
πΈ Character Encoding πΈ
so the DICOM character encoding? it gets determined automatically from the element with tag "0008,0005" (Specific Character Set) β if it's present. like, the file just tells you what it is. iconic behavior tbh β¨
here's the full lineup of character sets currently supported (and heads up, this requires libxml to include iconv support β go peek at the --version output to check π):
ASCIIβ (ISO_IR 6) β (UTF-8)UTF-8β"ISO_IR 192"β (UTF-8)ISO Latin 1β"ISO_IR 100"β (ISO-8859-1)ISO Latin 2β"ISO_IR 101"β (ISO-8859-2)ISO Latin 3β"ISO_IR 109"β (ISO-8859-3)ISO Latin 4β"ISO_IR 110"β (ISO-8859-4)ISO Latin 5β"ISO_IR 148"β (ISO-8859-9)ISO Latin 9β"ISO_IR 203"β (ISO-8859-15)Cyrillicβ"ISO_IR 144"β (ISO-8859-5)Arabicβ"ISO_IR 127"β (ISO-8859-6)Greekβ"ISO_IR 126"β (ISO-8859-7)Hebrewβ"ISO_IR 138"β (ISO-8859-8)
lowkey important: multiple character sets are not supported. only the first value of the "Specific Character Set" gets used for the character encoding when there's value multiplicity. one charset and one charset only, bestie π
and yeah β see the dcm2xml documentation for more details on the XML structure. go read your sibling's manual, it's giving family bonding π«Ά
π¦ Binary Data π¦
binary data (*) can be encoded one of two ways, pick your fighter:
- as a sequence of hex numbers separated by a backslash
"\" - in Base64 format (
binary="base64")
and there's a third option that's lowkey the best one: binary data can also be read from a file (binary="file"). in that case the filename has to be specified as the element value, like this:
<element tag="7fe0,0010" vr="OW" ...
binary="file">subdir/pixeldata.raw</element>
β οΈ please note that the contents of the file will be read as is. OW data is expected to be little endian ordered and will be swapped if necessary. no checks will be made to ensure that the amount of data is reasonable in terms of other attributes such as Rows or Columns. and Base64 encoded data is expected to use big endian byte ordering. the tool is trusting you completely, no vibe check, no cap π
() also a real one: currently only OB and OW data is supported β meaning element values with a VR of OD, OF, OL and OV are *not regarded as "binary data" and get treated as all other VRs. them's the rules π
π Compression π
if libxml is compiled with zlib support, the input file (xmlfile-in) can also be compressed with ZIP, which usually results in much smaller files (tiny file slay π). check the output of option --version to see whether zlib support is available.
π Limitations π
different versions of libxml might have different limits for the maximum length of an XML element value. so yeah β it should be avoided to use very long element values (e.g. for pixel data). don't push your luck bestie π
also: xml2dcm currently does not fully support DICOMDIR files. specifically, the value of the various offset data elements is not updated automatically by this tool. you're on your own for those, fr fr.
π₯ LOGGING π₯
the level of logging output of the various command line tools and underlying libraries can be specified by the user. by default, only errors and warnings are written to the standard error stream. basic.
- option
--verbosealso gives you informational messages like processing details β she's chatty β¨ - option
--debuggets you more details on the internal activity, e.g. for debugging purposes β she's very chatty π - other logging levels can be selected using option
--log-level - in
--quietmode only fatal errors are reported. in such very severe error events, the application will usually terminate π
for more details on the different logging levels, see documentation of module "oflog".
in case the logging output should be written to file (optionally with logfile rotation), to syslog (Unix) or the event log (Windows), the option --log-configcan be used β yes, the raw manpage text literally mashes it into --log-configcan be used, we love a roff artifact π. this configuration file also allows for directing only certain messages to a particular output stream and for filtering certain messages based on the module or application where they are generated. an example configuration file is provided in *<etcdir>/logger.cfg.
π COMMAND LINE π
all command line tools use the following notation for parameters: square brackets enclose optional values (0-1), three trailing dots indicate that multiple values are allowed (1-n), and a combination of both means 0 to n values. iykyk π
command line options are distinguished from parameters by a leading '+' or '-' sign, respectively. usually, order and position of command line options are arbitrary (i.e. they can appear anywhere). however, if options are mutually exclusive, the rightmost appearance is used. this behavior conforms to the standard evaluation rules of common Unix shells β she's consistent, periodt π
in addition, one or more command files can be specified using an '@' sign as a prefix to the filename (e.g. @command.txt). such a command argument is replaced by the content of the corresponding text file (multiple whitespaces are treated as a single separator unless they appear between two quotation marks) prior to any further evaluation.
β οΈ please note that a command file cannot contain another command file. no inception, we don't do that here π ββοΈ
this simple but effective approach allows one to summarize common combinations of options/parameters and avoids longish and confusing command lines (an example is provided in file <datadir>/dumppat.txt). short commands = happy life π¦
π ENVIRONMENT π
the xml2dcm utility will attempt to load DICOM data dictionaries specified in the DCMDICTPATH environment variable. by default, i.e. if the DCMDICTPATH environment variable is not set, the file <datadir>/dicom.dic will be loaded β unless the dictionary is built into the application (default for Windows).
the default behavior should be preferred, and the DCMDICTPATH environment variable only used when alternative data dictionaries are required. like, don't come for the defaults unless you have a reason bestie π«Ά
the DCMDICTPATH environment variable has the same format as the Unix shell PATH variable in that a colon (":") separates entries. on Windows systems, a semicolon (";") is used as a separator. the data dictionary code will attempt to load each file specified in the DCMDICTPATH environment variable.
π¨ it is an error if no data dictionary can be loaded. that's a hard fail, no cap.
π FILES π
<datadir>/dcm2xml.dtdβ Document Type Definition (DTD) file
β SEE ALSO β
π COPYRIGHT π
Copyright (C) 2003-2026 by OFFIS e.V., Escherweg 2, 26121 Oldenburg, Germany.
and that's the whole page, bestie, you ate that π β¨ this cutie was brought to you by Version 3.7.1, dated Sat Oct 17 2026 09:34:01 β go forth and convert your XML into DICOM, you absolute icon ππ
π¦ where this page comes from
- arch rolling: dcmtk 3.7.1-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms