我只是想开发一个基于XSD架构的网站,然后我将XML文件导入到web-inf文件夹,我收到一个错误,从元素AuctionItems
开始找到无效内容。
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<AuctionItems> <!--this is where the error I got,its a complex type element-->
<AuctionItem>
<Title>MacBook Pro 2015</Title>
<Category>Computers</Category>
<Picture>http://www.w3schools.com/images/smiley.gif</Picture>
<Description>Cool notebook</Description>
<PostalAddress>
<streetAddress>770 Eastern Parkway</streetAddress>
<city>Sydney</city>
<state>NSW</state>
<country>Australia</country>
<postalCode>2000</postalCode>
</PostalAddress>
<ReservePrice currency="AUD">1026.00</ReservePrice>
<BiddingStartPrice currency="AUD">100.00</BiddingStartPrice>
<BiddingIncrements>10</BiddingIncrements>
<EndTime>2002-09-24-06:00</EndTime>
<ID>faced800-d358-11e4-a715-0002a5d5c51b-26</ID>
</AuctionItem>
<AuctionItem>
<Title>MacBook Pro 2008</Title>
<Category>Computers</Category>
<Picture>http://www.w3schools.com/images/smiley.gif</Picture>
<Description>Old notebook</Description>
<PostalAddress>
<streetAddress>770 Eastern Parkway</streetAddress>
<city>Sydney</city>
<state>NSW</state>
<country>Australia</country>
<postalCode>2000</postalCode>
</PostalAddress>
<ReservePrice currency="AUD">613.00</ReservePrice>
<BiddingStartPrice currency="AUD">100.00</BiddingStartPrice>
<BiddingIncrements>10</BiddingIncrements>
<EndTime>2002-09-24-06:00</EndTime>
<ID>f3fefea6-d443-11e4-b9d6-1681e6b88ec1-26</ID>
</AuctionItem>
</AuctionItems>
</web-app>
XSD文件如下:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AuctionItems">
<xs:complexType>
<xs:sequence>
<xs:element name="AuctionItem" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Title">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Category" type="xs:string"/>
<xs:element name="Picture" type="xs:anyURI"/>
<xs:element name="Description">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="1000"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="PostalAddress">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="streetAddress"/>
<xs:element type="xs:string" name="city"/>
<xs:element type="xs:string" name="state"/>
<xs:element type="xs:string" name="country"/>
<xs:element type="xs:short" name="postalCode"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ReservePrice">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="currency" type="currencyType"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="BiddingStartPrice">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="currency" type="currencyType"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="BiddingIncrements" type="xs:decimal"/>
<xs:element name="EndTime" type="xs:date"/>
<xs:element name="ID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="currencyType">
<xs:restriction base="xs:string">
<xs:enumeration value="GBP"/>
<xs:enumeration value="EUR"/>
<xs:enumeration value="USD"/>
<xs:enumeration value="AUD"/>
</xs:restriction>
</xs:simpleType>