简体   繁体   中英

Does the xml “xinclude”d in another XML need to be fully valid?

I am trying to break up a massive XML into smaller more maintainable files by grouping relevant bits into a smaller XML. For example, here is my message with 100s of "message" elements.

<messages>
 <message>...</message>
 <message>...</message>
 <message>...</message>
 <message>...</message>
 <message>...</message>
 ...
</messages>

So my plan was to do something like -

<messages>
 <xi:include href="first_10_messages.xml" />
 <xi:include href="next_10.xml" />
 <xi:include href="another_10.xml" />
 ...
 <!-- other messages as is below -->
 <message>...</message>
 <message>...</message>
 ...
</messages>

The XMLs in the xi:include, are not valid XML as they dont have a root element. Is this possible?

When I apply schema validation on this I get the following error - "the markup in the document following the root element must be well-formed".

As a test, if I have a single <message> in the included file, it works fine as its valid XML.

I am parsing/validating the xml in Java using the DocumentBuilder api.

是的,XInclude的目标本身就是一个格式正确的XML文档。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM