A PrintShop Mail designer normally does not have to design XML databases on their own, it is provided by a third-party or is generated by a software. This page is meant as information to be forwarded to whomever is controlling how the XML is generated so that it is compatible with PrintShop Mail.
PrintShop Mail can map the elements in an XML file to records and fields and use it as a data source, as long as the XML conforms to certain rules.
Any XML encoding is supported. If the encoding is not specified, it is assumed to be UTF8.
There must be one root element. The root element can have one or more record elements, which form a recordset. Each record element can have one or more field elements.
Example 1: Basic flat hierarchy
<root> <record> <field2>Record 2, Field 2</field2> <field1>Record 2, Field 1</field1> </record> <record> <field2>Record 1, Field 2</field2> <field1>Record 1, Field 1</field1> </record> </root>
If a field element has child elements, the field element is considered to be an embedded recordset. The value of an embedded recordset is a combination of the values of its records, separated by newlines. You will see this value when you use the field in your layout. For performance reasons, the Select Table dialog and Data Fields pane do not display an actual preview of an embedded recordset - they only display the text "(Multiple records)".
Example 2: Dynamic product list
<orders> <order> <name>Mr. A.</name> <product type="Cranberry Sauce" price="$40.00"/> </order> <order> <name>Mrs. B.</name> <product type="Dried Pears" price="$30.00"/> <product type="Cajun Seasoning" price="$22.00"/> <product type="Aniseed Syrup" price="$10.00"/> </order> </orders>
Attributes are interpreted as child elements. For example: <elem attrib="1"/> is identical to <elem><attrib>1</attrib></elem>.
Exceptions:
- PrintShop Mail will not include an attribute as a data field if its name starts with "xmlns"
- PrintShop Mail will not include an attribute as a data field if its name is "xsi:noNamespaceSchemaLocation", "xsi:schemaLocation", "xsi:type", "xsi:nil", "xml:base", or "dt:dt"
A special case is <elem attrib="1">InnerText</elem>. PrintShop Mail will expose "attrib" as a data field since it's a named child element, but the InnerText value will be hidden. If you want to use the InnerText value you have two options:
PrintShop Mail 7.1 introduced support for multiple tables. Also, PrintShop Mail 7.1 no longer requires the record elements to be at the second level in the hierarchy. A 'table' in an XML data file is a collection of record elements, with the same name, at the same hierarchy level. If more than one table is found, the user will be asked to select one in the Select Table dialog.
Exceptions:
Example 3: Data at deeper level
</inventory> <level2> <level3> <level4> <car color="red" year="1999"/> <car color="lime" year="2000"/> <car color="black" year="2010"/> </level4> </level3> </level2> <inventory>
Example 4: Two tables, '/car' and '/bike'
<inventory> <car color="red" year="1999"/> <car color="lime" year="2000"/> <car color="black" year="2010"/> <bike type="unicycle"/> <bike type="two-seater"/> </inventory>
PrintShop Mail will display an error message with context information if the XML has an incorrect syntax.
It should be possible to have PrintShop Mail validate the XML against a DTD or XSD schema, but we noticed that the MSXML 4.0 parser can have some trouble processing certain DTD schemas. If you run into any strange behavior, try removing the schema reference.
Anything between CDATA brackets is considered to be literal character data instead of markup. Angle brackets ('<', '>') and ampersands ('&') within a CDATA section do not need to be escaped.
CDATA Example:
<elem><![CDATA[Hello world]]></elem>
PrintShop Mail has limited support for typed XML. Types need to be specified in an external XDR schema (the inline dt:dt attribute is not supported). Note that the "fixed.14.4" type is assumed to represent currency.
Example 5: XDR schema
[File: weather.xml]
<?xml version="1.0"?> <weather xmlns="x-schema:weather.xdr"> <date>1970-09-30</date> <degrees>67.5</degrees> </weather>
[File: weather.xdr]
<Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes"> <ElementType name="date" content="textOnly" dt:type="date"/> <ElementType name="degrees" content="textOnly" dt:type="float"/> <ElementType name="weather" content="eltOnly"> <element type="date"/> <element type="degrees"/> </ElementType> </Schema>