【问题标题】:combine 2 schemas in 1 XML file在 1 个 XML 文件中组合 2 个模式
【发布时间】:2017-10-20 06:14:16
【问题描述】:

我需要在 ONE XML 文档中获得来自 mods 架构的描述性信息和来自 PBCore 架构的技术信息。但是,无论我按什么顺序排列,我的 XML 编辑器中都会出现格式良好的错误。 我在 XML 文档的顶部有这个序言:

<?xml version='1.0' encoding='UTF-8'?>
<mods:modsCollection xmlns:mods="http://www.loc.gov/mods/v3"
    xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.loc.gov/mods/v3 
http://www.loc.gov/standards/mods/v3/mods-3-6.xsd">

稍后在我的 XML 文档中:

<pbcoreCollection xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html 
http://pbcore.org/xsd/pbcore-2.0.xsd">

我错过了什么?

【问题讨论】:

    标签: xml schema


    【解决方案1】:

    这里是一个示例文档,展示了这一点:

    <?xml version="1.0" encoding="UTF-8"?>
    <mods:modsCollection xmlns:mods="http://www.loc.gov/mods/v3"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.loc.gov/mods/v3
                          http://www.loc.gov/standards/mods/v3/mods-3-6.xsd">
      <mods:mods>
        <mods:extension>
          <pbcoreCollection
            xmlns="http://www.pbcore.org/PBCore/PBCoreNamespace.html"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.pbcore.org/PBCore/PBCoreNamespace.html
                                http://pbcore.org/xsd/pbcore-2.0.xsd">
            <pbcoreDescriptionDocument>
              <pbcoreIdentifier source="NOLA Code">AMEX000102</pbcoreIdentifier>
              <pbcoreTitle>American Experience: Radio Bikini</pbcoreTitle>
              <pbcoreDescription>In July 1946, the U.S. Navy...
                        later.</pbcoreDescription>
            </pbcoreDescriptionDocument>
          </pbcoreCollection>
        </mods:extension>
      </mods:mods>
    </mods:modsCollection>
    

    诀窍是确保您可以在父架构允许的位置插入其他架构内容。基本上,查看 XSD 文件中可以包含 mixed="true" 内容的元素:

    http://www.loc.gov/standards/mods/v3/mods-3-6.xsd

    【讨论】:

    • 谢谢!这非常非常有帮助。
    • 我现在真正需要知道的是如何创建 XSLT,它将两个不同 XML 文档的元数据合并为一个,将您的示例中的信息合并在一起。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-21
    • 1970-01-01
    • 2013-06-08
    • 2021-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多