467,092 Members | 1,242 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,092 developers. It's quick & easy.

How to write XSD for an XML File

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>
1 Week Ago #1
  • viewed: 1492
Share:

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
By using this site, you agree to our Privacy Policy and Terms of Use.