0

入力ファイルと出力ファイルを、別の main メソッドを使用してこのプログラムに渡すことができるようにしたいと考えています。私の意図は、GUI を介してこれにアクセスすることです。

public class SimpleTransform {
    public static void main(String[] args) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException {  
        // Use the static TransformerFactory.newInstance() method to instantiate 
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer(new StreamSource("demiprocess.xsl")); 
        transformer.transform(new StreamSource("Anzer.xml"), new StreamResult(new FileOutputStream("lee.xml")));
        System.out.println("*The result is in birds.out ***");
    }
}

これは私が試したものですが、エラーが発生し続けます:

public class Simple {
    private String xmlFile ;
    private String xslFile;
    private String  outputFile;


    /**
     * Constructor for objects of class Simple
     */
    public Simple(String xmlFile, String xslFile,String outputFile) {
        this.xmlFile = xmlFile;
        this.xslFile = xslFile;
        this.outputFile= outputFile;
    }

    public String SimpleTransform() throws TransformerException,TransformerConfigurationException,FileNotFoundException, IOException {
        String mystring = "";
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
        transformer.transform(new StreamSource(xmlFile), new StreamResult(new FileOutputStream(outputFile)));
        return mystring = "***The result is in birds.out *****";
    } 
}

「file:///C:/Users/Abiodun/Desktop/New%20system/new%20system/demiprocess.xsl; Line #1; Column #10; stylesheet requires attribute: version」というエラーが表示されます

4

1 に答える 1

0

XSL ファイル宣言に version 属性がないようです。これに似たものから始まりますか?

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
于 2012-08-23T19:58:45.513 に答える