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

Re: Off-topic: DOS script for XML directory listing

Subject: Re: Off-topic: DOS script for XML directory listing
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Tue, 29 Feb 2000 20:07:05 +0000
dos script
Linda van den Brink wrote:
> 
> Could anyone give me a DOS script that can list the URLS of all the (XML)
> files in a directory and write them to an XML-formatted output file?
> 

>From the NT online help: "You cannot display a pipe (|) or redirection
character (< or > ) when using the echo command."

But it is still possible to do this without using anything but DOS, XML
and XSLT.

I've (lazily) assumed no spaces in file names...

Francis.



You need the following three files:

G:\xmlSchema>type xmlDir.bat

@echo off
dir *.xml /b > xmlDir.lst
saxon xmlDir.xml xmlDir.xsl > xmlFiles.xml

G:\xmlSchema>type xmlDir.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xmlDir [
<!ENTITY xmlDirList SYSTEM "xmlDir.lst">
  ]>

<xmlDir>
&xmlDirList;
</xmlDir>

G:\xmlSchema>type xmlDir.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<!-- root function -->
<xsl:template match="/xmlDir">

  <!-- create our root output element -->
  <xmlDir>

    <xsl:call-template name="file">
      <!-- normalise CRs and line-breaks into single spaces, plus one on
the end -->
      <xsl:with-param name="flist"
select="concat(normalize-space(string()),' ')" />
    </xsl:call-template>

  </xmlDir>

</xsl:template>


<!-- process the idividual files in the space-separated file list -->
<xsl:template name="file">
  <xsl:param name="flist" />

  <xsl:if test="$flist != ''">

    <xmlFile><xsl:value-of select="substring-before($flist, ' ')"
/></xmlFile>

    <xsl:call-template name="file">
      <xsl:with-param name="flist" select="substring-after($flist, ' ')"
/>
    </xsl:call-template>

  </xsl:if>

</xsl:template>

</xsl:stylesheet>


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


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.