用XOM编写GraphML?
我试图在java中用XOM写出一个graphML文档,但我无法弄清楚如何使所有的命名空间声明都正确。要拥有有效的graphML,我需要有一个如下所示的根元素:
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
通过这样做,我已经能够完成大部分工作
Element root = new Element("graphml");
root.setNamespaceURI("http://graphml.graphdrawing.org/xmlns");
root.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance");
问题是这个标签的最后一个元素,xsi:schemaLocation
。我无法弄清楚如何在XOM中表达这一点。我不能将它作为普通属性来执行,因为抛出异常(Attribute prefixes must be declared.
)并将其作为附加名称空间声明也会导致异常(NCNames cannot contain colons
)。有任何想法吗?
没有找到相关结果
已邀请:
1 个回复
盛梯獭八搽
属性提供名称空间URI。因此,尝试创建一个没有命名空间的前缀属性,这显然不起作用。
在此处检查正确的Attribute构造函数