将元数据添加到XSD定义 [英] Add metadata to an XSD definition

查看:118
本文介绍了将元数据添加到XSD定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是所有人都对XSD熟悉,我想知道是否可以执行以下操作:

Not all that familiar with XSD, I wonder if it is possible to do the following:

<xs:group name="SomeGroup">
    <xs:sequence>
        <xs:element name="Groupingcode" type="OurType" origin="DB" />
        <xs:element name="Description" type="StringType" origin="XML" />

说明:我有一个XSD架构文件.我需要根据包含数据库数据的XSD(这部分工作正常)生成XML文件.但是,某些元素需要其他数据才能找到从数据库中获取的正确字段.这就是 origin 标记所在的位置.它使我可以在XSD中描述在哪里寻找数据.标记不必出现在生成的XML中,但是如果可能的话,可以使用相同的XSD来验证生成的XML. 我知道,另一种方式是使用单独的XML文件来描述这一点.但是我想知道是否完全可以在我的XSD中做到这一点.

To explain: I have an XSD schema file. I need to generate an XML file according to the XSD (this part works fine) containing database data. However, some elements need additional data to be able to find the proper field to get from the database. That's where the origin tag would come in. It would allow me to describe in the XSD where to look for the data. The tag need not be present in the generated XML, but if possible that same XSD would be used to validate the generated XML. Another way would be to use a separate XML file to describe this, I know. But I would like to know if it would at all be possible to do this in my XSD.

以上片段将生成以下XML:

The above fragment would generate to the following XML:

<SomeGroup>
    <Groupingcode>None</Groupingcode>
    <Description>This item does not belong to any group.</Description>

希望这是有道理的.

推荐答案

直接前进.只需将您的额外属性放到您自己的名称空间中,然后创建一个定义它们的架构即可. Microsoft对创建数据集时生成的.XSD文件执行此操作.

Go right ahead. Just put your extra attributes into a namespace of your own, and create a schema that defines them. Microsoft does this for the .XSD files generated when you create a DataSet.

这篇关于将元数据添加到XSD定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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