Tip: Batch Processing XML with XSLT 2.0
By Jack Herrington2005-05-04
HXDLG to the Rescue!
While surfing the Web, I found an obscure little Java program called the HTML/XML Directory List Generator (HXDLG) on SourceForge (see Resources). One of the functions of HXDLG is to create either HTML or XML representations of directory listings. I downloaded the tool and ran the statement in Listing 1 from the command line.
Listing 1. Code to create an XML directory using HXDLG
java -jar hdlg.jar XMLThe program takes three arguments. The first argument is the output type -- either XML or HTML. The second argument is the directory path. The third argument is the path of the output XML file. The result looks something like the code in Listing 2.
/Users/jherr/Projects/ibm_xml_tips/filelist/testfiles/
/Users/jherr/Projects/ibm_xml_tips/filelist/files.xml
Listing 2. The directory in XML
<?xml version="1.0" encoding="UTF-8"?>That's some high-end stuff. It has a Document Type Definition (DTD) and uses namespaces, and also has the file names and URLs that you're looking for. With absolute paths, to boot!
<!DOCTYPE hdlg:filesystem SYSTEM
"http://www.hdlg.info/XML/filesystem.dtd">
<hdlg:filesystem
xmlns:hdlg="http://www.hdlg.info/XML/filesystem">
<hdlg:folder name="testfiles"
url="file:/Users/jherr/Projects/ibm_xml_tips/filelist/testfiles/">
<hdlg:file name="test1.xml" size="179"
type="unknown"
url="file:/ibm_xml_tips/filelist/testfiles/test1.xml">
</hdlg:file>
<hdlg:file name="test2.xml" size="181"
type="unknown"
url="file:/ibm_xml_tips/filelist/testfiles/test2.xml">
</hdlg:file>
<hdlg:file name="test3.xml" size="181"
type="unknown"
url="file:/ibm_xml_tips/filelist/testfiles/test3.xml">
</hdlg:file>
</hdlg:folder>
</hdlg:filesystem>
Tutorial Pages:
» Use Directory Listings in XML to Drive XSLT 2.0 Processing
» HXDLG to the Rescue!
» Test It Out
» Summary
» Resources
First published by IBM DeveloperWorks
