2013-06-22 28 views
0

假设您已经使用JDOM2库构建了XML文档。什么是添加xml样式表来获得类似的API:如何将xml样式表应用到JDOM2文档

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

回答

1

我在周围钓了一段时间才找到正确的方法调用。所以在这里,以防万一有人在看:

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) 
+0

很好,我讨厌钓鱼) – ycomp

相关问题