Skip to main content

Data Formats ( XML & JSON ) XML AND JSON | Generate XSD For Breakfast Menu

 

Generate XSD For Breakfast Menu

Generate XSD for the given XML document

<?xml version="1.0" encoding="UTF-8"?>

<breakfast_menu>

<food>

<name>Turfle waffles</name>

<price>$5.95</price>

<description>This two turfle which has 2 famous product  is with real choco and maple syrup</description>

<calories>650</calories>

</food>

<food>

<name>Strawberry Belgian Waffles</name>

<price>$24.6</price>

<description>Light Belgian waffles covered with strawberries and whipped cream</description>

<calories>900</calories>

</food>

<food>

<name>Berry-Berry Belgian Waffles</name>

<price>$4.78</price>

<description>Light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>

<calories>400</calories>

</food>

<food>

<name>Fried Toast</name>

<price>$7.68</price>

<description>Thick slices made from our homemade wheat dough bread</description>

<calories>250</calories>

</food>

<food>

<name>Homestyle Breakfast</name>

<price>$7.95</price>

<description>Two eggs, bacon or sausage, toast, and England popular  hash browns</description>

<calories>1500</calories>

</food>

</breakfast_menu>

Solution:


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="breakfast_menu">
<xs:complexType>
   <xs:sequence>
<xs:element name="food" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="price" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="calories" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
   </xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Evaluation Result:


 

Result Description

Summary of tests
*Note: All the test cases might not have same weightage
+------------------------------+
|  1  test run/ 1  test passed |
+------------------------------+

Comments

Must Read:

Zero One Knapsack | Recursion

 1. You are given a number n, representing the count of items. 2. You are given n numbers, representing the values of n items. 3. You are given n numbers, representing the weights of n items. 3. You are given a number "cap", which is the capacity of a bag you've. 4. You are required to calculate and print the maximum value that can be created in the bag without       overflowing it's capacity. Note: Each item can be taken 0 or 1 number of times. You are not allowed to put the same item again and again. Input Format A number n v1 v2 .. n number of elements w1 w2 .. n number of elements A number cap Output Format A number representing the maximum value that can be created in the bag without overflowing it's capacity Constraints 1 <= n <= 20 0 <= v1, v2, .. n elements <= 50 0 < w1, w2, .. n elements <= 10 0 < cap <= 10 Sample Input 5 15 14 10 45 30 2 5 1 3 4 7 Sample Output 75 Solution: import java.io.*; import java.util.*; public class Main...

Count Encodings

 1. You are given a string str of digits. (will never start with a 0) 2. You are required to encode the str as per following rules     1 -> a     2 -> b     3 -> c     ..     25 -> y     26 -> z 3. You are required to calculate and print the count of encodings for the string str.      For 123 -> there are 3 encodings. abc, aw, lc      For 993 -> there is 1 encoding. iic       For 013 -> This is an invalid input. A string starting with 0 will not be passed.      For 103 -> there is 1 encoding. jc      For 303 -> there are 0 encodings. But such a string maybe passed. In this case       print 0. Input Format A string str Output Format count of encodings Constraints 0 < str.length <= 10 Sample Input 123 Sample Output 3 Solution: import java.io.*; import java.util.*; public class Main {   ...

Rhumbus Pattern

  /* @ToDo     Rhumbus Pattern                 *   *   *   *   *                *   *   *   *   *            *   *   *   *   *        *   *   *   *   *    *   *   *   *   *        */ #include   <iostream> using   namespace   std ; int   main (){       #ifndef  ONLINE_JUDGE        ...

Climb Stairs With Variable Jumps

 1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0th step and are required to climb to the top. 3. You are given n numbers, where ith element's value represents - till how far from the step you       could jump to in a single move.        You can of course jump fewer number of steps in the move. 4. You are required to print the number of different paths via which you can climb to the top. Input Format A number n .. n more elements Output Format A number representing the number of ways to climb the stairs from 0 to top. Constraints 0 <= n <= 20 0 <= n1, n2, .. <= 20 Sample Input 10 3 3 0 2 1 2 4 2 0 0 Sample Output 5 Solution: import java.io.*; import java.util.*; public class Main {     public static void main(String[] args) throws Exception {         // write your code here         Scanner sc = new Scanner(System.in);   ...

Data Formats ( XML & JSON ) XML AND JSON | Generate XSD 4

  Generate XSD 4 Generate an XSD for the following XML document <?xml version="1.0" encoding="UTF-8"?> <company> <employee> <id>101</id> <name>Ram</name> <salary>10000</salary> <email>ram@gmail.com</email> </employee> <employee> <id>102</id> <name>Dinesh</name> <salary>20000</salary> <email>dinesh@gmail.com</email> </employee> <employee> <id>103</id> <name>sathish</name> <salary>20000</salary> <email>sathish@gmail.com</email> </employee> <employee> <id>104</id> <name>Praveen</name> <salary>20000</salary> <email>praveen@gmail.com</email> </employee> </company> <? xml  version = "1.0"  encoding = "UTF-8" ?> < xs:schema   xmlns:xs = "http://www.w3.org/2001/XMLSchema"   elementF...

Data Formats ( XML & JSON ) XML AND JSON | Generate XSD for Students

  Generate XSD for Students   Generate XSD for the following XML. XYZ School wants to store the details of students in an xml file. The following scenario helps in designing the XML document. Here StudentList  is the root tag. StudentList contains the entry of each student with rollno, name, age, address and department. <?xml version="1.0" encoding="UTF-8"?> <StudentList  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="StudentList.xsd">     <Student rollno="2017CSE0055">         <name>             <firstname>Savitha</firstname>         </name>         <age>20</age>         <address>             <doorno>35</doorno>     ...

Cars and Bikes Problem Code: TYRES | CodeChef

Problem: Chef opened a company which manufactures cars and bikes. Each car requires   4 4  tyres while each bike requires  2 2  tyres. Chef has a total of  N N  tyres ( N N  is even). He wants to manufacture maximum number of cars from these tyres and then manufacture bikes from the remaining tyres. Chef's friend went to Chef to purchase a bike. If Chef's company has manufactured even a single bike then Chef's friend will be able to purchase it. Determine whether he will be able to purchase the bike or not. Input Format The first line contains an integer  T T  denoting the number of test cases. The  T T  test cases then follow. The first line of each test case contains an integer  N N  denoting the number of tyres. Output Format For each test case, output  YES  or  NO  depending on whether Chef's friend will be able to purchase the bike or not. Output is case insensitive. Constraints 1 ≤ T ≤ 100 1 ≤ T ≤...

Palindromic Pattern

  /* @ToDo     Palindromic Pattern                 1                2   1   2            3   2   1   2   3        4   3   2   1   2   3   4    5   4   3   2   1   2   3   4   5        */ #include   <iostream> using   namespace   std ; int   main (){       #ifndef  ONLINE_JUDGE        ...

Zig Zag Pattern

  /* @ToDo     Zig Zag Pattern         *               *                *       *       *       *        *               *               *        */ #include   <iostream> using   namespace   std ; int   main (){       #ifndef  ONLINE_JUDGE          freopen ( "../asset/input.txt" , "r" , stdin );          freopen (...

Subscribe to Get's Answer by Email