Redian新闻
>
[转载] Re: May a XML file have more than one root?
avatar
[转载] Re: May a XML file have more than one root?# XML - WWW明日之星
w*h
1
【 以下文字转载自 Java 讨论区 】
【 原文由 gas 所发表 】
no
avatar
w*h
2
【 以下文字转载自 Java 讨论区 】
【 原文由 sui 所发表 】
Why not?

avatar
w*h
3
【 以下文字转载自 Java 讨论区 】
【 原文由 txvoilet 所发表 】
If a XML's DTD has two roots, but the XML just has one root.
Is the XML valid?
Another one question, who know which parser can deal with
the XML with more
than one root? How about Oracle parser?
avatar
w*h
4
【 以下文字转载自 Java 讨论区 】
【 原文由 zinczinc 所发表 】
Please read the XML1.0 spec. One root per document is for
well-formed or valid XML document. But you can always write
ill-formed ones.
avatar
w*h
5
【 以下文字转载自 Java 讨论区 】
【 原文由 txvoilet 所发表 】
Can Oracle XML parser deal with ill-formed XML?
avatar
w*h
6
【 以下文字转载自 Java 讨论区 】
【 原文由 gas 所发表 】
yes
It is not XML and you should not suppose xml parser to do so.
avatar
w*h
7
【 以下文字转载自 Java 讨论区 】
【 原文由 txvoilet 所发表 】
It is not XML? what is it then?
You said above that XML can have one root and its DTD has
tow roots.
That means a XML need not obey its DTD strictly?For example,
Here is a DTD file:







avatar
w*h
8
【 以下文字转载自 Java 讨论区 】
【 原文由 txvoilet 所发表 】
It is not XML? what is it then?
You said above that XML can have one root and its DTD has
tow roots.
That means a XML need not obey its DTD strictly?For example,
Here is a DTD file:







avatar
w*h
9
【 以下文字转载自 Java 讨论区 】
【 原文由 gas 所发表 】
bad-formed XML or non-XML markup language
sure
avatar
w*h
10
【 以下文字转载自 Java 讨论区 】
【 原文由 wendywh 所发表 】
XML can have several roots.
But it's hard to find a XML parser to deal with that.
As to the Oracle parser, you can check getDocumentElement(), it will
allows direct access to the child node that is the root element of
the document.But the return value is just Element. So it means that you cannnot
return a list of root elements.
I have not find any parser can return a list of root elements.
avatar
w*h
11
【 以下文字转载自 Java 讨论区 】
【 原文由 xt 所发表 】
I think our house parser can deal with that, but it will
parse the file into more than 1 message.
avatar
b*k
12

It's wrong according to the specification.
That should be called XML fragment.
All you have to do is create a root yourself. something like:

&data;

you define your data as entity reference.
It's because there is only one root for every xml document.

【在 w*****h 的大作中提到】
: 【 以下文字转载自 Java 讨论区 】
: 【 原文由 xt 所发表 】
: I think our house parser can deal with that, but it will
: parse the file into more than 1 message.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。