Batch XML with XSLT 2.0

Source: Internet
Author: User
Tags xslt xslt processor

Most people want an XSLT processor like Saxon to use multiple input files. It's often a problem to convert an XML file from one directory to HTML. You can use Saxon for each of these files, but what if you finally want to generate a file that contains all the HTML files ' indexes?

What you need is an XML version of the catalog list. This enables you to use the XML file as the unique input file for XSLT and to process each file with XSLT. It would be perfect if XSLT was able to do directory processing directly. Unfortunately, although XSLT is powerful, especially XSLT 2.0, there is no directory operation for this language.

Hxdlg to help!

While surfing the web, I found an obscure little Java program from SourceForge, Html/xml Directory List Generator (see Resources). One of the features of Hxdlg is to create an HTML or XML representation of a directory listing. I downloaded the tool and ran the statement shown in Listing 1 from the command line.

Listing 1. To create the code for an XML catalog using Hxdlg

java -jar hdlg.jar XML
  /Users/jherr/Projects/ibm_xml_tips/filelist/testfiles/
  /Users/jherr/Projects/ibm_xml_tips/filelist/files.xml

This program has three parameters. The first parameter is the output type, XML or HTML. The second is the directory path, and the third is the path to the output XML file. The results are shown in Listing 2.

Listing 2. XML-Formatted Directory

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hdlg:filesystem SYSTEM
  "http://www.hdlg.info/XML/filesystem.dtd">
xmlns:hdlg="http://www.hdlg.info/XML/filesystem">
     url="file:/Users/jherr/Projects/ibm_xml_tips/filelist/testfiles/">
         type="unknown"
  url="file:/ibm_xml_tips/filelist/testfiles/test1.xml">
             type="unknown"
  url="file:/ibm_xml_tips/filelist/testfiles/test2.xml">
             type="unknown"
  url="file:/ibm_xml_tips/filelist/testfiles/test3.xml">
     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.