Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   unique attribute value (http://www.velocityreviews.com/forums/t735203-unique-attribute-value.html)

kanpeter 10-11-2010 01:40 PM

unique attribute value
 
Hi,

How can I declare the xsd such that an element Fare will have an
attribute of name "type" and each value of "type" can occur at most
once?



<Fare type="faretype1"/>
<Fare type="faretype2"/>

is valid in XML but not

<Fare type="faretype1"/>
<Fare type="faretype1"/>

Martin Honnen 10-11-2010 01:48 PM

Re: unique attribute value
 
kanpeter wrote:

> How can I declare the xsd such that an element Fare will have an
> attribute of name "type" and each value of "type" can occur at most
> once?
>
>
>
> <Fare type="faretype1"/>
> <Fare type="faretype2"/>
>
> is valid in XML but not
>
> <Fare type="faretype1"/>
> <Fare type="faretype1"/>



In the definition of the parent element of those "Fare" elements use
<xs:unique name="unique-fare-type">
<xs:selector xpath="Fare"/>
<xs:field xpath="@type"/>
</xs:unique>
See http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness
--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/


All times are GMT. The time now is 01:04 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.