扩展XML模式xs:choice [英] Extending XML Schema xs:choice
问题描述
我正在开发可通过XML配置并可以通过PowerShell模块扩展的构建工具.我有一个XSD( http://download.crawler-lib.net/BuildTools/BuildConfig. xsd ),它描述了开箱即用的功能.一个扩展点是构建序列的工具:
I'm developing build tools that are configurable via XML and extendable with PowerShell modules. I have an XSD (http://download.crawler-lib.net/BuildTools/BuildConfig.xsd) which describes the out of the box functionality. One extension point are the tools of the build sequences:
<xs:element name="BuildSequence">
<xs:annotation>
<xs:documentation>Performs a sequence of build tools to build the solution</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element ref="bt:AppendText"/>
<xs:element ref="bt:Autover"/>
<xs:element ref="bt:Call"/>
<xs:element ref="bt:CopyFile"/>
<xs:element ref="bt:Download"/>
<xs:element ref="bt:DumpContext"/>
<xs:element ref="bt:FxCop"/>
<xs:element ref="bt:IntelliLock"/>
<xs:element ref="bt:MSBuild"/>
<xs:element ref="bt:NuGetPack"/>
<xs:element ref="bt:NuGetPush"/>
<xs:element ref="bt:NUnit"/>
<xs:element ref="bt:NuSpecUpdate"/>
<xs:element ref="bt:Powershell"/>
<xs:element ref="bt:RemoveFile"/>
<xs:element ref="bt:Upload"/>
<xs:element ref="bt:VerifyFile"/>
<xs:element ref="bt:Xslt"/>
<xs:element ref="bt:Zip"/>
</xs:choice>
<xs:attribute name="Name" type="xs:string" use="required"/>
<xs:attribute name="NewBuild" type="bt:boolean" use="optional"/>
</xs:complexType>
</xs:element>
有人可以使用附加的PowerShell模块扩展此功能,该模块定义一个名为"MyTool"的构建步骤工具.因此,在XML配置中,可能还有另一个有效元素,应该在选项列表中,例如:
Someone may extend this with an additional PowerShell module defining a build step tool named "MyTool". So in the XML config there may be another valid element which should be in the list of choices like:
<xs:element ref="custom:MyTool"/>
如何使用附加的(custom.xsd)XSD文件扩展此类定义?这样我就可以在Visual Studio中为自定义元素获取IntelliSense?
How can I extend such a definition with an additional (custom.xsd) XSD file? So that I get IntelliSense in Visual Studio for the custom element?
推荐答案
考虑使用替代组.如果您的内容模型允许元素E,则它还允许E替换组中的任何元素;否则,它不支持元素E.任何人都可以创建这样的元素(除非您将其阻止),并且该元素会自动变为可用,而无需更改您的内容模型.
Consider using substitution groups. If your content model allows element E, then it also allows any element that is in the substitution group of E; anyone can create such an element (unless you block it), and it automatically becomes available without having to change your content model.
这篇关于扩展XML模式xs:choice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!