Use Java XSLT conversion in XMLSPY

zhaozj2021-02-11  171

Use Java XSLT conversion in XMLSPY.

I like to write XML, XSL, XSD in xmlspy, and use xmlspy to view the XSLT conversion results or use MSXML to view the XSLT conversion results. It is found in actual use, although XMLSPY's XSLT has some small bugs, but it provides specific errors. Location, tired is very convenient. Java

There are Xalan and Saxon to do XSLT conversion.

In addition to supporting standard XSLT1.0, SAXON also supports XSLT2, where multi-document output is especially useful. Download address: saxon.sf.net. After decompression, configure it in XMLSPY: Java-Jar C: / Java / lib / saxon7 -3-1 / saxon7.jar -O% 2% 1% 3

Xalan has been built in JDK1.4, but does not provide command line call mode, here is simple packaging as follows:

Import javax.xml.transform. *;

/ ** * Command line xslt using jdk1.4 *

Title: *

description: *

Copyright: CopyRight (C) 2003 *

Company: * @Author not attributable * @version 1.0 * /

Public class xslt {private static final string usage = "xslt 1.0: command line xslt for jdk1.4 / n / n" "Command Line usage: java -jar xslt.jar XMLFILE XSLFILE OUTFILE / N" "XMLSPY EXTERAL XSLT SETUP : java -jar c: //java//lib//xslt.jar% 1% 3% 2 / N ";

Public xslt () {}

Public Static Void Transform (Source XML, Source XSL, Javax.xml.Transform.Result out) throws exception {transformerfactory.newinstance (). NewTransformer (XSL) .transform (XML, OUT);}

Public static void main (string [] args) {if (args.length <2) {system.out.println (usage); return;} Source XML = new javax.xml.transform.Stream.StreamSource (args [0] ); Source xsl = new javax.xml.transform.Stream.StreamSource (args [1]); result out = null; if (args.length> 2) OUT = New javax.xml.transform.Stream.StreamResult (args [ 2]); else out = new javax.xml.transform.Stream.StreamResult (System.out); try {transform (XML, XSL, OUT);} catch (Exception E) {system.out.println ("Error: E.getMessage ());}}

}

It is recommended to pack Xslt.jar with JBuilder's Jar Builder Wizard. XMLSPY is configured as follows: java -jar c: /java/lib/xslt.jar% 1% 3% 2 is on the running speed, the difference is not big, still full of:)

转载请注明原文地址:https://www.9cbs.com/read-5852.html

New Post(0)