以文本方式查看主题

-  中文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=45810)


--  作者:shijian3
--  发布时间:4/22/2007 9:09:00 AM

--  [求助] 帮忙写一个不复杂的XML Schema. 感激不尽
大家好,我现在想给一个烹饪成分XML文件写XML Schema,这个文件主要介绍一个成分,成分描述,数量.方法等等.
请大家帮帮忙. 谢谢各位.

下面是这个XML文件的样板:
<?xml version="1.0" ?>
- <recipe>
      <name>Aussie Damper</name>
      <description>some description</description>
    - <categories>
          <category>Bread</category>
          <category>Snack</category>
      </categories>
    - <yield>
          <quantity>1</quantity>
          <unit>loaf</unit>
      </yield>
    - <ingredients>
        - <ingredient>
              <quantity>2</quantity>
              <unit>cups</unit>
              <item>self-raising flour</item>
              </ingredient>
        - <ingredient>
              <quantity>1</quantity>
              <unit>cup</unit>
              <item>water</item>
              <preparation>cold</preparation>
          </ingredient>
        - <ingredient>
              <quantity>1</quantity>
              <unit>pinch</unit>
              <item>salt</item>
          </ingredient>
    </ingredients>
    - <method>
          <step>step 1</step>
          <step>step 2</step>
      </method>
  </recipe>

Schema有如下要求:(下面每个英文单词都是XML文件里的一个节点)
1.每个recipe必须有且仅有一个name.
2.description可有可无,但是每个recipe最多只能有一个description.
3.每个recipe必须至少有一个category,但是每个recipe可以有categories的总数不限.
4.category的值必须是 1,2,3,4,5 其中一个.(这里只是用数字打个比方,简化使大家更容易明白).
5.每个recipe必须有一个yield,而且yield必须包含quantityY和unit. yield里面的quantity必须是一个正整数.
6.每个recipe必须有一个或者多个ingredients.
7.每个ingredient必须有quantity和item.  unit和preparation可有可无.
8.每个ingredient里面的quantity必须是正数,并且可以最多有两位小数.
9.每个recipe必须有一个method,并且每个method必须有一个或者多个step.


--  作者:gemingke
--  发布时间:4/23/2007 4:17:00 PM

--  
确实不复杂,为什么不自己动手试试呢?
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms