472,102 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

How to write XSD for an XML File

1 Bit
This is my XML File:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" ?> <rooms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="room.xsd">
  2.  <room> 
  3. <capacity>2 Adults</capacity>
  4.  <room_name>King Double</room_name> <cost_st>$1700</cost_st> 
  5. <cost_lt>$3400</cost_lt> 
  6. <loc>Ground Floor</loc>
  7.  <photo>fraise.jpg</photo> </room> </rooms>
  8.  
This is my attempt at XSD, it's not working
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  3.  
  4.  <xs:complexType name="Image">
  5.                                  <xs:simpleContent>
  6.                                             <xs:extension base="xs:anyURI">
  7.                                                  <xs:attribute name="src" type="xs:string"/>
  8.                                                  </xs:extension>
  9.                                   </xs:simpleContent>
  10.                          </xs:complexType>
  11.  
  12.         <xs:element name="rooms">
  13.         <xs:complexType>
  14. <xs:sequence>
  15.  
  16. <xs:element name="room" minOccurs="1" maxOccurs="unbounded">
  17.  <xs:element name="capacity" type="xs:string"/>
  18.                            <xs:element name="room_name" type="xs:string"/>
  19.                            <xs:element name="cost_st" type="xs:string"/>
  20.                            <xs:element name="cost_lt" type="Image"/>
  21.          <xs:element name="loc" type="xs:string"/>
  22.                            <xs:element name="photo" type="xs:Image"/>
  23.  
  24.       </xs:element>
  25.       </xs:sequence>
  26.       </xs:complexType>
  27.       </xs:element>
  28.       </xs:schema>
Jan 5 '21 #1
0 2424

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by clintonG | last post: by
1 post views Thread by Tim | last post: by
5 posts views Thread by sheriff | last post: by
4 posts views Thread by Bruno | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.