0
我在Transformer transformer = tFactory.newTransformer(StreamXSL);
上收到異常,但下面的錯誤不是顯式的,我不明白爲什麼「無法編譯樣式表」?Java:XML/XSL Transformer如何獲取有關錯誤的更多信息?
韓國社交協會
static String getHtml(String xml)
{
Element elementObj = getElementObject(xml);
String xslName = getValueOfElement(elementObj, xml, "XSL_TO_RUN");
StreamSource StreamXML = new StreamSource(new StringReader(xml));
try{
TransformerFactory tFactory = TransformerFactory.newInstance();
if(xslName!=null){
String xslfile = xslName;
File xfile = new File(xslfile);
if (xfile.exists()){}
else
{
LogI.log(4,"getHtml:: ERROR: xsl file don´t Exist! " + xslName);
return null;
}
StreamSource StreamXSL = new StreamSource(xfile);
Transformer transformer = tFactory.newTransformer(StreamXSL);
}else{
LogI.log(0,"getHtml::ERROR->Error on create stream XSL");
return null;
}
} catch(TransformerConfigurationException ex){
LogI.log(0,"getHtml::Erro crossing the XML with the XSL:" + ex);
LogI.log(0,"getHtml::Erro crossing the XML with the XSL(1):" + ex.getMessageAndLocation());
LogI.log(0,"getHtml::Erro crossing the XML with the XSL(2):" + ex.getMessage());
for(int i=0;i<ex.getStackTrace().length;i++){
LogI.log(0, "ARQ::Pedido:: ERRO(2) ->" + ex.getStackTrace()[i]);
}
return null;
} catch(Exception e){
LogI.log(0,"getHtml::Erro crossing the XML with the XSL:" + e);
//out.clear();
//out.println(errorPage);
return null;
}
}
這裏是輸出:
ERRO: getHtml::Erro crossing the XML with the XSL:javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
ERRO: getHtml::Erro crossing the XML with the XSL(1):Could not compile stylesheet
ERRO: getHtml::Erro crossing the XML with the XSL(2):Could not compile stylesheet
ERRO: ARQ::Pedido:: ERRO(2) ->com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
ERRO: ARQ::Pedido:: ERRO(2) ->com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
ERRO: ARQ::Pedido:: ERRO(2) ->BizBanc.Arq.getHtml(Arq.java:189)
ERRO: ARQ::Pedido:: ERRO(2) ->BizBanc.Arq.getResponse(Arq.java:792)
xsl是好的,因爲在沒有錯誤的tomcat環境中使用。 .. – Reversed 2010-03-15 16:48:21
你是對的我的xsl有重複的字段! 感謝您的幫助! – Reversed 2010-03-18 18:19:46