Answer the question
In order to leave comments, you need to log in
How are key , keyref xml schema applied?
<парковаться xmlns="http://parken.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://parken.org parken.xsd">
<машина номер="12341"/>
<машина номер="258"/>
<машина номер="12"/>
<машина номер="4587"/>
<парковка id="12">
<парк>258</parkt>
<парк>12</parkt>
</парковка>
<парковка id="1597">
<парк>12341</parkt>
<парк>4587</parkt>
</парковка>
</парковаться>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://parken.org" xmlns:tns="http://parken.org" elementFormDefault="qualified">
<xs:element name="парковаться">
<xs:complexType>
<xs:sequence>
<xs:element name="машина" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="номер" type="xs:positiveInteger"></xs:attribute>
</xs:complexType>
<xs:key name="номерType">
<xs:selector xpath="tns:парковаться/tns:машина></xs:selector>
<xs:field xpath="@номер"></xs:field>
</xs:key>
</xs:element>
<xs:element name="парковка" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="парк" type="xs:positiveInteger" maxOccurs="unbounded"></xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:positiveInteger"></xs:attribute>
</xs:complexType>
<xs:key name="idType">
<xs:selector xpath="tns:парковаться/tns:парковка"></xs:selector>
<xs:field xpath="@id"></xs:field>
</xs:key>
<b> <xs:keyref refer="tns:номерType" name="номерRefType">
<xs:selector xpath="????"></xs:selector>
<xs:field xpath="?????"></xs:field>
</xs:keyref> </b>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Answer the question
In order to leave comments, you need to log in
Based
those. there can't be more than one known car in the same parking lot (in the XML example above, it can)
XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://parken.org" targetNamespace="http://parken.org" elementFormDefault="qualified">
<xs:element name="парковаться">
<xs:complexType>
<xs:sequence>
<xs:element name="машина" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="номер" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="парковка" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="парк" type="xs:string" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="УникальностьМашин">
<xs:selector xpath="tns:машина"/>
<xs:field xpath="@номер"/>
</xs:key>
<xs:key name="УникальностьПарковок">
<xs:selector xpath="tns:парковка"/>
<xs:field xpath="@id"/>
</xs:key>
<xs:keyref name="МашинаНаПарковкеСуществует" refer="tns:УникальностьМашин">
<xs:selector xpath="tns:парковка/tns:парк"/>
<xs:field xpath="."/>
</xs:keyref>
<xs:key name="ОднаМашинаНаОднойПарковке">
<xs:selector xpath="tns:парковка"/>
<xs:field xpath="@id"/>
<xs:field xpath="tns:парк"/>
</xs:key>
</xs:element>
</xs:schema>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question