JDOM生成的xml文件,content结点下的html标签都是正确的,经过xsl转换后就出现问题拉,所有的都变成了< 和 > 啦,请高手帮忙看看,问题在哪里...
xml文档如下:
<?xml version="1.0" encoding="GB2312"?>
abc]]>
xsl文档如下:
<?xml version="1.0" encoding="UTF-8"?>
java代码:
//doc 为xml
public String DocTrans(String xslPath) {
XSLTransformer transformer = null;
Document HTMLdoc = null;
try {
transformer = new XSLTransformer(xslPath);
HTMLdoc = transformer.transform(doc);
}
catch (XSLTransformException ex) {
System.out.println("XSLTransformException @ tearar.control.XMLoperate.DocTrans is error:"+ex);
}
if (!HTMLdoc.hasRootElement()) {
return "";
}
XMLOutputter XMLOut = new XMLOutputter(getFormat());
return XMLOut.outputString(HTMLdoc);
}
转换后content中的字符就变成:
<P><font color=red>abc</font></P>
xml文档如下:
<?xml version="1.0" encoding="GB2312"?>
abc]]>
xsl文档如下:
<?xml version="1.0" encoding="UTF-8"?>
java代码:
//doc 为xml
public String DocTrans(String xslPath) {
XSLTransformer transformer = null;
Document HTMLdoc = null;
try {
transformer = new XSLTransformer(xslPath);
HTMLdoc = transformer.transform(doc);
}
catch (XSLTransformException ex) {
System.out.println("XSLTransformException @ tearar.control.XMLoperate.DocTrans is error:"+ex);
}
if (!HTMLdoc.hasRootElement()) {
return "";
}
XMLOutputter XMLOut = new XMLOutputter(getFormat());
return XMLOut.outputString(HTMLdoc);
}
转换后content中的字符就变成:
<P><font color=red>abc</font></P>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7483566/viewspace-159341/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7483566/viewspace-159341/