DuHarTapt
27-01-2009, 14:23
Ho un po' di problemi nel convertire un file .docx in un file xml utilizzando un xslt, in JAVA.
In java ho fatto il metodo seguente
public void conversione(String inputFile, String outputFile,String xsltPath) throws TransformerConfigurationException
{
File xmlFile = new File(inputFile);
File xsltFile = new File(xsltPath);
Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact = TransformerFactory.newInstance();
javax.xml.transform.Transformer trans = transFact.newTransformer(xsltSource);
try
{
trans.transform(xmlSource, new StreamResult(outputFile));
}
catch( TransformerException t){System.out.println(t);}
}
Questo mi restituisce l'eccezione javax.xml.transform.TransformerConfigurationException: Impossibile compilare il foglio di stile ERRORE. 'Errore durante la verifica del tipo di espressione 'funcall(doc, [step("self", -1)])'.'
La riga del file xslt corrispondente è:
<xsl:variable name="doc-ur-ex" select="lower-case(string(tokenize(document-uri(.), '\.')[last()]))"/>
E' sbagliato il metodo java, c'è un errore nel xslt o altro?
In java ho fatto il metodo seguente
public void conversione(String inputFile, String outputFile,String xsltPath) throws TransformerConfigurationException
{
File xmlFile = new File(inputFile);
File xsltFile = new File(xsltPath);
Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact = TransformerFactory.newInstance();
javax.xml.transform.Transformer trans = transFact.newTransformer(xsltSource);
try
{
trans.transform(xmlSource, new StreamResult(outputFile));
}
catch( TransformerException t){System.out.println(t);}
}
Questo mi restituisce l'eccezione javax.xml.transform.TransformerConfigurationException: Impossibile compilare il foglio di stile ERRORE. 'Errore durante la verifica del tipo di espressione 'funcall(doc, [step("self", -1)])'.'
La riga del file xslt corrispondente è:
<xsl:variable name="doc-ur-ex" select="lower-case(string(tokenize(document-uri(.), '\.')[last()]))"/>
E' sbagliato il metodo java, c'è un errore nel xslt o altro?