“<svg xmlns="http://www.w3.org/2000/svg" viewBox="...
Criado em: 11 de março de 2025
Criado em: 11 de março de 2025
“<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 580">
<!-- Background --> <rect width="800" height="580" fill="white"/> <!-- Blue header bar --> <rect x="0" y="0" width="800" height="70" fill="#1a5c9a"/> <!-- Title --><text x="400" y="45" font-family="Arial, sans-serif" font-size="32" font-weight="bold" text-anchor="middle" fill="white">Building Academic Identity</text>
<!-- Simple icon - just basic shapes --> <circle cx="400" cy="130" r="30" fill="#4682b4"/> <circle cx="340" cy="155" r="25" fill="#1a5c9a"/> <circle cx="460" cy="155" r="25" fill="#1a5c9a"/> <circle cx="375" cy="85" r="22" fill="#1a5c9a"/> <circle cx="425" cy="85" r="22" fill="#1a5c9a"/> <!-- Simple connecting lines --> <line x1="400" y1="130" x2="340" y2="155" stroke="#1a5c9a" stroke-width="3"/> <line x1="400" y1="130" x2="460" y2="155" stroke="#1a5c9a" stroke-width="3"/> <line x1="400" y1="130" x2="375" y2="85" stroke="#1a5c9a" stroke-width="3"/> <line x1="400" y1="130" x2="425" y2="85" stroke="#1a5c9a" stroke-width="3"/> <!-- STEM Fields Section --><text x="150" y="220" font-family="Arial, sans-serif" font-size="26" font-weight="bold" fill="#1a5c9a">STEM Fields:</text>
<text x="170" y="260" font-family="Arial, sans-serif" font-size="22" fill="#333">• Emphasize process verification (过程验证)</text>
<text x="170" y="300" font-family="Arial, sans-serif" font-size="22" fill="#333">• Example verbs: calibrate, simulate, quantify</text>
<text x="150" y="360" font-family="Arial, sans-serif" font-size="26" font-weight="bold" fill="#1a5c9a">HSS Fields:</text>
<text x="170" y="400" font-family="Arial, sans-serif" font-size="22" fill="#333">• Focus on argumentation (论证) & interpretation (解读)</text>
<text x="170" y="440" font-family="Arial, sans-serif" font-size="22" fill="#333">• Example verbs: argue, interpret, contextualize</text>
在不同环境中,有些浏览器或渲染器对 SVG 的支持不一致,导致相同的 SVG 在某些地方(例如某些老旧浏览器、特定的 PDF 引擎或者特定的嵌入场景)会出现排版或文字无法正确显示的问题。常见原因包括:
字体/字符集问题
font-family="Arial, sans-serif"
,在实际渲染时如果操作系统或浏览器缺乏完整的中英文或符号字体支持,就会引发显示异常。嵌入方式或 MIME 类型不正确
<img src="xxx.svg" />
标签嵌入,而一些老旧或特殊的浏览器/引擎本身对 SVG 的支持不完整,可能无法正确识别 viewBox、文字锚点等属性,导致排版错乱或不显示。<svg>…</svg>
内联到 HTML(并确保 MIME 类型为 image/svg+xml
),或者使用 <object>
/ <embed>
方式。浏览器/渲染引擎兼容性
viewBox
、text-anchor
、stroke-width
等),显示效果会被“简化”或错误渲染。编码声明/特殊字符处理
<?xml version="1.0" encoding="UTF-8"?>
声明,或者外部引用的方式被误识别为其他编码,也可能导致中文字符渲染失败。在现代主流浏览器或专业的 SVG/矢量工具里,上述示例代码通常可以正常渲染。但一旦在老旧的环境、嵌入到不同的系统(如部分 PDF 引擎或某些第三方导出工具)里,就可能因为字符集或 SVG 支持不完善而出错。解决的思路通常包括:
image/svg+xml
)。<?xml version="1.0" encoding="UTF-8"?>
,或在 HTML 中以 <meta charset="utf-8">
确保不会因为编码冲突导致中文无法显示。This page contains the following errors:
error on line 31 at column 115: xmlParseEntityRef: no name
这是一个典型的 XML 解析错误,最常见的原因是 原始的 &
符号没有进行转义。在 XML(包括 SVG)中,&
符号具有特殊意义,必须写成 &
才能被正确解析。
在你的代码中,这行容易出错:
xml<text x="170" y="400" ...>• Focus on argumentation (论证) & interpretation (解读)</text>
XML 解析器遇到 & interpretation
时,会把它看成一个无效的实体引用(例如想解析成 & interpretation;
这种,但它并不存在),所以报错:
error on line 31 at column 115: xmlParseEntityRef: no name
解决方法:将所有在文本中出现的 &
符号替换为 &
,例如:
xml<text x="170" y="400" ...> • Focus on argumentation (论证) & interpretation (解读) </text>
这样再去解析或浏览就不会报错了。
同理,如果文本中还包含其他可能触发 XML 解析的符号(如 <
或 >
),在纯文本中也必须转义为 <
、>
等。但在你提供的例子中,最明显的就是那一个 &
。