0

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>
witzawitz
  • 416
  • 1
  • 5
  • 11

1 Answers1

0

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'.

witzawitz
  • 416
  • 1
  • 5
  • 11