如何使用jsonix将自定义xsi命名空间添加到XML文件中?我们希望实现以下目标:
<network xsi:schemaLocation="http://example.com/XMLSchema ../../../Example/schema/Example.xsd">我们能得到的最好结果是使用命名空间前缀:
<network xmlns:schemaLocation="http://example.com/XMLSchema ../../../Example/schema/Example.xsd">谢谢!
发布于 2015-10-16 20:06:54
免责声明:,我是Jsonix的作者(你知道)。
目前,您可以使用属性属性或任何属性来建模xsi:schemaLocation,比如:
{
type: 'attribute',
name: 'schemaLocation',
attributeName : { localPart: 'schemaLocation', namespaceURI : 'http://www.w3.org/2001/XMLSchema-instance' }
typeInfo: 'String'
}基本上,就像其他任何正常属性一样。
但是,我认为xsi:schemaLocation应该在Jsonix.Context级别上得到支持。这个目前不支持,但我认为它应该是这样的:
var context = new Jsonix.Context(mappings, {
schemaLocations: {
"http://example.com/XMLSchema": "../../../Example/schema/Example.xsd"
}
});类似于namespacePrefixes,但是将命名空间URI映射到模式位置。
如果您想拥有这个功能,请提出问题。
https://stackoverflow.com/questions/33158106
复制相似问题