Site icon techieswiki

TIBCO BW Development Tutorial: How to create XML Schema Definition (XSD) in TIBCO BusinessWorks

In this tutorial, we are going to discuss the XML Schema Definition (XSD). When we working with XML files as input/output we need to create an XSD or DTD to validate or format the input/output content.

Let’s Discuss on how to create an XML Schema Definition (XSD).

To start creating the XSD, drag and drop the Schema pallet to the root folder and double click on it.

Schema-Pallet

Before creating the XML Schema Definition, we need to understand the input/output XML format like the elements name, attributes etc. For this example, I am going to create an XSD for the below XML format.

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications 
      with XML.</description>
   </book>
   <book id="bk102">
      <author>Ralls, Kim</author>
      <title>Midnight Rain</title>
      <genre>Fantasy</genre>
      <price>5.95</price>
      <publish_date>2000-12-16</publish_date>
      <description>A former architect battles corporate zombies, 
      an evil sorceress, and her own childhood to become queen 
      of the world.</description>
   </book>
   <book id="bk103">
      <author>Corets, Eva</author>
      <title>Maeve Ascendant</title>
      <genre>Fantasy</genre>
      <price>5.95</price>
      <publish_date>2000-11-17</publish_date>
      <description>After the collapse of a nanotechnology 
      society in England, the young survivors lay the 
      foundation for a new society.</description>
   </book>
</catalog>
  1. As you can see, ‘catalog’ and ‘book’ are the elements. So when we create the XSD we need to set the content type as ‘Elements’ for these two and the rest of them, it will be ‘Typed’.
  2. Book is the subelement of ‘catalog’ and it’s a repeating one. So in the Content Model section, you need to type ‘book+’. here plus denotes the repeating element.
    Schema Elements

     

  3. For rest of them, you can specify like the below. In the Data Type section, select the appropriate data type for the elements based on your need.

    Schema Typed

  4.  All these Typed elements are the sub-element of Book. So we need to Mention that in the Content Model section. Type all the sub-elements in the Text Area. Also, we can use the Insert button to select the elements. The ‘?’ mark after ‘author’ element demotes that its an optional value. Like in the book element case, type ‘+’ if any of them are repeating. Also, we can use the wild card (*) character to set optional & repeatable for an element.

    Schema Content Model

  5. In the XML you can see an id attribute for the book element. We need to mention that as well in the XSD. If we are not sure about the attribute value for the element or if we are not going to use it anywhere select ‘#anyAttribute’. Else just type the element name there. By default, it will be an optional value.

    Schema Element Attribute

  6. Now click on Apply button to save the XML Schema Definition. if all the configurations are made accuratley we will get a Pictorial representation of the XSD as shown in the below image.
    Pictorial representation of XML Schema Definition (XSD)

     

Read ‘Tibco BW development tutorial how to configure parse XML and render XML activity step by step guide‘ to see how we can use the Schema

Hope this helps you guys to understand how to create the Schema definition. Please let me know your suggestions and feedback in the comment section below.

Exit mobile version