Hi.
find below the stylesheet plus "verification" of output.
$ cat codes.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:output encoding="ISO-8859-1" />
<xsl:variable name="codes"><c>123</c><c>456</c></xsl:variable>
<xsl:template match="/">
<spool>
<xsl:for-each select="
(document('File1.xml')|document('File2.xml')|document('File3.xml'))
/spool
/pd[fact/cab/code[.=document('')/*/xsl:variable[(_at_)name='codes']/c]]
">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="fact"/>
<xsl:copy-of select="document"/>
</xsl:copy>
</xsl:for-each>
</spool>
</xsl:template>
</xsl:stylesheet>
$
$ xsltproc codes.xsl codes.xsl >out.xml
$ tidy -q -xml out.xml >out.tidy
$ tidy -q -xml target.xml >target.tidy
$ diff out.tidy target.tidy
$
Mit besten Gruessen / Best wishes,
Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
Fixpack team lead
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
From: "Jimenez, Luis" <Luis(_dot_)Jimenez(_at_)xerox(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Date: 11/30/2010 05:28 AM
Subject: [xsl] Search In Multiple Files
Hi All,
as I can find several codes in different files and having an output with
the results with a single XSL.
i.e:
codes to search: 123 and 456
Tag to search for previous codes: fact and document
XSLT 1.0
File 1.xml:
<?xml version="1.0" encoding="iso-8859-1"?> <spool>
<pd>
<fact>
<cab>
<name>Luis</name>
<code>123</code>
</cab>
<details/>
</fact>
<pica>
<box>1</box>
</pica>
<document>
<number>1</number>
</document>
</pd>
<pd ps="1">
<fact>
<cab>
<name>Juan</name>
<code>456</code>
</cab>
<details/>
</fact>
<pica>
<box>2</box>
</pica>
<document>
<number>2</number>
</document>
</pd>
</spool>
File 2.xml:
<?xml version="1.0" encoding="iso-8859-1"?> <spool>
<pd>
<fact>
<cab>
<name>Luis</name>
<code>123</code>
</cab>
<details/>
</fact>
<pica>
<box>3</box>
</pica>
<document>
<number>3</number>
</document>
</pd>
<pd ps="1">
<fact>
<cab>
<name>Ernesto</name>
<code>789</code>
</cab>
<details/>
</fact>
<pica>
<box>4</box>
</pica>
<document>
<number>4</number>
</document>
</pd>
</spool>
File 3.xml:
<?xml version="1.0" encoding="iso-8859-1"?> <spool>
<pd>
<fact>
<cab>
<name>Valery</name>
<code>789</code>
</cab>
<details/>
</fact>
<pica>
<box>6</box>
</pica>
<document>
<number>5</number>
</document>
</pd>
<pd ps="1">
<fact>
<cab>
<name>Juan</name>
<code>456</code>
</cab>
<details/>
</fact>
<pica>
<box>9</box>
</pica>
<document>
<number>6</number>
</document>
</pd>
</spool>
Desired Output è Codes: 123 and 456 with only Tag fact and document:
<?xml version="1.0" encoding="iso-8859-1"?> <spool> <pd>
<fact>
<cab>
<name>Luis</name>
<code>123</code>
</cab>
<details/>
</fact>
<document>
<number>1</number>
</document>
</pd>
<pd ps="1">
<fact>
<cab>
<name>Juan</name>
<code>456</code>
</cab>
<details/>
</fact>
<document>
<number>2</number>
</document>
</pd>
<pd>
<fact>
<cab>
<name>Luis</name>
<code>123</code>
</cab>
<details/>
</fact>
<document>
<number>3</number>
</document>
</pd>
<pd ps="1">
<fact>
<cab>
<name>Juan</name>
<code>456</code>
</cab>
<details/>
</fact>
<document>
<number>6</number>
</document>
</pd>
</spool>
Thanks for the help.
Luis Fdo.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--