2014-04-02 3 views
0

요소 값의 조합이 고유 한 경우 스키마를 통해 유효성을 검사 할 수 있습니까? 유효한고유 한 XML 특성 조합

:

<Hardware ID="1"> 
    <COMPort>COM1</COMPort> 
    <BaudRate>9600</BaudRate> 
</Hardware> 
<Hardware ID="2"> 
    <COMPort>COM2</COMPort> 
    <BaudRate>9600</BaudRate> 
</Hardware> 
<Hardware ID="3"> 
    <COMPort>COM1</COMPort> 
    <BaudRate>115200</BaudRate> 
</Hardware> 

잘못된 : 처신과 전송 속도의 조합이 고유하지 않기 때문에

<Hardware ID="1"> 
    <COMPort>COM1</COMPort> 
    <BaudRate>9600</BaudRate> 
</Hardware> 
<Hardware ID="2"> 
    <COMPort>COM2</COMPort> 
    <BaudRate>9600</BaudRate> 
</Hardware> 
<Hardware ID="3"> 
    <COMPort>COM1</COMPort> 
    <BaudRate>9600</BaudRate> 
</Hardware> 

이 코드는 유효하지 않습니다.

답변

2

네, 가능합니다 : 하드웨어 요소의 부모 요소 선언에

<xs:unique name="u"> 
    <xs:selector xpath="Hardware"/> 
    <xs:field xpath="COMPort"/> 
    <xs:field xpath="BaudRate"/> 
</xs:unique> 
같은 것을 사용