以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  [求助]各位大哥,我想问问关于group和attributegroup在schemal中的用法  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=15731)


--  作者:冰峰
--  发布时间:3/17/2005 10:30:00 AM

--  [求助]各位大哥,我想问问关于group和attributegroup在schemal中的用法
各位大哥:
    我想问问关于group和attributegroup在schemal中的用法。
    谢了
--  作者:wangtng
--  发布时间:8/16/2005 10:11:00 PM

--  
我也存在同样的问题
--  作者:headman
--  发布时间:8/19/2005 11:04:00 AM

--  
group Element

The group element enables you to group together element declarations.
Note: the group element is just for grouping together element declarations, no attribute declarations allowed!

<xsd:element name="Book" >
      <xsd:complexType>
                <xsd:sequence>
                         <xsd:group ref="PublicationElements"/>
                         <xsd:element name="ISBN" type="string"/>
                         <xsd:element name="Reviewer" type="string"/>
                </xsd:sequence>
      </xsd:complexType>
</xsd:element>
<xsd:element name="CD" >
      <xsd:complexType>
                <xsd:sequence>
                         <xsd:group ref="PublicationElements"/>
                         <xsd:element name="RecordingStudio" type="string"/>
                </xsd:sequence>
      </xsd:complexType>
</xsd:element>
<xsd:group name="PublicationElements">
        <xsd:sequence>
            <xsd:element name="Title" type="xsd:string"/>
            <xsd:element name="Author" type="xsd:string" maxOccurs="unbounded"/>
            <xsd:element name="Date" type="xsd:string"/>
        </xsd:sequence>
</xsd:group>

Following is error!!!!!

<xsd:element name="Book">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:group name="PublicationElements">
                    <xsd:sequence>
                        <xsd:element name="Title" type="xsd:string" minOccurs="0"/>
                        <xsd:element name="Author" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
                        <xsd:element name="Date" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:group>
                <xsd:element name="ISBN" type="xsd:string"/>
                <xsd:element name="Publisher" type="xsd:string"/>
            </xsd:sequence>
            ...
        </xsd:complexType>
    </xsd:element>


--  作者:headman
--  发布时间:8/19/2005 11:09:00 AM

--  
attributegroup:

<xsd:element name="BookStore">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Book"  maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="Title" type="xsd:string"/>
                            <xsd:element name="Author" type="xsd:string"/>
                            <xsd:element name="Date" type="xsd:string"/>
                            <xsd:element name="ISBN" type="xsd:string"/>                                     
                            <xsd:element name="Publisher" type="xsd:string"/>
                        </xsd:sequence>
                        <xsd:attributeGroup ref="BookAttributes"/>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:attributeGroup name="BookAttributes">
        <xsd:attribute name="Category" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="autobiography"/>
                    <xsd:enumeration value="non-fiction"/>
                    <xsd:enumeration value="fiction"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="InStock" type="xsd:boolean" default="false"/>
        <xsd:attribute name="Reviewer" type="xsd:string" default=" "/>
    </xsd:attributeGroup>


--  作者:zhwpost
--  发布时间:4/3/2006 9:15:00 AM

--  
学习中

--  作者:highthand
--  发布时间:4/5/2006 10:40:00 PM

--  
谢谢二楼的兄弟,看了有收获.
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
78.125ms