ro********@yahoo.com wrote:
1) static xml
<items>
<item id="1" type="clothes"/>
<item id="2" type="cars"/>
<item id="3" type="tvs"/>
</items>
2) i need to derive a unique set from the following:
<new-items>
<new-item type="house"/>
<new-item type="boats"/>
</new-items>
<new-items>
<new-item type="windows"/>
<new-item type="boats"/>
</new-items>
** i can use muenchian to get uniques
If those are two different documents then I think grouping with key is
difficult as I think a key applies always to nodes in one particular
document but not across documents. You might need an extra step that
first combines those two documents.
2b) i need to combine (1) with (2) to get:
<items>
<item id="1" type="clothes"/>
<item id="2" type="cars"/>
<item id="3" type="tvs"/>
<item id="4" type="house"/>
<item id="5" type="boats"/>
<item id="6" type="windows"/>
</items>
Well you can certainly do
<xsl:variable name="itemCount" select="count(items/item)" />
and
<xsl:template match="items">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="item" />
<xsl:variable name="new-items"
select="document('test2005110102.xml', /)/new-items/new-item" />
<xsl:apply-templates select="$new-items[not(@type =
preceding-sibling::new-item/@type)]" />
</xsl:copy>
</xsl:template>
and
<xsl:template match="new-item">
<item id="{$itemCount + position()}" type="{@type}" />
</xsl:template>
--
Martin Honnen
http://JavaScript.FAQTs.com/