Connecting Tech Pros Worldwide Help | Site Map

XSD: Require One Element with a specific Attribute value

Adam dR.
Guest
 
Posts: n/a
#1: Nov 2 '08
I would like to create an XSD that will verify the xml below has one
<configelement with the name attribute equal to 'DBC' all other
<configelements are optional and their values don't matter. I
cannot restrict other <configelements from being there. Is this
possible with XSD? If so could someone help me with an example?

<-- This should be VALID be cause it has one and only one config
element with name 'DBC' --/>
<project>
<config name='DBC' output='myprogram.exe'>
<file>myfile.dbr</file>
</config>
<config name='Make' output='myprog.exe'>
<file>myfile2.dbr</file>
</config>
</project>

<-- This should be VALID be cause it has one and only one config
element with name 'DBC' --/>
<project>
<config name='DBC' output='myprogram.exe'>
<file>myfile.dbr</file>
</config>
</project>

<-- This should be INVALID be cause it does not have a config element
with name 'DBC' --/>
<project>
<config name='comp.bat' output='myprogram.exe'>
<file>myfile.dbr</file>
</config>
<config name='Make' output='myprog.exe'>
<file>myfile2.dbr</file>
</config>
</project>

Closed Thread


Similar .NET Framework bytes