2014-08-30 54 views
0

我正在開發可通過XML進行配置並可通過PowerShell模塊進行擴展的構建工具。我有一個XSD(http://download.crawler-lib.net/BuildTools/BuildConfig.xsd),它描述了開箱即用功能。一個擴展點是構建序列的工具:擴展XML模式xs:選擇

<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模塊定義名爲「WZ」一個生成步驟工具延伸此。所以在XML配置有可能是這應該是在像選擇列表中的其他有效的元素:

<xs:element ref="custom:MyTool"/> 

如何延長使用一個額外的(custom.xsd)XSD文件這樣一個定義?爲了讓自定義元素在Visual Studio中獲得IntelliSense?

回答

0

考慮使用替代組。如果您的內容模型允許元素E,那麼它也允許E的替代組中的任何元素;任何人都可以創建這樣的元素(除非你阻止它),並且它可以自動變爲可用,而無需更改您的內容模型。

+0

謝謝你的回答。看起來是一個很好的解決方案,但我不熟悉替代組的概念。你知道一個好的起點來學習它嗎?問候湯姆 – 2014-08-31 13:01:01

+0

普里西拉瓦姆斯利的書是優秀的。 – 2014-08-31 17:46:27

+0

謝謝你的提示。 – 2014-08-31 22:22:49