首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

由xsd 转换 xml解决办法

2012-04-04 
由xsd 转换 xml怎么在转换的xml那里添加 ?xml-stylesheet typetext/xsl hreffoobar.xsl ? 这个?现

由xsd 转换 xml
怎么在转换的xml那里添加 <?xml-stylesheet type='text/xsl' href='foobar.xsl' ?> 这个? 
现在只能转换生成xml其他结点内容, 但这一句怎么加上去呢?



各位大侠帮帮小弟.

[解决办法]
似乎没有直接的函数可以支持,要换个做法:

Java code
StringWriter writer = new StringWriter();//add processing instructions "by hand" with escaped quotation marks//or single markswriter.println("<?xml version='1.0'?>");writer.println("<?xml-stylesheet type=\"text/xsl\" href=\"\">");//create and configure marshaller to leave out processing instructionsMarshaller marshaller = context.createMarshaller();marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);//marshal to the StringWritermarshaller.marshal(someObject,writer);//get the string representation String str = writer.toString(); 

热点排行