XmlMerge actions

Help
2011-01-17
2013-05-02
  • Jared Gould

    Jared Gould - 2011-01-17

    I'm trying to merge 2 xml documents using the XmlMerge 1.1.1 library and the result is VERY close to what I expect. The only issue I'm seeing is that text elements append the patch document's string to the original, which isn't my intention at all (I want to replace). For example:

    file1.xml

    <rom>
        <romid>16BITBASE</romid>
        <make>Subaru</make>
    </rom>
    

    file2.xml

    <rom>
        <romid>A4TF400E</romid>
        <make>Subaru</make>
        <flashmethod>wrx04</flashmethod>
    </rom>
    

    output.xml

    <rom>
        <romid>16BITBASEA4TF400E</romid>
        <make>SubaruSubaru</make>
        <flashmethod>wrx04</flashmethod>
    </rom>
    

    When what I really want is this:

    <rom>
        <romid>4TF400E</romid>
        <make>Subaru</make>
        <flashmethod>wrx04</flashmethod>
    </rom>
    

    Is there a way to do this without privileges to modify the xml source? Thank you very much for your help!

     
  • Jared Gould

    Jared Gould - 2011-01-26

    Thank you very much for your help. I'm actually using the XmlMerge library in my own open source project (http://www.romraider.com) and chose 1.1.1 because I couldn't find a standalone build of later versions and don't need the rest of the el4j functionality. I may look in to building a newer version but for the time being it looks like 1.1.1 will fill my needs.

     
  • Jared Gould

    Jared Gould - 2011-01-29

    I thought it might help me get a better understanding of the API if I looked through the command line documentation but the links aren't working. Is there another place I can read the documentation?

     
  • Jared Gould

    Jared Gould - 2011-01-29

    I did manage to find the documentation in a download archive. I'm using XPath and Properties. I've got the hang of it now but bad practice in the xml sources I'm merging has brought up one last problem. The names of elements that should be merged don't match. The rule is fairly simple but I'm having trouble finding a way do it it programatically.

    16BITBASE.xml:

    <rom>
      <table name="Target Boost" rom>
        <table name="Throttle" type="X Axis" elements="8" scaling="%" />
        <table name="Engine Speed" type="Y Axis" elements="9" scaling="RPM" />
      </table>
    </rom>
    

    A4TF400E.xml:

    <rom>
      <table name="Target Boost" address="2a726">
        <table name="X" address="2a714" elements="500"/>
        <table name="Y" address="2a701" />
      </table>
    </rom>
    

    In the second file, the axis table names were replaced with a shortened version of the type attribute. The easiest way would be to add a new id attribute to each; if type='X Axis' or name='X', then id='x', and then match on id. Is there a way to do this?

    Thanks again for the help!
    Jared

     
  • Jared Gould

    Jared Gould - 2011-01-31

    My solution was to create an XSL transform to make attributes play more friendly with XmlMerge. Unfortunately,  my source documents aren't ordered so I don't think XmlMerge is going to work for me. I appreciate your input though.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks