I have two inputs for transformation.
One is source XML source.xml and looks like this:
<ROOT>
<row>
<id>1</id>
<value>FooBar</value>
</row>
<row>
<id>2</id>
<value>Bar</value>
</row>
<row>
<id>3</id>
<value>FooFoo</value>
</row>
</ROOT>
Other one is supplied through parameter (<xsl:param name="input" />) into transformation. Structure is same as a XML above. But contains different number of rows and different values.
<ROOT>
<row>
<id>1</id>
<value>Foo</value>
</row>
<row>
<id>2</id>
<value>Bar</value>
</row>
</ROOT>
Now I need to merge those inputs. I want to iterate over source.xml and for each row's id decide if there is same id in variable and update. If there is not same id in variable $input I want to create new row.
In other words: source.xml represents new data while input parameter represents data I already have. And I want them to merge. I think you get it.
I tried many ways to solve this, but I always stucked on comparing ids with creating unnecessary rows. The restrictions are those:
- XSLT 1.0 limitation.
- input for comparison can be imported only by using XSLT parameter.
Output should look like this:
<ROOT>
<row>
<id>1</id>
<value>FooBar</value>
</row>
<row>
<id>2</id>
<value>Bar</value>
</row>
<row>
<id>3</id>
<value>FooFoo</value>
</row>
</ROOT>
<xsl:param name="input" />does not tell us what kind of type your parameter will have.<row> <id>1</id> <value>Updated</value> </row>and not<row> <id>1</id> <value>Foo</value> </row>if thesource.xmlrepresents the new data?