xsl-list
[Top] [All Lists]

Re: [xsl] collecting a fileset with XSLT 2.0

2012-02-06 14:46:52
Mark,

This is cool.

On 2/6/2012 12:50 PM, Mark Giffin wrote:
Thanks Wendell, also good to know. In this project I ran out of time and
couldn't take the time to work out how to use collection(), so I handled
it elsewise. collection() would have required a ton of refactoring on
this project. I realized I mainly needed to exclude a couple files, so I
embedded a little lookup table in the stylesheet that holds a couple
strings:

<st:exclude>
<st:file name="filename1.xml"/>
<st:file name="filename2.xml"/>
</st:exclude>

Then I made a key to parse it:

<xsl:variable name="excluded-files"
select="document('')/xsl:stylesheet/st:exclude"/>

Or you could simply do

<xsl:variable name="excluded-files" as="element(st:file)+">
  <st:file name="filename1.xml"/>
  <st:file name="filename2.xml"/>
  ...
</xsl:variable>

and take it from there.

(The hoary old XSLT 1.0 trick you used is no longer necessary. :-)

Then you may not need the key any more either, as

exists($excluded-files[@name=$this-file])

will then tell you what you need to know, probably as fast.

(Many things can become much simpler under 2.0.)

Cheers,
Wendell


<!-- Key to parse $excluded-files. -->
<xsl:key name="excluded" match="st:file" use="@name"/>

And excluded those files by testing it with key():

<xsl:when test="exists(key('excluded', $thisfile, $excluded-files))">
<!-- do nothing -->
</xsl:when>

Maybe later I can get cooler with collection().

--
======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

--~------------------------------------------------------------------
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>
--~--