使用内部xml节点和文本为节点创建DTD [英] Create DTD for node with inner xml node and text
本文介绍了使用内部xml节点和文本为节点创建DTD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有如下所示的非常简单的XML。
I have pretty simple XML shown below.
<?xml version="1.0" ?>
<message>
This is a message with some <bold>highlights</bold> in a text.
</message>
如何创建DTD来验证消息元素中的内容?节点和文本的混合体。
How can I create DTD to validate things inside message element? A mixture of node and text. This does not work.
<!DOCTYPE message [
<!ELEMENT message (#PCDATA, bold)>
<!ELEMENT bold (#PCDATA)>
]>
推荐答案
当您混合内容(元素和文本),您不能指定顺序(使用 |
而不是,
),并且它必须是零次或多次出现( *
)。
When you have mixed content (both elements and text), you can't specify order (use |
instead of ,
) and it has to be zero or more occurrences (*
).
示例:
<!DOCTYPE message [
<!ELEMENT message (#PCDATA|bold)*>
<!ELEMENT bold (#PCDATA)>
]>
<message>
This is a message with some <bold>highlights</bold> in a text.
</message>
这篇关于使用内部xml节点和文本为节点创建DTD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文