加入xml片段 [英] joining xml fragments

查看:20
本文介绍了加入xml片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 id 或其他方式将这 2 个片段连接在一起 .. 我有 2 种方法

I want to join these 2 fragments together by id or whatever .. I have 2 ways

<SigmodRecord>
 <issue>
  <volume>11</volume> 
  <number>1</number> 
 <articles>
 <article> <id>1</id> ....  </article>
 <article> <id>2</id>....  </article>
 <article> <id>3</id>....  </article>
 <article> <id>4</id> .....  </article>
</articles>
</issue>
</SigmodRecord>

<小时>

<SigmodRecord>
 <authors><id>1</id>...</authors> 
 <authors><id>2</id> ...</authors>
 <authors><id>3</id>...  </authors>
 <authors><id>4</id>....</authors>
</SigmodRecord>

<小时>

第一个问题,如果我已经有大量数据,这将通过添加元素来增加文件大小或另一种方式是属性像和但我需要一些更精简、更高效的内容,参考这个问题 xsd如何表示不同的xml文件?提前致谢

推荐答案

如果你想通过id加入,那么你可以在文章节点[authorIdRef]中有一个属性.此属性可用于链接到包含实际数据的作者节点 [uniqueId].

例如,

If you want to join by id, then you can have a attribute in the article node [authorIdRef]. This attribute can be used to link to a author node [uniqueId] containing the actual data.

For example,

<article authorIdRef="author1"> ...  </article>
...
...
<authors>
    <author uniqueId="author1"> .... </author>
</authors

请注意,在上述情况下,数据的验证(链接作者是否存在)完全由 xml 的使用者完成.例如,可以有一个 authorIdRef="author1" 但在作者节点中没有作者将其 uniqueId 作为 author1.

架构需要相应地修改以反映附加属性.

Note that in the above case the validation of the data (whether the linked author is present or not is to done entirely by the consumer of the xml. For example, it is possible to have an authorIdRef="author1" but in the authors node there is no author having its uniqueId as author1.

The schema needs to be modified accordingly to reflect the additional attributes.

这篇关于加入xml片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆