[xsd-users] Defining key and key ref
    Carmi, Eyal (Eyal) 
    carmi at avaya.com
       
    Sun Feb 26 03:50:47 EST 2006
    
    
  
Hi,
 
I have the following schema:
 
<xs:schema>
<xs:element name="MyFilters">
                              <xs:complexType>
                                             <xs:sequence>
                                                            <xs:element
name="Filter" type="FilterType" minOccurs="0" maxOccurs="4"/>
                                             </xs:sequence>
                              </xs:complexType>
                              <xs:key name="FilterKey">
                                             <xs:selector
xpath="Filter"/>
                                             <xs:field xpath="@pKey"/>
                              </xs:key>
               </xs:element>
               <xs:complexType name="FilterType">
                              <xs:sequence>
                                             <xs:element name="data1"
type="xs:integer"/>
                                             <xs:element name="data2"
type="xs:integer" minOccurs="0"/>
                              </xs:sequence>
                              <xs:attribute name="pKey"
type="FilterKeyType"/>
               </xs:complexType>
</xs:schema>
 
Where I tried to define 'pKey' attribute as a key, when I created the
following file:
 
<MyFilters>
            <Filter pKey="A">
                        <data1>-0</data1>
                        <data2>-0</data2>
            </Filter>
            <Filter pKey="A">
                        <data1>-0</data1>
                        <data2>-0</data2>
            </Filter>
</MyFilters>
 
It validates even though the pKey 'A' appears twice... I also tried
defining 'pKey' as an element (instead of attribute) but the results are
the same.
 
I anyone manages to solve the problem I would appreciate an example of
how to define a keyref based on this key.
 
Thanks,
 
Eyal Carmi
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codesynthesis.com/pipermail/xsd-users/attachments/20060226/1f1117ac/attachment.html
    
    
More information about the xsd-users
mailing list