I am transforming data from a database into an XML format. I want to run
the transformation only on a subset of all records I have available. I
put identifiers for those records that I want to transform in a simple
external XML file, which I would like to use as filter.
Only those records should be transformed where
document(acquisition-nums.xml)//acqnum matches
tuple/atom[(_at_)name='ObjAccessionNo'].
The way I constructed the test does not work and the whole set from the
source file is transformed. I got stuck on this and can't move further.
I appreciate any hint or help on this. I am using Saxon B 9.1.0.7.
Thanks in advance, Standa
Here are the file samples:
File 1 - Source File (records.xml)
<table name="ecatalogue">
<tuple>
<atom name="ObjAccessionNo">2009.030</atom>
<atom name="ObjTitle">OBJECT TTTLE</atom>
<atom name="DatDateCreated">2009</atom>
</tuple>
<tuple>
<atom name="ObjAccessionNo">2009.031</atom>
<atom name="ObjTitle">OBJECT TTTLE</atom>
<atom name="DatDateCreated">2009</atom>
</tuple>
</table>
File 2 External File (acquisition-nums.xml)
<items>
<acqnum>2004.045</acqnum>
<acqnum>2005.098</acqnum>
<acqnum>2008.007</acqnum>
<acqnum>2009.030</acqnum>
</items>
Stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" name="xml"/>
<xsl:variable name="acq-num" select="document('acquisition-nums.xml')"/>
<xsl:template match="table[(_at_)name='ecatalogue']">
<collection>
<xsl:if
test="tuple/atom[(_at_)name='ObjAccessionNo']=$acq-num/items/acqnum">
<xsl:apply-templates select="tuple"/>
</xsl:if>
</collection>
</xsl:template>
<xsl:template match="tuple">
<record>
<identifier>
<xsl:value-of select="atom[(_at_)name='ObjAccessionNo']"/>
</identifier>
<title>
<xsl:value-of select="atom[(_at_)name='ObjTitle']"/>
</title>
</record>
</xsl:template>
</xsl:stylesheet>
--~------------------------------------------------------------------
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>
--~--