[Home] [By Thread] [By Date] [Recent Entries]
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[@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[@name='ecatalogue']"> <collection> <xsl:if test="tuple/atom[@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[@name='ObjAccessionNo']"/>
</identifier>
<title>
<xsl:value-of select="atom[@name='ObjTitle']"/>
</title>
</record>
</xsl:template></xsl:stylesheet>
|

Cart



