Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设您已经使用 JDOM2 库构建了 XML 文档。什么是添加 xml-stylesheet 以获得类似的 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)