![]() |
![]() ![]() |
![]() |
![]() ![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 26 Pomógł: 0 Dołączył: 11.09.2005 Ostrzeżenie: (0%) ![]() ![]() |
Mam taki schemacik :
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > <!-- xmlns="http://xx.pl/marcin" targetNamespace="http://xx.pl/marcin"> --> <xs:annotation> <xs:documentation xml:lang="pl"> Przykład schematu z rozszerzaniem typów i referencjami. </xs:documentation> </xs:annotation> <xs:element name="studenci"> <xs:complexType> <xs:sequence> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="student" type="StudentTyp"/> <xs:element name="osoba" type="OsobaTyp"/> </xs:choice> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="OsobaTyp"> <xs:sequence> <xs:element name="imie" type="xs:string" maxOccurs="unbounded"/> <xs:element name="nazwisko" type="xs:string"/> </xs:sequence> <xs:attribute name="plec" type="PlecTyp" use="required"/> <xs:attribute name="email" type="xs:string" use="optional"/> </xs:complexType> <xs:complexType name="StudentTyp"> <xs:complexContent> <xs:extension base="OsobaTyp"> <xs:sequence> <xs:element name="nr-indeksu" type="xs:unsignedLong"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:simpleType name="PlecTyp"> <xs:restriction base="xs:string"> <xs:enumeration value="k"/> <xs:enumeration value="m"/> </xs:restriction> </xs:simpleType> <xs:element name="grupy"> <xs:complexType> <xs:sequence> <xs:element name="grupa" type="GrupaTyp" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="GrupaTyp"> <xs:sequence> <xs:element name="numer-grupy" type="xs:positiveInteger"/> <xs:element name="student" type="StudentWGrupieTyp" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="StudentWGrupieTyp"> <xs:attribute name="ref" type="xs:string"/> </xs:complexType> <xs:element name="uczelnia"> <xs:complexType> <xs:sequence> <xs:element ref="studenci"/> <xs:element ref="grupy"/> </xs:sequence> </xs:complexType> <xs:key name="studenci_key"> <xs:selector xpath="studenci/student"/> <xs:field xpath="nr-indeksu"/> </xs:key><!-- <xs:keyref name="grupy_studenci_ref" refer="studenci_key"> <xs:selector xpath="grupy/grupa/student"/> <xs:field xpath="@ref"/> </xs:keyref>--> </xs:element> </xs:schema> I to działa tzn jeżeli wygeneruje przykładowy dokument xml z unikalnymi nr-indexu to się waliduje a gdy nr-indeksu nie są unikalne to się nie waliduje czyli ogólnie ok ale gdy dodaje do tego namespace to przykładowe dokumenty validują się bez względu na to czy nr-indexu jest unkalny czy nie no a to już jest źle pytanie brzmi dlaczego po dodaniu przestrzeni nazw coś się psuje ? Jak widać w komentarzu wyżej prubuje dodać coś takiego xmlns="http://xx.pl/marcin" targetNamespace="http://xx.pl/marcin" to schema Problem rozwiązany. XMLSpy w wersji Enterprise Edition 2007 nie obsługuje kluczy ot i cały problem. |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 18.07.2025 - 01:42 |