SVG Batik根元素命名空间与请求的不匹配 [英] SVG Batik Root element namespace does not match that requested

查看:607
本文介绍了SVG Batik根元素命名空间与请求的不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周以前,它完全正常工作我的SVG,但它不知何故停止工作,我不知道原因,因为在服务器上触发的错误没有帮助。当我将svg文件传输到我的pdf时会发生这种情况:

Few weeks ago, it was working PERFECTLY my SVG, but somehow it stopped working and I don't know the cause because the error fired on the server wasn't helpful. It happens when I transfer the svg file to my 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验证器上)网站)是有效的代码。我写的是这样的:

I don't what it means, my xml svg(on xml validator website) is valid code. I'm writing like this:

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行一样)

The variable svgimage is a bunch of g, defs, text, images, etc (really big, like 1k of lines)

推荐答案

我有很多工作要找到xml上+ 1k行的原因这是svg创建的标签,w3无法识别,这是 clipPath clip-path 并删除它们,完美运作:

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>

不知何故,w3没有识别 url(...)只需删除它,它就可以了。而且很奇怪,它总是在那里。

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

这篇关于SVG Batik根元素命名空间与请求的不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆