具有混合内容的 xsd 复杂类型 [英] xsd Complex Types with Mixed Content

查看:39
本文介绍了具有混合内容的 xsd 复杂类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读本教程,它指出要获得这样的 xml:

I am reading this tutorial and it states that to get an xml like this:

<letter>
  Dear Mr.<name>John Smith</name>.
  Your order <orderid>1032</orderid>
  will be shipped on <shipdate>2001-07-13</shipdate>.
</letter> 

您需要此 xml 架构定义:

you need this xml schema definition:

<xs:element name="letter">
  <xs:complexType mixed="true">
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="orderid" type="xs:positiveInteger"/>
      <xs:element name="shipdate" type="xs:date"/>
    </xs:sequence>
  </xs:complexType>
</xs:element> 

但我认为这并不完全正确.它定义了 name、orderid 和 shiptdate 元素,但没有定义像 Dear Mr.Your orderwill be shipping 之类的纯文本代码>

But I see that is not completely correct. It defines the name, orderid, and shiptdate elements but it didn't define the plain text like Dear Mr., Your order and will be shipped on

唯一的 xs:string 类型已分配给 name 元素.

The only xs:string type has been assigned to the name element.

你能帮我理解一下吗?

非常感谢

推荐答案

这就是 mixed="true" 所做的 - 它允许在复杂类型的声明元素周围和之间使用任意文本.元素必须按要求的顺序出现,但中间可以有任何文本.

That's what the mixed="true" does - it permits arbitrary text around and between the declared elements of the complex type. The elements must appear in the required sequence but there can be any text in between.

这篇关于具有混合内容的 xsd 复杂类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆