使用DTD可以指定元素出现的确切数目吗? [英] Using DTD can I specify an exact number of element occurrences?

查看:73
本文介绍了使用DTD可以指定元素出现的确切数目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用XML进行此练习,但我停留在这一特定点。我被要求创建一个满足要求列表的DTD,但我找不到实现以下条件的方法:

I am trying to do this exercise in XML and I am stuck at this particular point. I am being asked to create a DTD that will satisfy a list of requirements and I cannot find a way to achieve the following:


季节性价格'列表中可能没有,一,两个或三个出现过'season_price'元素

The seasonal_prices' list can have none, one, two or three occurrences of the 'season_price' element

有没有一种方法可以使用<

Is there a way to achieve this using only a DTD?

推荐答案


有没有一种方法可以使用 DTD?

Is there a way to achieve this using only a DTD?

不。

您只能这样做:


  • season_price (恰好是一个)

  • 季节价格?(零或一个)

  • season_price + (一个或多个)

  • season_price * (零或更多)

  • season_price (exactly one)
  • season_price? (zero or one)
  • season_price+ (one or more)
  • season_price* (zero or more)

请参见 https://www.w3.org/TR/xml11/#sec-element-content 了解更多信息。

----- 编辑 -----

----- Edit -----

就像您在另一个问题,您可以 >使用执行此操作吗?,例如:

Like you mentioned in another question, you could do this using ? like:

<!ELEMENT seasonal_prices (season_price?, season_price?, season_price?)>

但是没有XML Schema(minOccurs / maxOccurs)这样的直接方法。

but there's no direct way like in XML Schema (minOccurs/maxOccurs).

这篇关于使用DTD可以指定元素出现的确切数目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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