HomeGuidesRecipesAPI
HomeGuidesAPILog In

Template - XSD

Infiniti generates XML from XSD

Infiniti can generate XML file directly from an XSD template. This feature reduces the workload of generating XML files for the users.

📘

Note:

An.xsd file must exist, and has correct format and namespace in order to generate the XML file.

Try it

For testing, we will use this XSD.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"      elementFormDefault="qualified">
 <xsd:element name="Order">
   <xsd:complexType>
  	<xsd:sequence>
      <xsd:element name="name" type="xsd:string" maxOccurs="unbounded" />
      <xsd:element name="street" type="xsd:string" maxOccurs="1" />
      <xsd:element name="city" type="xsd:string" maxOccurs="1" />
      <xsd:element name="zip" type="xsd:string" maxOccurs="1"/>
		</xsd:sequence>
	</xsd:complexType>
	</xsd:element>
</xsd:schema>

📘

Max and Min Occurs

maxOccurs and minOccurs specify the maximum and minimum attributes occurrences per element.

🚧

maxOccurs

maxOccurs is mandatory attribute.

  1. Create new Infiniti project of type form, and call it XSD to XML

  2. From templates menu, drag XSD template under finish page. Doing so, browse dialog will open to select your XSD file.

345
  1. In the right vertical menu, click Placeholders. If your XSD is well formatted, infiniti will be able to understand and parse it, and then extract the elements and attributes from it to be mapped to questions.
390
  1. Create section, in its properties check Repeating. This will convert it to repeated section.
    In Repeat Content properties change (None) to Placeholder. Click the three dots button to open Select Placeholders dialog.
    If your XSD is well formatted, you will get a list of placeholders similar to this:
543

Select the Placeholder and click Add and OK.
Now, for each element/attribute in your XSD add question in the repeated section.

  1. Drag each place holder to its respective question/answer. Dragged placeholders will change their colors to grey to distinguish between the used and unused ones.
322
  1. Save and publish your project, and navigate to produce to test it.

  2. Create multiple sections and fill them, then click submit. Download the XML file to find out the data you have filled in the generated XML file.

This is an example of generated XML.

<?xml version="1.0" encoding="UTF-8"?>
-<Order>
	<name>Dave Hudson</name>
	<street>Parkes Way</street>
	<city>Canberra</city>
	<zip>2600</zip>
</Order>