Hi,
You can start with a recursive copy template and add a rule to check if
the item shold be copied or not. Assuming the document 2 is named
ids.xml then you need a stylesheet like below
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="item">
<xsl:if test="id=document('ids.xml')/ids/id">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Join Bytes! wrote:
Quote:
Originally Posted by
Hello,
>
I am very new to xsl. So, If anyone can help eme out, it would be
great. I have the following problem.
>
I have 2 xml documents.
>
Document 1: A collection of items
>
<items>
<item>
<id>...</id>
<location>...</location>
...
</item>
<item>
...
>
</item>
<items>
>
>
Document 2: A collection of ids (which is a subset of ids from
document 1)
<ids>
<id... </id>
<id... </id>
<ids>
>
Needed output in xml: Filtered document 1 consisting only of items with
the ids from document 2.
>
-js