首页 新闻 会员 周边

xml架构

0
[已关闭问题]

<Books>
 <book title="西游记">
           <author>吴承恩</author>
           <price>100</price>
        </book>
 <book title="西游记">
           <author>吴承恩</author>
           <price>100</price>
        </book>
</Books>

这个xml文档中的title="西游记"属性在xml架构中怎么进行定义啊,请高手指点,谢谢!!!

无名氏的主页 无名氏 | 初学一级 | 园豆:190
提问于:2010-05-31 11:27
< >
分享
其他回答(2)
0

为什么不这样呢?

<Books>
 <book>

    <title>西游记</title>
           <author>吴承恩</author>
           <price>100</price>
        </book>

 <book>

    <title>西游记</title>
           <author>吴承恩</author>
           <price>100</price>
        </book>

</Books>

Jared.Nie | 园豆:1940 (小虾三级) | 2010-05-31 12:55
0

怎么样写都行,你说的“架构定义”是什么意思。

Astar | 园豆:40805 (高人七级) | 2010-05-31 13:46
0

title 是 book 的一个属性,book 是复杂类型

整个的 schema 应该是

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Books">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" name="book">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="author" type="xs:string" />
                            <xs:element name="price" type="xs:unsignedByte" />
                        </xs:sequence>
                        <xs:attribute name="title" type="xs:string" use="required" />
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

冠军 | 园豆:886 (小虾三级) | 2010-05-31 21:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册