日期:2014-05-20  浏览次数:20680 次

一个非常奇怪的问题,请教各位!
我有一个Document对象doc,我想应用样式表转换输出,可是运行以后就报
XML-22101:   (Fatal   Error)   DOMSource   node   as   this   type   not   supported.
这个错误,真搞不懂怎么回事了,奇怪的是,前天我还运行好好的,从昨天不知就怎么回事出错误了,我还以为是我改动了什么,可是我把以前的代码调出来还是运行错误,拜托各位高手帮帮忙,我都弄了两天了,还是解决不了,下面是转换代码
Source   source   =   new   DOMSource(   doc);
File   xsltFile   =   new   File(   xsltFileName   );
StreamSource   xsltSource   =   new   StreamSource(   xsltFile   );
File   outFile   =   new   File(   outFileName   );
Result   result   =   new   StreamResult(   outFile   );
TransformerFactory   tff   =   TransformerFactory.newInstance();
Transformer   trans   =   tff.newTransformer(xsltSource);
trans.transform(source,   result);

------解决方案--------------------
文件的格式有问题吧。你看看报错~
------解决方案--------------------
问题应该不在这段代码,你的xlst文件和xml文件有没有动过?
------解决方案--------------------
问题在于你的xml文件,错误写的很明白了,虽然你很确定xml文件没有错误,但是还建议你换一个看看,或者将这个xml文件的结点去掉几个看看

不支持这个类型的DOMSource结点.