Schema validation scope
The XSD checks XML elements, attributes, and nesting. When converting to Wiki JSON, @eihrteam/xml also checks rules that depend on the chapter mode, element placement, or field contents. After editing an entry, validate its structure against the XSD and run the converter to check whether it can produce Wiki JSON.
Additional rules the converter checks
The root element's children can appear in any order, and <chapters> can appear more than once. The XSD declares the structure of each child, and the converter checks that <itemId>, <metainfo>, and <description> are present. The converter also checks the following rules.
- A chapter with
table="true"must contain a direct<table>child. A chapter withaudio="true"uses a direct<audios>child or audio tabs, each of which must contain exactly one<audios>element. A chapter withdialog="true"must contain at least one dialog entry and cannot enable another mode. - The first message in a dialog branch must have
side="me"and the last must haveside="other". The first message cannot contain an<image>element. - For complex tables, the converter checks header positions, cell coordinates, row and column spans, grid coverage, and column widths. If
widthsis omitted, the converter calculates default column widths from the supported chapter size and the number of logical columns. - If an image's
<id>or<format>is omitted, the converter tries to infer the missing fields from the file name in<url>. - The
<publicMeta>element can be empty. If it has content, that content must be a JSON object.
Structures the converter accepts
In some positions, the converter ignores unrecognized empty elements, such as <unused/> in the body. If <name> appears more than once in <metainfo>, the converter reads the first one. The XSD reports both structures as errors. When editing an entry, remove unknown elements and keep one element for each field that takes a single value.
Examples
Save each example separately as item.xml and validate it with the command on the XSD Schema page. Then run v1.0.0 of the converter to compare the results.
npx --yes --package=@eihrteam/xml@1.0.0 xml convert --from xml --to json --input item.xmlMissing a required entry ID
This entry has metadata and a description, but omits <itemId>.
<sklandDocument>
<metainfo>
<name>Sample entry</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
</sklandDocument>The entry passes XSD validation. The converter reports that <itemId> is missing. Add the actual entry ID as a child of the root element and run the conversion command again.
Unknown empty element in the description
The <description> element in this entry contains an empty element that the converter ignores.
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>Sample entry</name>
<cover/>
<subTypes/>
</metainfo>
<description>Sample text<unused/></description>
</sklandDocument>The XSD reports <unused> as a disallowed child element. The converter ignores the element and keeps the description text. Remove <unused/> to pass both checks.