【问题标题】:Add custom xsi namespace with jsonix使用 jsonix 添加自定义 xsi 命名空间
【发布时间】:2015-10-15 20:37:52
【问题描述】:

如何使用 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">

谢谢!

【问题讨论】:

    标签: javascript json xml jsonix


    【解决方案1】:

    免责声明:我是Jsonix 的作者(嗯,你知道)。

    目前您可以使用attribute propertyany attribute property 来模拟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 映射到架构位置。

    如果您想拥有此功能,请file an issue

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-04
      • 1970-01-01
      • 2015-03-17
      • 1970-01-01
      相关资源
      最近更新 更多