您的位置:程序门 -> java -> web services / xml



xmlbeans 输出xml文本的格式问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


xmlbeans 输出xml文本的格式问题
发表于:2008-01-13 01:30:07 楼主
使用过xmlbeans的朋友:  

在调用xxxtype.tostring   或   xxxtype.xmltext()的时候,生成的xml包含了uri等信息,如下所示:  
<inputfield   name="troubledescription"   getfunction="gettroubledescription"   xmlns="http://hp.com/ism/ovsc/jsr91/fm/objectmapping"   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"/>  

我想要的效果应该是不包括uri的:  
<inputfield   name="troubledescription"   getfunction="gettroubledescription">  

请问该如何调整输出xml的格式?   thx   so   much  
发表于:2008-01-13 01:36:391楼 得分:0
用string   xmltext(xmloptions   options)
just   like   xmltext()   but   with   options.   options   map   may   be   null.  
note   that   this   method   does   not   produce   xml   with   the   xml   declaration,   including   the   encoding   information.  


  xmloptions   opts   =   new   xmloptions();
  opts.setsaveprettyprint();
  opts.setsaveprettyprintindent(4);
  system.out.println(xobj.xmltext(opts));

  the   alternative   is   single-line   usage:  
  system.out.println(xobj.xmltext(new   xmloptions().setsaveprettyprint().setsaveprettyprintindent(4)));
发表于:2008-01-13 15:27:152楼 得分:0
楼上的兄弟,谢谢你的回复。但这个方法发帖前我已经试验过了,没有作用,不知道是为什么,输出的时候还是带:xmlns="http://hp.com/ism/ovsc/jsr91/fm/objectmapping"   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"

我曾经还专门写了函数来封装xmloptions操作:

public   string   getxmltext(xmlobject   xmlobj)
        {
                if(xmlobj==null)   return   null;
               
                xmloptions   options   =   new   xmloptions();
                options.setcharacterencoding("utf-8");
                options.setsaveouter();
                options.setsaveprettyprint();
                options.setsaveprettyprintindent(2);
               
                return   xmlobj.xmltext(options);
               
        }

调用如下所示:xxservice.getxmltext(mf.getfunctionparameter());

是否还需要某些配置才能打开xmloptions的过滤功能吗?
发表于:2008-01-14 22:33:173楼 得分:0
  自己再顶一下。。。


快速检索

最新资讯
热门点击