Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将xml样式表应用于JDOM2文档_Xml_Xslt_Jdom 2 - Fatal编程技术网

如何将xml样式表应用于JDOM2文档

如何将xml样式表应用于JDOM2文档,xml,xslt,jdom-2,Xml,Xslt,Jdom 2,假设您已经使用JDOM2库构建了XML文档。添加xml样式表以获得以下内容的API是什么: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="test.xsl"?> <root> <node> ... </root> ... 在找到合适的方法调用之前,我已经四处搜寻了一段时间。因此,如果有人也在看: Document doc

假设您已经使用JDOM2库构建了XML文档。添加xml样式表以获得以下内容的API是什么:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<root>
  <node>
...
</root>

...

在找到合适的方法调用之前,我已经四处搜寻了一段时间。因此,如果有人也在看:

Document doc = ...

Map<String, String> m = new HashMap<String, String>(); 
m.put("href", "test.xsl"); 
m.put("type", "text/xsl"); 
doc.addContent(0, new ProcessingInstruction("xml-stylesheet", m)
文档文档=。。。
Map m=新的HashMap();
m、 put(“href”,“test.xsl”);
m、 put(“类型”、“文本/xsl”);
doc.addContent(0,新处理指令(“xml样式表”,m)

太好了,我讨厌钓鱼)