开发者

adding elements to including file via XInclude

Can I somehow add elements to included file using XPointer or XPath or anything else?

Main file

<doc xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="field.xml" />
</doc>

field.xml

<field>
    <title>address</title>
    <type>string</type>
</field>

I want to add 'size' element to field.xml while including so the resulting file should look like

<doc xmlns:xi="http://www.w3.org/2001/XInclude">
    <field>
        <title>address</title>
        <type>开发者_开发问答;string</type>
        <size>64</size>
        <size>51</size>
    </field>
</doc>


Problem solved

I've used next trick to solve the problem:

<doc xmlns:xi="http://www.w3.org/2001/XInclude">
    <field>
        <xi:include href="field.xml#xpointer(/field/child::*)" />
        <size>64</size>
        <size>51</size>
    </field>
</doc>

I've included from 'field.xml' all child elements that belong to parent 'field'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜