以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  请教一个问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=35577)


--  作者:duckandrat
--  发布时间:7/13/2006 10:03:00 AM

--  请教一个问题
下面是精华区的一个例子 cd.xml
<?xml version="1.0"?>
<database xmlns="http://www.newInstance.com/cd-database"
          xmlns:sh="http://www.sugarhillrecords.com"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.newInstance.com/cd-database cd-database.xsd
                              http://www.sugarhillrecords.com sugarHill.xsd"
>
  <cd title="Nickel Creek">
    <artist>Nickel Creek</artist>
    <sh:album>
      <sh:description>Bluegrass Revivalists, Acoustic Innovators,
        Youthgrass are just some of the terms that have been used
        to describe Nickel Creek over the past year -- perhaps
        producer Alison Krauss says it best:It's just Nickel Creek
        music.</sh:description>
      <sh:producer>Alison Krauss</sh:producer>
    </sh:album>
  </cd>
  <cd title="Ice Caps: Peaks of Telluride">
    <artist>Sam Bush</artist>
    <sh:album>
      <sh:description>Sam Bush's amazing mandolin and fiddle playing,
        singing and outrageous stage presence have been captivating
        audiences since the late 1960s. So what could be better-or
        more fun-than a live Sam Bush album recorded at the Telluride
        Bluegrass Festival, where he has performed for 26 years?
      </sh:description>
      <sh:producer>Sam Bush</sh:producer>
    </sh:album>
  </cd>
</database>
————————————————————————————————————
sugarHill.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.sugarhillrecords.com" targetNamespace="http://www.sugarhillrecords.com" elementFormDefault="qualified">
 <xs:element name="album">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="description" type="xs:string"/>
    <xs:element name="producer" type="xs:string"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>

______________________________________________________________
cd-database.xsd  代码如下:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sh="http://www.sugarhillrecords.com" xmlns:ns1="http://www.newInstance.com/cd-database" targetNamespace="http://www.newInstance.com/cd-database" elementFormDefault="qualified">
 <xs:import namespace="http://www.sugarhillrecords.com" schemaLocation="sugarHill.xsd"/>
 
    <xs:element name="database">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="cd" maxOccurs="unbounded"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="cd">
    <xs:complexType>
     <xs:sequence>
     <xs:element name="artist" type="xs:string"/>
     <xs:element ref="sh:albume"/>
     </xs:sequence>
     <xs:attribute name="title" type="xs:string"/>
    </xs:complexType>
 </xs:element>
</xs:schema>

当用xmlspy打开时,总出现以下错误提示:
'cd' must refer to an exsiting element
可是cd 不是已经定义了吗?
我是新手,请高手指点错误,谢谢!


--  作者:gemingke
--  发布时间:7/13/2006 6:54:00 PM

--  
呃,那就看看是不是有空格,大小写不符
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
1,476.563ms