怎么在转换的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();