几周前,它在我的 SVG 上运行得很好,但不知何故它停止了工作,我不知道原因,因为在服务器上触发的错误没有帮助。当我将 svg 文件传输到 pdf 时会发生这种情况:
Root element namespace does not match that requested:
Requested: http://www.w3.org/2000/svg
Found: null. Stacktrace follows:
org.apache.batik.bridge.BridgeException: Root element namespace does not match that requested:
Requested: http://www.w3.org/2000/svg
Found: null
at org.apache.batik.bridge.BridgeContext.getReferencedNode(BridgeContext.java:780)
at org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext.java:796)
at org.apache.batik.bridge.CSSUtilities.convertClipPath(CSSUtilities.java:719)
at org.apache.batik.bridge.AbstractGraphicsNodeBridge.buildGraphicsNode(AbstractGraphicsNodeBridge.java:146)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:219)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82)
at net.sf.jasperreports.renderers.BatikRenderer.ensureSvg(BatikRenderer.java:192)
at net.sf.jasperreports.renderers.BatikRenderer.getDimension(BatikRenderer.java:141)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1351)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:774)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:738)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:616)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:364)
at com.scacp.operation.MonitoringWellController$_closure13.doCall(MonitoringWellController.groovy:749)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我不明白这是什么意思,我的 xml svg(在 xml 验证器网站上)是有效的代码。我是这样写的:
file.write('<?xml version="1.0" encoding="UTF-8"?> \n'
+ '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> \n'
+ '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="705px" height="1000px" viewBox="0 0 705 1000" enable-background="new 0 0 705 1000" xml:space="preserve"> \n'
+ svgimage + '\n'
+ '</svg>');
变量 svgimage 是一堆g
, defs
, text
, images
等(非常大,比如 1k 行)
我建议这样做,但没有完全理解问题 - 转换为 pdf 是否在某个时刻起作用,然后突然失败。
在文档类型声明中:
w3.org 提到在系统标识符中使用“扁平”DTD,这是单个扁平 DTD,而不是多个文件。
w3.org - SVG NampeSpace、公共标识符和系统标识符: https://www.w3.org/TR/SVG/intro.html#NamespaceAndDTDIdentifiers
“请注意,系统标识符中列出的 DTD 是模块化 DTD(即,其内容分布在多个文件中),这意味着验证器可能必须获取多个模块才能进行验证。因此,有一个扁平化 DTD可用的 DTD 对应于 SVG 1.1 模块化 DTD。可以在以下位置找到:http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat.dtd http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat.dtd."
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)