【发布时间】:2013-09-06 00:12:30
【问题描述】:
我正在尝试按照本文将 SVG 文件转换为 XSL 样式表:http://www.linuxjournal.com/article/9283?page=0,0
我尝试简单地构造一个新文档,其中插入了 XSL 相关元素之间的 svg 数据,但是当我执行包含此代码的方法时:
Document input=builder.build(sourcefile);
Element styletags=new Element("xsl:stylesheet",
"http://www.w3.org/1999/XSL/Transform");
styletags.appendChild(new Element("xsl:template%20match=\"/\""));
styletags.appendChild(input);
Document result=new Document(styletags);
我得到以下异常:
nu.xom.NamespaceConflictException:前缀元素必须具有命名空间 URI。
如果我尝试使用以下代码
Element xsl=new Element("template%20match=\"/\"");
xsl.addNamespaceDeclaration("xsl","http://www.w3.org/1999/XSL/Transform");
Element styletags=new Element("stylesheet");
styletags.addNamespaceDeclaration("xsl","http://www.w3.org/1999/XSL/Transform");
styletags.appendChild(xsl);
styletags.appendChild(input);
我明白了
nu.xom.IllegalNameException: 0x25 不是合法的 NCName 字符
我做错了什么?
【问题讨论】: