以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  XML schema 怎么描述一个包含组合模式的继承类?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=65456)


--  作者:NatashaJackel
--  发布时间:8/5/2008 10:33:00 PM

--  XML schema 怎么描述一个包含组合模式的继承类?
我需要用XML格式导出一份数据,之前必须定义XML文档的结构。
数据结构是一个以A类为跟的类B,包含组合模式,B自己组合B自己, 然后派生一个C子类。意思是B可以有自己的儿子,其儿子是B或者C类。
class A
{
std::vector<B*> m_regChildren;
}
class B
{
A *m_pParent;
std::vector<B*> m_regChildren;
}
class C: public B
{
B *m_pParent;
}
但是当我声明B为 xs:element 的话,它没办法作为 C类 xs:complexType 的基类。提示无法找到基类。
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="A">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="B">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="C">
                <xs:complexType>
                  <xs:complexContent>
                    <xs:extension base="B">
                       <xs:sequence />
                    </xs:extension>
                  </xs:complexContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

请问我怎么写才能写对呢?

如果我要写组合模式,是不是这样就OK了? 我用VisualStiduo2005的xmlschema,需要用增加关联来实现组合吗? 还是直接现在这样就是组合了?

谢谢呀!


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