Serially referring to elements in multiple files
Posted: Mon Aug 12, 2013 7:00 pm
Hello all,
I am trying to create an XSLT stylesheet in order to convert XML information from multiple files. I have used the collection function to group the files, but my problem is more complex:
I have two sets of files: one directory includes xml HEADERs, the other directory the xml TEXTs of the same documents. The TEXTs are grouped by the collection function and I extract the elements I require from it. In addition, I need to extract elements (title and date) from the parallel header file (which have the same name and a common ID element, only .hdr extension). I tried this way, which as I suspected did not work:
any ideas how else I could solve this?
Many thanks,
Sinai
I am trying to create an XSLT stylesheet in order to convert XML information from multiple files. I have used the collection function to group the files, but my problem is more complex:
I have two sets of files: one directory includes xml HEADERs, the other directory the xml TEXTs of the same documents. The TEXTs are grouped by the collection function and I extract the elements I require from it. In addition, I need to extract elements (title and date) from the parallel header file (which have the same name and a common ID element, only .hdr extension). I tried this way, which as I suspected did not work:
Code: Select all
<xsl:variable name="X" select="collection('file:/.../?select=*.xml;recurse=yes')//TEXT"/>
<xsl:for-each select="$X">
<tr>
<xsl:variable name="headerfile" select= "self::IDG/@ID"> </xsl:variable>
<td><xsl:value-of select="$headerfile"/></td>
<td><xsl:value-of select="doc('file:/.../$headerfile.hdr')//TITLESTMT/TITLE"/></td>
<td><xsl:value-of select="doc('file:/...//$headerfile.hdr')//SOURCEDESC//DATE"/></td>
<td><xsl:value-of select="TEXT/FRONT"/></td>
<td><xsl:value-of select="TEXT/BACK"/></td>
<td><xsl:value-of select="TEXT/BODY"/></td>
Many thanks,
Sinai