[ English | Japanese ]
DtoXml [ options ] [ input-file.. ]
DtoXml converts D-records in the input-files into an XML portion. Usually, output XML file is fed to other XML program to form a total application system.
A D-field is converted to an XML element having only character data. The field name becomes the element name, and the field value becomes the character data. A D-record is converted to an XML element containing only elements converted from the D-fields of the record. The element name is <record> by default, which you can change by the -r option.
An input file is enclosed as <file> element. Whole input files are enclosed as <root> element. These element names can be changed by the -f and -o option.
A D-field of which name start with COMMERCIAL AT (@) is converted to an attribute. The attribute is placed in the element of the preceding D-field, or in the record element when no preceding D-field exists.
When a D-field value is converted to the character data of an element, characters not allowed in XML character data (e.g. <) are converted to the predefined entities (e.g. <). But, when the D-field value is already coded as XML character data, you can escape this conversion by listing the field names in the -n option.
Output file has no indention. Start-tag, character data and end-tag are concatenated and form one line. Start-tag or end-tag for the root, file and record forms one line by itself. After the end-tag for the record and file, one null line is inserted.
This is an example to show basic function of DtoXml. Input D-file is as follows:
@attr1:1
a:text-a
@attr2:2
b:text-b
DtoXml without any option produces next output.
<root>
<file>
<record attr1="1">
<a attr2="2">text-a</a>
<b>text-b</b>
</record>
</file>
</root>
Next example is to show -n option. Input file is:
a:text-a <c>text-ac</c>
b:text-b <c>text-bc</c>
DtoXml -n a will produce:
<root>
<file>
<record>
<a>text-a <c>text-ac</c></a>
<b>text-b <c>text-bc</c></b>
</record>
</file>
</root>
See the manual of D_msg.
Dintro, DfromXml, DtoTex, DtoCsv, D_msg.
MIYAZAWA Akira