java - XSLT 无法将样式表附加到 XML
问题描述
Element root = document.createElement("urlset");
document.setXmlStandalone(true);
document.appendChild(root);
root.setAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
root.setAttribute("xmlns:xhtml", "http://www.w3.org/1999/xhtml");
org.w3c.dom.ProcessingInstruction pi = document.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"C:\\\\CanonWebApp\\\\utility\\\\sitemap.xslt encoding=\\\"utf-8\"");
document.insertBefore((Node) pi, root);
document.setXmlStandalone(true);
我正在使用处理指令向我的 xml 添加样式表。我已将样式表保存在本地,但仍然出现如下屏幕截图所示的错误:
“此 XML 文件似乎没有与之关联的任何样式信息。文档树如下所示。”
解决方案
推荐阅读
- android - Android APK 安装“包安装程序已停止”
- python - win32 excel复制除功能
- rest - 对 github 的 api 的类似请求的不同结果
- javascript - 如何在不同的编程语言之间进行通信?
- angular - (Angular 2/4/5/6)具有多个 http 请求的嵌套订阅方法
- c++ - C++ 更改每个 boost::dynamic_bitset 块的位
- math - 概率分布
- javascript - 如何将一串句子分成两半,分成两个字符串的数组,每个字符串的长度尽可能相似?
- javascript - 客户端 onTextChanged
- java - 如何在 Java 中使用 opencv 或 ffmpeg 在网络摄像头流上覆盖视频