Problema con xsd schema

di il
1 risposte

Problema con xsd schema

Ciao!
sto sviluppando un xsd schema che userò poi per validare un xml. Purtroppo quando creo l'xml corretto lo schema mi dice che c'è un errore! più precisamente mi dice questo errore:

"Key 'rifsubmissionhost' with value 'host2' not found for identity constraint of element 'cluster' "

ecco il codice dello schema:

[list]
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
   
       <xsd:element name="cluster" type="ClusterType">
    	<xsd:key name="HostNameUnico">
    		<xsd:selector xpath="host"></xsd:selector>
    		<xsd:field xpath="@name"></xsd:field>
    	</xsd:key>
    	<xsd:unique name="JobNameUnico">
    		<xsd:selector xpath="./jobgroup/Job"></xsd:selector>
    		<xsd:field xpath="@name"></xsd:field>
    	</xsd:unique>
    	<xsd:unique name="JobGroupNameUnico">
    		<xsd:selector xpath="./jobgroup"></xsd:selector>
    		<xsd:field xpath="@name"></xsd:field>
    	</xsd:unique>
    	
    	<xsd:keyref name="rifsubmissionhost" refer="HostNameUnico">
    	<xsd:selector xpath="./jobgroup/job"></xsd:selector>
    	<xsd:field xpath="@submissionhost"></xsd:field>
    	</xsd:keyref>
    	
    	<xsd:keyref name="rifexecutionnhost" refer="HostNameUnico">
    		<xsd:selector xpath="jobgroup/job"></xsd:selector>
    		<xsd:field xpath="@executionhost"></xsd:field>
    	</xsd:keyref>
    </xsd:element>
    
    <xsd:complexType name="ClusterType">
    	<xsd:sequence>
    		<xsd:element name="host" type="hostType"
    			maxOccurs="unbounded" minOccurs="0">
    		</xsd:element>
    		<xsd:element name="jobgroup" type="jobgrouptype"
    			maxOccurs="unbounded" minOccurs="1">
    		</xsd:element>
    	</xsd:sequence>
    	<xsd:attribute name="name" use="required">
    		<xsd:simpleType>
    			<xsd:restriction base="xsd:string">
    				<xsd:pattern value="[a-zA-Z][a-zA-Z0-9_]*"></xsd:pattern>
    			</xsd:restriction>
    		</xsd:simpleType>
    	</xsd:attribute>
    	<xsd:attribute name="status" use="required">
    		<xsd:simpleType>
    			<xsd:restriction base="xsd:string">
    				<xsd:enumeration value="OK"></xsd:enumeration>
    				<xsd:enumeration value="UNAVAIL"></xsd:enumeration>
    			</xsd:restriction>
    		</xsd:simpleType>
    	</xsd:attribute>
    </xsd:complexType>
    
    
    <xsd:complexType name="hostType">
    	<xsd:choice>
	    	<xsd:element name="serverhost" type="serverhosttype"></xsd:element>
	    	<xsd:element name="clienthost" type="clienthosttype"></xsd:element>
    	</xsd:choice>
    	<xsd:attribute name="name" use="required">
    		<xsd:simpleType>
    			<xsd:restriction base="xsd:string">
    				<xsd:pattern value="[a-zA-Z][a-zA-Z0-9_]*"></xsd:pattern>
    			</xsd:restriction>
    		</xsd:simpleType>
    	</xsd:attribute>
    </xsd:complexType>


    <xsd:complexType name="serverhosttype">



    	<xsd:choice>

    		<xsd:element name="unavailunlicensedstatus"
    			type="unavailunlicensedtype" maxOccurs="1" minOccurs="0">
    		</xsd:element>
    		<xsd:element name="okclosedstatus" type="okclosedstatustype"
    			maxOccurs="1" minOccurs="0">
    		</xsd:element>
    	</xsd:choice>
    	<xsd:attribute name="ismaster" type="xsd:boolean"></xsd:attribute>
    </xsd:complexType>
	
	<xsd:complexType name="clienthosttype">
    	<xsd:attribute name="status" use="required">
    		<xsd:simpleType>
    			<xsd:restriction base="xsd:string">
    				<xsd:enumeration value="OK"></xsd:enumeration>
    			</xsd:restriction>
    		</xsd:simpleType>
    	</xsd:attribute>
    </xsd:complexType>
    
    <xsd:complexType name="jobgrouptype">
    	<xsd:sequence>
    		<xsd:element name="job" type="Jobtype" minOccurs="0" maxOccurs="unbounded"></xsd:element>
    	</xsd:sequence>
    	<xsd:attribute name="name" use="required">
    		<xsd:simpleType>
    			<xsd:restriction base="xsd:string">
    				<xsd:pattern value="[a-zA-Z][a-zA-Z0-9_]*"></xsd:pattern>
    			</xsd:restriction>
    		</xsd:simpleType>
    	</xsd:attribute>
    	<xsd:attribute name="descrizione" type="xsd:string" use="optional"></xsd:attribute>
    </xsd:complexType>
	
	<xsd:complexType name="Jobtype">
    	<xsd:attribute name="jobid" type="xsd:positiveInteger" use="required"> </xsd:attribute>
    	<xsd:attribute name="state" use="required">
    		<xsd:simpleType>
    			<xsd:restriction base="xsd:string">
    				<xsd:enumeration value="PENDING"></xsd:enumeration>
    				<xsd:enumeration value="RUNNING"></xsd:enumeration>
    				<xsd:enumeration value="DONE"></xsd:enumeration>
    				<xsd:enumeration value="EXIT"></xsd:enumeration>
    				<xsd:enumeration value="SUSPENDED"></xsd:enumeration>
    			</xsd:restriction>
    		</xsd:simpleType>
    	</xsd:attribute>
    	<xsd:attribute name="submissiontime" type="xsd:dateTime" use="required"></xsd:attribute>
    	<xsd:attribute name="submissionhost" use="required"></xsd:attribute>
    	<xsd:attribute name="executionhost" use="optional"></xsd:attribute>
    </xsd:complexType>

	<xsd:complexType name="okclosedstatustype">
		<xsd:attribute name="load" type="xsd:positiveInteger" use="required"></xsd:attribute>
		<xsd:attribute name="memory" type="xsd:positiveInteger" use="required"></xsd:attribute>
		<xsd:attribute name="status" use="required">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="OK"></xsd:enumeration>
					<xsd:enumeration value="CLOSED"></xsd:enumeration>
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>


	<xsd:complexType name="unavailunlicensedtype">
		<xsd:attribute name="status" use="required">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="UNAVAIL"></xsd:enumeration>
					<xsd:enumeration value="UNLICENSED"></xsd:enumeration>
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>


	</xsd:complexType>
</xsd:schema>
[/list]
ed ecco il codice dell'xml:

<?xml version="1.0" encoding="UTF-8" ?>

<cluster xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="PJSInfo.xsd" status="OK" name="sardo">
	<host name="host1">
		<serverhost ismaster="true">
			<okclosedstatus status="OK" load="10" memory="20"/>
		</serverhost>
	</host>
	<host name="host2">
		<clienthost status="OK"/>
	</host>
	
	<host name="host3">
		<serverhost ismaster="true">
			<unavailunlicensedstatus status="UNAVAIL"/>
		</serverhost>
	</host>
	
	<host name="host30">
		<clienthost status="OK"/>
	</host>
	<jobgroup name="jobroup1" descrizione="aaa">
		<job submissionhost="host2" state="PENDING" submissiontime="2002-05-30T09:30:10Z" jobid="21"/>
	</jobgroup>
	<jobgroup name="jobroup2">
	</jobgroup>
</cluster> 

1 Risposte

  • Re: Problema con xsd schema

    Penso di aver risolto.

    Il problema è nel validatore xml di eclipse! se uso visual studio tutto funziona!

    Grazie lo stesso
Devi accedere o registrarti per scrivere nel forum
1 risposte