[转载] Re: May a XML file have more than one root?# XML - WWW明日之星
w*h
1 楼
【 以下文字转载自 Java 讨论区 】 【 原文由 gas 所发表 】 no
w*h
2 楼
【 以下文字转载自 Java 讨论区 】 【 原文由 sui 所发表 】 Why not?
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?
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.
w*h
5 楼
【 以下文字转载自 Java 讨论区 】 【 原文由 txvoilet 所发表 】 Can Oracle XML parser deal with ill-formed XML?
w*h
6 楼
【 以下文字转载自 Java 讨论区 】 【 原文由 gas 所发表 】 yes It is not XML and you should not suppose xml parser to do so.
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:
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:
w*h
9 楼
【 以下文字转载自 Java 讨论区 】 【 原文由 gas 所发表 】 bad-formed XML or non-XML markup language sure
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.
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.
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.