1

I have an xml file of following structure:

<root>
<paramsToInclude>
    <params id="id1">
        <param11>val1</param11>
        <param12>val2</param12>
        <param13>val3</param13>
        <param14>val4</param14>
    </params>

    <params id="id3">
        <param31>val1</param31>
        <param32>val2</param32>
    </params>
</paramsToInclude>

<process>
    <subprocess1>
        <include params="id1"/>
        <query>
            SELECT *
            FROM
            table;
        </query>
    </subprocess2>

    <subprocess1>
        <rule>rule1</rule>
        <rule>rule2</rule>
    </subprocess2>

    <subprocess3>
        <processParam>val1</processParam>
        <include params="id2"/>
        <include params="id3"/>
    </subprocess3>
</process>

I'm using jaxb to parse this xml into the java classes. Is there a way to substitute includes in the process by it's values from the begin of file? I mean, I wan't file to be parsed as if it look's like

<root>
<paramsToInclude>
    <params id="id1">
        <param11>val1</param11>
        <param12>val2</param12>
        <param13>val3</param13>
        <param14>val4</param14>
    </params>

    <params id="id3">
        <param31>val1</param31>
        <param32>val2</param32>
    </params>
</paramsToInclude>

<process>
    <subprocess1>
        <param11>val1</param11>
        <param12>val2</param12>
        <param13>val3</param13>
        <param14>val4</param14>
        <query>
            SELECT *
            FROM
            table;
        </query>
    </subprocess2>

    <subprocess1>
        <rule>rule1</rule>
        <rule>rule2</rule>
    </subprocess2>

    <subprocess3>
        <processParam>val1</processParam>
        <param11>val1</param11>
        <param12>val2</param12>
        <param13>val3</param13>
        <param14>val4</param14>
        <param31>val1</param31>
        <param32>val2</param32>
    </subprocess3>
</process>

is it possible t do this? I've found link http://thetechietutorials.blogspot.com/2011/08/jaxb-tutorial-part-2-jaxb-with-xinclude.html how to this include from another file, but comment says that it's impossible to do this for the same file (I understand that I can put this includes in another xml, but I don't think it's a best way). Also I don't want to use hashMap because in this way included params will be stored in hashMap and processParam (from subprocess3) will be class variable. Is there a way to do this somehow?

user2281439
  • 673
  • 2
  • 11
  • 19
  • [See my question about `key` and `keyref`](http://stackoverflow.com/q/17300793/2071828) - there are links to explanations of how to do this in Moxy. – Boris the Spider Nov 07 '13 at 08:22

0 Answers0