Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSD: Require One Element with a specific Attribute value

From: "Adam dR." <MeowCow@-----.--->
To: NULL
Date: 11/2/2008 8:01:00 AM
I would like to create an XSD that will verify the xml below has one
<config> element with the name  attribute equal to 'DBC'  all other
<config> elements are optional and their values don't matter.  I
cannot restrict other <config> elements 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>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent