刚刚接触xquery,现在需要用一个org.w3c.Document对象来构造一个XQSequence对象,最后将XQSequence对象输出xml文档,按照XQJ和Saxon的帮助文档,使用XQSequence seq=new SaxonXQDataSource().getConnection().createSequence(iterator it)方法,如下: org.w3c.Document w3cdoc=.....;
//确定了w3c不为空
ArrayList items=new ArrayList();
items.add(new Integer(1));
items.add(w3cdoc);
items.add(new Integer(2));
XQSequence result=new SaxonXQDataSource().getConnection().createSequence(items.iterator);
if(result!=null)
{
this.filename=fname;
Properties pro=new Properties();
pro.setProperty("method", "xml");
pro.setProperty("indent", "yes");
try{
BufferedOutputStream fos=new BufferedOutputStream(new FileOutputStream(fname));
result.writeSequence(fos, pro);
fos.flush();
fos.close();
}
catch(Exception e){e.printStackTrace();}
}
但是结果输出的xml文档为:
<?xml version="1.0" encoding="UTF-8"?>1
结果分析:无法将w3cdoc的内容输出,并且其后面的2也没有输出。请教各位大虾,这是什么原因?
//确定了w3c不为空
ArrayList items=new ArrayList();
items.add(new Integer(1));
items.add(w3cdoc);
items.add(new Integer(2));
XQSequence result=new SaxonXQDataSource().getConnection().createSequence(items.iterator);
if(result!=null)
{
this.filename=fname;
Properties pro=new Properties();
pro.setProperty("method", "xml");
pro.setProperty("indent", "yes");
try{
BufferedOutputStream fos=new BufferedOutputStream(new FileOutputStream(fname));
result.writeSequence(fos, pro);
fos.flush();
fos.close();
}
catch(Exception e){e.printStackTrace();}
}
但是结果输出的xml文档为:
<?xml version="1.0" encoding="UTF-8"?>1
结果分析:无法将w3cdoc的内容输出,并且其后面的2也没有输出。请教各位大虾,这是什么原因?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货