xsl-list
[Top] [All Lists]

Re: testing which files have same element/@code

2003-07-30 01:22:05
Date: Tue, 19 Aug 2003 10:17:30 -0600
From: Rick Taylor <taylor(_at_)ppdm(_dot_)org>
Subject: Re: [xsl] testing which files have same element/@code

James,

This should work. However, it might be slow if you have lots of files to parse.

<xsl:param name="codeValue" select="'124'"/>

<xsl:template match="files">
 <form action="http://www.foo.com";>
  <select name="File-to-see">
   <xsl:apply-templates
select="file[count(document(@filename)/foo/bar[(_at_)code=$codeValue]) &gt; 
0]"/>
  </select>
  <input type="hidden" name="code" value="{$codeValue}"/>
  <input type="submit"/>
 </form>
</xsl:template>

<xsl:template match="file">
 <option name="{(_at_)name}">
  <xsl:value-of select="@filename"/>
 </option>
</xsl:template>

Yup, that was the kind of method I was assuming.  I've decided for the
pre-generated files this will be an ok way to do it - it doesn't matter
how long it takes (within reason) to create those.  For those that are
dymanically created in a cocoon pipeline, this seems less reasonable.

I suppose another way to do this would be to create an intermediate
file which contains all the possible @code values with a list of
what files have that code, so I could get the information by opening
only one file, which would be quicker.  So something like:
<foo>
<bar code="123">
<file name="file1.xml"/>
<file name="file2.xml"/>
<file name="file3.xml"/>
<file name="file4.xml"/>
</bar>
<bar code="134">
<file name="file1.xml"/>
<file name="file4.xml"/>
</bar>
<bar code="139"/>
</foo>

-- 
Dr James Cummings, James(_dot_)Cummings(_at_)uea(_dot_)ac(_dot_)uk, 
http://www.uea.ac.uk/~q503
Cursus Project, School of Music, University of East Anglia,
Norwich, Norfolk, NR4 7TJ, UK  Tel:(01603)593-595



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>