+ -
当前位置:首页 → 问答吧 → 如和用IE实践Schema?

如和用IE实践Schema?

时间:2003-12-22

来源:互联网

为什么在IE下,我的Schema文件显示不出作用?
比如我将xml文件的<price>元素改成非数字字符时, 按理应得到错误信息("<xs:element name="price" type="xs:decimal"/>"),但是没有得到错误信息,难道是IE6不支持Schema?

文件1:
Shiporder.Xsd
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="shiporder">
<xs:complexType>
  <xs:sequence>
   <xs:element name="orderperson" type="xs:string"/>
   <xs:element name="shipto">
    <xs:complexType>
     <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="address" type="xs:string"/>
      <xs:element name="city" type="xs:string"/>
      <xs:element name="country" type="xs:string"/>
     </xs:sequence>
    </xs:complexType>
   </xs:element>
   <xs:element name="item" maxOccurs="unbounded">
    <xs:complexType>
     <xs:sequence>
      <xs:element name="title" type="xs:string"/>
      <xs:element name="note" type="xs:string" minOccurs="0"/>
      <xs:element name="quantity" type="xs:positiveInteger"/>
      <xs:element name="price" type="xs:decimal"/>
     </xs:sequence>
    </xs:complexType>
   </xs:element>
  </xs:sequence>
  <xs:attribute name="orderid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element></xs:schema>



文件2:
Shiporder.XML

<?xml version="1.0" encoding="ISO-8859-1"?><shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
<orderperson>John Smith</orderperson>
<shipto>
  <name>Ola Nordmann</name>
  <address>Langgt 23</address>
  <city>4000 Stavanger</city>
  <country>Norway</country>
</shipto>
<item>
  <title>Empire Burlesque</title>
  <note>Special Edition</note>
  <quantity>1</quantity>
  <price>10.90</price>
</item>
<item>
  <title>Hide your heart</title>
  <quantity>1</quantity>
  <price>9.90</price>
</item>
</shiporder>

作者: Amolin   发布时间: 2003-12-22

ding

作者: Amolin   发布时间: 2003-12-31

XML 文件顶部更改为如下试试?

<?xml version="1.0" encoding="ISO-8859-1"?>
<shiporder orderid="889923"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="x-schema:shiporder.xsd">

作者: bencalie   发布时间: 2003-12-31

请问那里有介绍Schema的文章???最好中文!

作者: phddcg   发布时间: 2003-12-31

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Error opening input file: 'shiporder.xsd'. Incorrect definition for the root element in schema. Error processing resource 'file://Ch01wbs01/ojt_new/XMLWEB/shiporder.xsd'. Line 2, Position 56

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

谢谢bencalie,如果您修改一下,能让这个例子运行就太好了,我太想感受一下SCHEMA的力量了..

作者: Amolin   发布时间: 2004-01-02