non sono in grado di ottenere i xs: identificatore unico a lavorare in un file XML. Non riesco a capire un XPath che funzioni. Le mie scuse per la quantità di codice in questa domanda, ma sarei estremamente grato a tutti coloro che potrebbero indicare che cosa sto facendo male qui di seguito. Non importa quello che faccio, non riesco a ottenere l'attributo @ref nell'elemento per segnalare un errore per il mio duplicare il valore (ogni ref deve essere univoco).Come specificare valori unici in uno schema XML
Qualsiasi aiuto o puntatori a informazioni sarebbero molto gratefuly ricevuti.
Tipo desidera, Patrick
Questo è il mio schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Artworks"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:aw="http://www.fourthwish.co.uk/data/Artworks.xsd"
xmlns="http://www.fourthwish.co.uk/data/Artworks.xsd"
targetNamespace="http://www.fourthwish.co.uk/data/Artworks.xsd"
elementFormDefault="qualified"
>
<xs:element name="artworks">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="artwork" type="ArtworkType">
<xs:unique name="uniqueRef">
<xs:selector xpath="artwork"/>
<xs:field xpath="@ref"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ArtworkType">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
</xs:sequence>
<xs:attribute name="ref" type="xs:nonNegativeInteger"/>
</xs:complexType>
</xs:schema>
E questo è il mio file XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<artworks
xmlns="http://www.fourthwish.co.uk/data/Artworks.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.fourthwish.co.uk/data/Artworks.xsd Artworks.xsd"
>
<artwork ref="1">
<title>Title String</title>
</artwork>
<artwork ref="1">
<title>Title String</title>
</artwork>
</artworks>
Perché non ottengo un errore per l'arbitro duplicato valori? Arrrggghhh! Ho letto tutto su internet. Per favore aiuta qualcuno.