如何将多个 XSD 文件合并为一个 XSD 文件? [英] How to merge more than one XSD file to one XSD file?

查看:41
本文介绍了如何将多个 XSD 文件合并为一个 XSD 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是 XML 和 XSD 的高手.

I am not master in XML and XSD.

只想知道如何将多个 XSD 文件合并为一个 XSD 文件?

Just want to know how I can merge more than one XSD file to one XSD file?

提前致谢.

推荐答案

您可以使用导入(不同的命名空间)和 include(相同的命名空间)多次.redefine 也可以多次使用.这取决于您所说的合并"是什么意思.

You can use import (different namespace) and include (same namespace) multiple times. redefine can also be used multiple times. It depends on what you mean by "merge."

另见 http://www.herongyang.com/XML-Schema/Multiple-XSD-Schema-Document-Include-Redefine-Import.htmlhttp://msdn.microsoft.com/en-us/library/ee254473%28v=bts.10%29.aspx.

重新定义可以多次使用(类似于包含).

redefine can be used multiple times (similar to include).

示例(在 Eclipse 中验证)如下.我在必要时使用了不同的命名空间(作为合并"目标命名空间)和元素名称:

Examples (validated in Eclipse) follow. I used different namespace (as the "merging" target namespace) and element names where necessary:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.org/m"
    xmlns:tns="http://www.example.org/m" elementFormDefault="qualified">

    <!-- import: different (i.e. not target) namespace -->
    <import namespace="http://www.example.org/a" schemaLocation="so20046640a.xsd"/>
    <import namespace="http://www.example.org/b" schemaLocation="so20046640b.xsd"/>

    <!-- include: same namespace -->
    <include schemaLocation="so20046640c.xsd"/>
    <include schemaLocation="so20046640d.xsd"/>

    <!-- redefine: same namespace -->
    <redefine schemaLocation="so20046640e.xsd"/>
    <redefine schemaLocation="so20046640f.xsd"/>
</schema>

...a.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.org/a"
    xmlns:tns="http://www.example.org/a" elementFormDefault="qualified">
    <element name="a" type="int"/>
</schema>

...b.xsd:与...a.xsd 相同,但目标命名空间.../b

...b.xsd: Same as ...a.xsd but target namespace .../b

...c.xsd:与...a.xsd 相同,但目标命名空间.../m

...c.xsd: Same as ...a.xsd but target namespace .../m

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.example.org/m"
    xmlns:tns="http://www.example.org/m" elementFormDefault="qualified">
    <element name="a" type="int"/>
</schema>

...d.xsd:与...c.xsd 相同,但元素名称为 b.

...d.xsd: Same as ...c.xsd but element name b.

...e.xsd:与 ...c.xsd 相同,但元素名称为 e.

...e.xsd: Same as ...c.xsd but element name e.

...f.xsd:与 ...c.xsd 相同,但元素名称为 f.

...f.xsd: Same as ...c.xsd but element name f.

这篇关于如何将多个 XSD 文件合并为一个 XSD 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆