以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  在book.xsd里有个问题,请哪位大哥给点建议!!!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=38643)


--  作者:adiros
--  发布时间:10/8/2006 8:00:00 PM

--  在book.xsd里有个问题,请哪位大哥给点建议!!!
在book.xsd里有个问题,请哪位大哥给点建议!!!
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="transaction" type="transactionType"/>
<xsd:complexType name="transactionType">  
  <xsd:sequence>    
      <xsd:element name="lender" type="addresType"/>
      <xsd:element name="borrower" type="addresType"/>
      <xsd:element ref="note" minOccurs="0"/>
      <xsd:element name="books" type="bookType"/>
  </xsd:sequence>    
      <xsd:attribute name="borrowDate" type="xsd:date"/>
</xsd:complexType>
<xsd:element name="note" type="xsd:string"/>
<xsd:complexType name="addressType">
  <xsd:sequence>
       <xsd:element name="name" type="xsd:string"/>
       <xsd:element name="street" type="xsd:string"/>
       <xsd:element name="city" type="xsd:string"/>
       <xsd:element name="state" type="xsd:string"/>
  </xsd:sequence>     
       <xsd:attribute name="borrowDate" type="xsd:date"/>       
</xsd:complexType>

<xsd:complexType name="bookType">
<xsd:element name="book" minOccurs="0" maxOccurs="10">
   <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="bookTitle" type="xsd:string"/>
      <xsd:element name="pubDate" type="xsd:date" minccurs='0'/>
      <xsd:element name="replacementValue" type="xsd:string"/>
      <xsd:element name="maxDaysOut">
         <xsd:simpleType base="xsd:integer">
            <xsd:restriction base="xsd:integer">
                 <xsd:maxExclusive value="14"/>
            </xsd:restriction>
         </xsd:simpleType>
      </xsd:element>     
     </xsd:sequence>
     <xsd:attribute name="bookID" type="catalogID"/>
   </xsd:complexType>  
</xsd:element>
</xsd:complexType>

<xsd:simpleType name="catalogID">
    <xsd:restriction base="xsd:string">
        <xsd:pattern value="\d{3}-\d{4}-\d{3}"/>
    </xsd:restriction>
</xsd:simpleType>     
</xsd:schema>
在transtaction.xml 这个调用没问题 !
<?xml version="1.0"?>
<transaction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="book.xsd"  borrowDate="2001-10-15">
   <lender phone="9903 44563">
         <name>Michael Calder</name>
         <street>41 mcmahons rd</street>
         <city>frankston</city>
         <state>vic</state>
   </lender>
   <borrower phone="9903 3455">
         <name>carig gavin</name>
         <street>56 overprt rd</street>
         <city>karingal</city>
         <state>vic</state>
   </borrower>       
   <note>lender wants these back in two weeks</note>
   <books>
      <book bookID="123-4567-890">
           <bookTitle>Earthquarkes for breakfast</bookTitle>
           <pubDate>2001-10-20</pubDate>
           <replacementValue>15.95</replacementValue>
           <maxDaysOut>14</maxDaysOut>
      </book>
      <book bookID="123-4567-890">
           <bookTitle>Avalanches for lunch</bookTitle>
           <pubDate>2001-10-21</pubDate>
           <replacementValue>19.99</replacementValue>
           <maxDaysOut>14</maxDaysOut>
      </book>
      <book bookID="123-4567-890">
           <bookTitle>Meteor showers for dinner</bookTitle>
           <pubDate>2001-10-22</pubDate>
           <replacementValue>11.95</replacementValue>
           <maxDaysOut>14</maxDaysOut>
      </book>
      <book bookID="123-4567-890">
           <bookTitle>Snacking on Volcanoes</bookTitle>
           <pubDate>2001-10-23</pubDate>
           <replacementValue>17.99</replacementValue>
           <maxDaysOut>14</maxDaysOut>
      </book>
      
   </books>   
</transaction>


--  作者:adiros
--  发布时间:10/8/2006 9:18:00 PM

--  
怎么今天也没人爱?!
--  作者:gemingke
--  发布时间:10/9/2006 11:27:00 AM

--  
你的问题在哪?指出来总可以吧,全是代码
--  作者:adiros
--  发布时间:10/9/2006 7:27:00 PM

--  
<xsd:complexType name="bookType">
<xsd:element name="book" minOccurs="0" maxOccurs="10">
   <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="bookTitle" type="xsd:string"/>
      <xsd:element name="pubDate" type="xsd:date" minccurs='0'/>
      <xsd:element name="replacementValue" type="xsd:string"/>
      <xsd:element name="maxDaysOut">
         <xsd:simpleType base="xsd:integer">
            <xsd:restriction base="xsd:integer">
                 <xsd:maxExclusive value="14"/>
            </xsd:restriction>
         </xsd:simpleType>
      </xsd:element>     
     </xsd:sequence>
     <xsd:attribute name="bookID" type="catalogID"/>
   </xsd:complexType>  
</xsd:element>
</xsd:complexType>

在spywriter里提示:complexType 嵌套complexType


--  作者:gemingke
--  发布时间:10/10/2006 12:51:00 PM

--  
既然不能两次嵌套,对于element“book”可以用引用的方式嘛
--  作者:adiros
--  发布时间:10/11/2006 8:30:00 PM

--  
能具体点吗?大哥!/!!
--  作者:adiros
--  发布时间:10/11/2006 8:31:00 PM

--  
我才刚学习这个!
有的问题真的不晓得啊!
--  作者:gemingke
--  发布时间:10/12/2006 11:20:00 AM

--  
<xsd:complexType name="bookType">
<xsd:element name="book" type="bookType" minOccurs="0" maxOccurs="10"/>
    
</xsd:complexType>

<xsd:complexType name="bookType">
     <xsd:sequence>
      <xsd:element name="bookTitle" type="xsd:string"/>
      <xsd:element name="pubDate" type="xsd:date" minccurs='0'/>
      <xsd:element name="replacementValue" type="xsd:string"/>
      <xsd:element name="maxDaysOut">
         <xsd:simpleType base="xsd:integer">
            <xsd:restriction base="xsd:integer">
                 <xsd:maxExclusive value="14"/>
            </xsd:restriction>
         </xsd:simpleType>
      </xsd:element>     
     </xsd:sequence>
     <xsd:attribute name="bookID" type="catalogID"/>
   </xsd:complexType>  


--  作者:adiros
--  发布时间:10/12/2006 12:17:00 PM

--  
大哥,还是与问题啊!
--  作者:adiros
--  发布时间:10/12/2006 12:20:00 PM

--  
在xmlspy2005版里还是有问题!
--  作者:adiros
--  发布时间:10/12/2006 12:28:00 PM

--  
大哥有QQ?
我的:260959420
加我大哥!!!
--  作者:adiros
--  发布时间:10/12/2006 12:29:00 PM

--  
加我QQ:260959420!大哥!
--  作者:adiros
--  发布时间:10/13/2006 7:56:00 PM

--  
<xsd:complexType name="bookType">
  <xsd:sequence>
   <xsd:element name="book" minOccurs="0" maxOccurs="10">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="bookTitle" type="xsd:string"/>
      <xsd:element name="pubDate" type="xsd:date" minOccurs="0"/>
      <xsd:element name="replacementValue" type="xsd:decimal"/>
      <xsd:element name="maxDaysOut">
       <xsd:simpleType>
        <xsd:restriction base="xsd:integer">
         <xsd:maxExclusive value="14"/>
        </xsd:restriction>
       </xsd:simpleType>
      </xsd:element>
     </xsd:sequence>
     <xsd:attribute name="bookID" type="catalogID"/>
    </xsd:complexType>
   </xsd:element>
  </xsd:sequence>
 </xsd:complexType>
这下的代码就对了!!

W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
147.461ms