A.2 Using jd.xslt

The jd.xslt XSLT processor was written by Johannes Döbler of Munich, Germany. This processor supports XSLT Version 1.1 (see http://www.w3.org/TR/xslt11). XSLT 1.1 was withdrawn by the W3C in favor of XSLT 2.0, which is now under development. Nevertheless, Version 1.1 offers several interesting features, including the script element, not available under XSLT Version 1.0. The script element allows you to define extensions within a stylesheet, something like the function element in XSLT 2.0. You can read more about the jd.xslt processor at http://www.aztecrider.com/xslt/.

A.2.1 Downloading and installing jd.xslt

Follow these steps (which may vary over time) to download and install jd.xslt:

  1. Using a browser, go to http://aztecrider.com/xslt/download.html.

  2. Click on http://aztecrider.com/xslt/jdxslt.zip.

  3. Save the file jdxslt.zip to the directory of your choice.

  4. When the download is complete, extract the file from the archive using an unzip utility.

  5. The installation is complete.

A.2.1.1 Running jd.xslt

One option is to copy the JAR file jdxslt.jar from the lib directory of the archive to one of the chapter directories under C:\LearningXSLT\examples directory. Placing the JAR in a working directory obviates the need to deal with the Java classpath (see Section A.1.2, earlier in this appendix).

Test to see if jd.xslt works by typing the following line at a command prompt:

java -jar jdxslt.jar

This should give you:

jd.xslt processor version 1.5.2    Usage: java jd.xml.xslt.Stylesheet [options] xml [xsl...]    xml                   the uri of an input xml document, "-" for STDIN xsl...                zero or more uris of stylesheets - if their number is                       = 0: use the associated stylesheets of the xml document                       = 1: transform the input with that stylesheet                       > 1: chain the transformations                       the uri "urn:jdxslt:identity" denotes the identity                       transformation options: -entityresolver <cls> set a sax EntityResolver -errorstack           show the java call stack in case of an error -media <media>        filter associated stylesheets by their media attribute -msglistener <class>  set a message listener -out <file>           write the output to the file (default is System.out) -out:<prop> <value>   set the value of a xsl:output property -param <name> <expr>  set the value of a toplevel parameter (expr is a context-                       free XPath expression). Multiple parameters are allowed -parser <class>       set a sax parser -parserxml <class>    set a sax parser for input xml documents -parserxsl <class>    set a sax parser for the stylesheet -proxy <url>          set a proxy host -repeat <number>      repeat the transformation n times -security <class>     set a XsltSecurityManager -title <title>        filter associated stylesheets by their title attribute -trace                create trace output -uriresolver <class>  set a UriResolver -validate             validate xml documents -verbose              turn on verbose mode to display transformation info -w0                   recover silently from recoverable errors -w1                   report recoverable errors and continue (default) -w2                   treat recoverable errors as fatal java -jar saxon7.jar test.xml test.xsl

To transform a file, use the following:

java -jar jdxslt.jar test.xml test.xsl

To transform a source file with more than one stylesheet, use the following line:

java -jar jdxslt.jar test.xml test1.xsl test2.xsl test3.xsl

To send output to a file, use the -out option:

java -jar jdxslt.jar -out test.out test.xml test.xsl

Set an output property (based on the attributes of the output element) using the -out: option:

java -jar jdxslt.jar -out:indent yes test.xml

For verbose output, use the -verbose option:

java -jar jdxlst.jar -verbose test.xml test.xsl

If the source document has an associated DTD, you can validate it at runtime with the -validate option:

java -jar jdxslt.jar -validate test.xml test.xsl

A DTD will be associated with the XML document by a document type declaration, which will look something like:

<!DOCTYPE test SYSTEM "test.dtd">

A.2.2 Using xmlspy

Altova's xmlspy is available for download from http://www.xmlspy.com. You can get a free trial before purchasing a license. (This is the only XSLT processor I am demonstrating that isn't free.) I should note, however, that xmlspy runs only on the Windows platform.

Assuming that you have successfully installed xmlspy, follow these steps.

  1. Launch the xmlspy application.

  2. Choose Window All on/off. This closes the Project, Info, and Entry Helper windows.

  3. Open the file message.xml with File Open from the working directory C:\LearningXslt\examples\ch01 (or something similar, depending on how you've set things up).

  4. Choose View Text view.

  5. Open the file message.xsl with File Open in the same location as message.xml.

  6. Choose View Text view again. At this point, xmlspy should appear as it does in Figure A-1.

  7. Click on the message.xml window to give it the focus.

  8. Choose XSL XSL Transformation or press F10. A dialog box appears.

  9. Click the Window button, select the file message.xsl, and click OK. The dialog box should appear as shown in Figure A-2.

  10. Click OK once more and another HTML window appears showing you the result of the transformation, as in Figure A-3.

Figure A-1. xmlspy with files loaded
figs/lxsl_aa01.gif
Figure A-2. xmlspy dialog box
figs/lxsl_aa02.gif
Figure A-3. Result of transforming message.xml with message.xsl
figs/lxsl_aa03.gif

A.2.3 Using xRay2

Architag's xRay2 is a free, graphical XML editor with XSLT processing capability. It is available for download from http://www.architag.com/xray. xRay2, like xmlspy, runs only on the Windows platform.

Assuming that you have successfully downloaded and installed xRay2 according to the easy instructions provided by Architag, follow these steps to process a source document with a stylesheet.

  1. Launch the xRay2 application.

  2. Open the file message.xml with File Open from the working directory C:\LearningXSLT\examples\ch01\ (or something similar).

  3. Open the file message.xsl with File Open in the same location.

  4. Choose File New XSLT Transform.

  5. In the XML Document pull-down menu, select message.xml (see the result in Figure A-4).

  6. In the XSLT Program pull-down menu, select message.xsl (see what it should look like in Figure A-5).

  7. If it is not already checked, check Auto-update.

  8. The result of the transformation should appear in the transform window (see Figure A-6).

Figure A-4. message.xml in xRay2
figs/lxsl_aa04.gif
Figure A-5. message.xsl in xRay2
figs/lxsl_aa05.gif
Figure A-6. Result of transforming message.xml with message.xsl in xRay2
figs/lxsl_aa06.gif


Learning XSLT
Learning XSLT
ISBN: 0596003277
EAN: 2147483647
Year: 2003
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net