keys - across different files

Subject: keys - across different files
From: Dave Pawson <daveP@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Aug 2000 21:01:33 +0100
Sax errors apart <sorry Mike/>

Below is an example of using keys across / between
two different files, which the rec says they are not
supposed to be, and Mike Kays books says they can be.

Objective was to find out if all the 8 years of files
reflected in a database were actually still in the 
flat file store.
key1.xml is the database output,
key2.xml is the flat file system record (thanks Chris)
I found it quite a struggle, 3 mins for DC is the challenge :-)

Hope it helps someone else

Regards DaveP

Key1.xml (key2 inserted as comment)

<?xml version="1.0" standalone="yes"?>

  <state>xxxx</state> <!-- matches in key 2 -->
  <state>yyyy</state><!--  matches in key2 -->
  <state>aaaa</state><!--  match fails -->
  <state>zzzz</state><!--  matches in key2 -->
  <state>zzzB</state><!--  matches again in key2 -->
  <state>zzzA</state><!--  match fails -->

<!--  This is key2.xml



<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="";

   <xsl:output method="text"/>
   <xsl:strip-space elements="*"/>
   Objective: to find all //st elements in key2.xml that have the same
content as the particular set of elements in key1.xml

In my case it was, do all the 'actuals' in the flat file system
have records in the database which is supposed to reflect the
flat file system. (I.e. the database is reflected in key1.xml, the 
flat file system in key2.xml)

   <!-- key is in document 2, which must be the 'source' document -->
   <xsl:key name="target-node-set"  match="/wrapper/st" use="."/>

<!-- Root template on 'any document' -->
   <xsl:template match="/">
<!-- Grab and hold the first file element in primary file context -->
   <xsl:for-each select="document('key1.xml')">
     <xsl:for-each select="/wrapper/state">
<!-- Save the context element -->
       <xsl:variable name="here" select="."/>
       <!-- Change context to document  2 -->
	<xsl:for-each select="document('key2.xml')">
	  <xsl:if test="key('target-node-set', $here)">
	    Match on item <xsl:value-of select="$here"/> from key1




 XSL-List info and archive:

Current Thread