2013-07-23 5 views
1

У меня есть XML-документ с даннымиXML-схемы с типом данных

<?xml version="1.0" encoding="ISO-8859-1"?> 

    <!-- Edited by XMLSpy® --> 

    <bookstore> 

     <book category="COOKING"> 

      <title lang="en">Everyday Italian</title> 

      <author>Giada De Laurentiis</author> 

      <year>2005</year> 

      <price>30.00</price> 

     </book> 

     <book category="CHILDREN"> 

      <title lang="en">Harry Potter</title> 

      <author>J K. Rowling</author> 

      <year>2005</year> 

      <price>29.99</price> 

     </book> 

     <book category="WEB"> 

      <title lang="en">XQuery Kick Start</title> 

      <author>James McGovern</author> 

      <author>Per Bothner</author> 

      <author>Kurt Cagle</author> 

      <author>James Linn</author> 

      <author>Vaidyanathan Nagarajan</author> 

      <year>2005</year> 

      <price>49.99</price> 

     </book> 

     <book category="WEB"> 

      <title lang="en">Learning XML</title> 

      <author>Erik T. Ray</author> 

      <year>2005</year> 

      <price>39.95</price> 

     </book> 

</bookstore> 

Я хочу, чтобы установить тип <price> данных в виде целого числа. Пожалуйста, помогите мне, чтобы получить решение.

+0

почему цена как целое? не следует плавать? –

+0

@DavorMlinaric: Да Это может быть и поплавок. Просто нужно знать, как установить тип данных –

ответ

0

Вы можете использовать онлайн-инструмент для создания схемы.

http://www.freeformatter.com/xsd-generator.html#ad-output

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="bookstore"> 
    <xs:annotation> 
     <xs:documentation>Edited by XMLSpy®</xs:documentation> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="book" maxOccurs="unbounded" minOccurs="0"> 
      <xs:complexType> 
      <xs:sequence> 
       <xs:element name="title"> 
       <xs:complexType> 
        <xs:simpleContent> 
        <xs:extension base="xs:string"> 
         <xs:attribute type="xs:string" name="lang" use="optional"/> 
        </xs:extension> 
        </xs:simpleContent> 
       </xs:complexType> 
       </xs:element> 
       <xs:element type="xs:string" name="author" maxOccurs="unbounded" minOccurs="0"/> 
       <xs:element type="xs:short" name="year"/> 
       <xs:element type="xs:float" name="price"/> 
      </xs:sequence> 
      <xs:attribute type="xs:string" name="category" use="optional"/> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema>