SVG Batik根元素命名空间与请求的不匹配

fsi*_*fsi 7 xml svg jasper-reports

几个星期前,它完全正常工作我的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)
Run Code Online (Sandbox Code Playgroud)

我不是这意味着什么,我的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>');
Run Code Online (Sandbox Code Playgroud)

变量SVGImage的是一堆的g,defs,text,images,等(真大,像线1K)

fsi*_*fsi 0

I had a lot of work to find the cause over +1k of lines on my xml and It's a tag that svg created and w3 didn't recognized, which is clipPath and clip-path and by removing them, works perfectly:

<clipPath id="_ABSTRACT_RENDERER_ID_0"> //removed
...
</clipPath>

<g clip-path="url(http://mypage.com/344#_ABSTRACT_RENDERER_ID_0)"> //remove the attribute clip-path
...
</g>
Run Code Online (Sandbox Code Playgroud)

Somehow, the w3 didnt recognized the url(...) by simply removing this, it works. And It's strange, it was always there.