[英]Allow any attribute with a defined prefix
I'm working on OFMX, an XML exchange format based on AIXM.我正在研究 OFMX,一种基于 AIXM 的 XML 交换格式。 The schema validates the publicly available files correctly, however, when OFMX is used internally, a number of attributes are inuse which are not part of the schema.该架构正确地验证了公开可用的文件,但是,当 OFMX 在内部使用时,许多不属于该架构的属性都在使用中。
Here's a simple valid OFMX file:这是一个简单有效的 OFMX 文件:
<?xml version="1.0" encoding="UTF-8"?>
<OFMX-Snapshot xmlns:xsi="http://schema.openflightmaps.org/0/OFMX-Snapshot.xsd" version="0" origin="rubygem aixm-0.3.9" namespace="daf19610-f43b-4db3-80b7-602d9083dc32" created="2020-03-03T10:25:18+01:00" effective="2020-02-27T00:00:00+01:00">
<Ahp source="LF|AD|AD-2.LFBA|2020-02-27|17">
<AhpUid region="LF">
<codeId>LFBA</codeId>
</AhpUid>
<OrgUid region="LF">
<txtName>FRANCE</txtName>
</OrgUid>
<txtName>AGEN LA GARENNE</txtName>
<codeIcao>LFBA</codeIcao>
<codeType>AD</codeType>
<geoLat>44.17472222N</geoLat>
<geoLong>000.59055556E</geoLong>
<codeDatum>WGE</codeDatum>
<valElev>204</valElev>
<uomDistVer>FT</uomDistVer>
<valMagVar>0.0</valMagVar>
</Ahp>
</OFMX-Snapshot>
In order to speed things up, non-public (local) processing might add attributes such as dbid
:为了加快速度,非公开(本地)处理可能会添加属性,例如dbid
:
<Ahp source="LF|AD|AD-2.LFBA|2020-02-27|17" dbid="1234">
I don't want to pollute the schema with such non-public attribute definitions and therefore I'm looking for a minimally invasive way to allow them.我不想用这种非公共属性定义污染模式,因此我正在寻找一种微创方式来允许它们。
Allowing any attribute with say a prefixed underscore like _dbid
would be a solution, but AFAIK, it's not possible to define wildcard attributes in the schema.允许任何带有前缀下划线的属性,例如_dbid
将是一个解决方案,但 AFAIK,不可能在架构中定义通配符属性。
Is there an alternative eg a local namespace like local:dbid
maybe together with anyAttribute
with as few modifications on the root element as possible?是否有替代方法,例如像local:dbid
这样的本地命名空间,可以与anyAttribute
一起使用,并对根元素进行尽可能少的修改?
The proper way to do this in XML is to put the attribute in a namespace, writing it as db:id="1234"
with a namespace declaration for the db
prefix.在 XML 中执行此操作的正确方法是将属性放在命名空间中,将其写为db:id="1234"
并带有db
前缀的命名空间声明。
The schema can then be written to permit either (a) any attribute in a specific namespace, or (b) any attribute in any namespace using an xs:anyAttribute
wildcard with an appropriate namespace
attribute, eg namespace="##other"
.然后可以编写架构以允许 (a) 特定命名空间中的任何属性,或 (b) 任何命名空间中的任何属性,使用xs:anyAttribute
通配符和适当的namespace
属性,例如namespace="##other"
。
If you want to make all your element declarations extensible in this way, the usual way is to derive all the element types by restriction from a type that contains the wildcard.如果要以这种方式使所有元素声明都可扩展,通常的方法是通过限制从包含通配符的类型派生所有元素类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.