[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl grabbing specific data

Subject: Re: xsl grabbing specific data
From: "cking" <cking@xxxxxxxxxx>
Date: Thu, 9 Sep 2004 10:04:32 +0200
xsl substring file name
Hi Dan,

Maybe you can create an additional xml-file, say 'files.xml':

    <files>
        <file>boot.ini</file>
        <file>compmgmt.msc</file>
        ...
    </files>

And then use

    <xsl:variable name="files" select="document('files.xml')/files/file"/> and
    <xsl:if test="$files[contains(file-acl/@name, .)]">

to extract only the files you want... something like

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>

 <xsl:variable name="files" select="document('files.xml')/files/file"/>

 <xsl:template match="/">
  <list>
   <xsl:apply-templates select="//file-acl-list/file-acl"/>
   <!-- NOTE: if possible, pass absolute path rather than "//" -->
  </list>
 </xsl:template>

 <xsl:template match="file-acl">
  <xsl:if test="$files[contains(current()/@name, .)]">
   <xsl:variable name="filename">
    <xsl:call-template name="filename-from-path">
     <xsl:with-param name="name" select="@name"/>
    </xsl:call-template>
   </xsl:variable>
   <file name="{$filename}">
    <xsl:apply-templates select="ace"/>
   </file>
  </xsl:if>
 </xsl:template>

 <xsl:template match="ace">
  <xsl:if test="@is-grant = 'true'">
   <!-- or do whatever else to handle this -->
   <ace trustee="{@trustee}"/>
  </xsl:if>
 </xsl:template>

 <xsl:template name="filename-from-path">
  <xsl:param name="name"/>
  <xsl:choose>
   <xsl:when test="contains($name, '\')">
    <xsl:call-template name="filename-from-path">
     <xsl:with-param name="name" select="substring-after($name, '\')"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="$name"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

</xsl:stylesheet>

HTH,
Anton Triest

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.