key or unique that is out of range
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Fri Aug 04, 2006 5:18 pm
key or unique that is out of range
I have a schema and data file that seem to be good but when I attempt to validate the file against the schema I get this error:
E Identity Constraint error: identity constraint "KeyRef@155b797" has a keyref which refers to a key or unique that is out of scope.
Does anyone know what this means or why I am getting this error. This schema was sent to be by another company and they tell me that it works fine to valdate this example file for them. I'm not sure if they are mistaken or I'm making an error somewhere would just like to try and get another set of eyes on this. Attached is the schema and the example data file.
Schema:
Example XML File:
E Identity Constraint error: identity constraint "KeyRef@155b797" has a keyref which refers to a key or unique that is out of scope.
Does anyone know what this means or why I am getting this error. This schema was sent to be by another company and they tell me that it works fine to valdate this example file for them. I'm not sure if they are mistaken or I'm making an error somewhere would just like to try and get another set of eyes on this. Attached is the schema and the example data file.
Schema:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.synergysw.com/SAMS/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:s2k="http://www.synergysw.com/SAMS/XMLSchema" xmlns="http://www.synergysw.com/SAMS/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.5.0">
<xsd:include schemaLocation=".\Sams2kSharedComplexTypes.xsd"/>
<xsd:element name="SAMS">
<xsd:annotation>
<xsd:documentation>Document's starting element.</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Header">
<xsd:annotation>
<xsd:documentation>Document's header.</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="CreatedBy" type="xsd:string" use="required"/>
<xsd:attribute name="DateCreated" type="xsd:string" use="required"/>
<xsd:attribute name="Version" type="xsd:string" use="required"/>
<xsd:attribute name="GenuineKey" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Objects">
<xsd:annotation>
<xsd:documentation>Element containing all the exported containers.</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Consumer" type="s2k:Consumer" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>This element contains a client object.</xsd:documentation>
</xsd:annotation>
<xsd:keyref name="Client__Create_User__Ref" refer="User__UniqueID">
<xsd:selector xpath="s2k:CREATE_USER"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
<xsd:keyref name="Client__Lupdate_User__Ref" refer="User__UniqueID">
<xsd:selector xpath="s2k:LUPDATE_USER"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
</xsd:element>
<xsd:element name="ServiceDelivery" type="s2k:ServiceDelivery" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>This element contains a service delivery object.</xsd:documentation>
</xsd:annotation>
<xsd:keyref name="Service_Delivery__Create_User__Ref" refer="User__UniqueID">
<xsd:selector xpath="s2k:CREATE_USER"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
<xsd:keyref name="Service_Delivery__Lupdate_User__Ref" refer="User__UniqueID">
<xsd:selector xpath="s2k:LUPDATE_USER"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
<xsd:keyref name="Consumer__Service_Delivery__Ref" refer="Consumer__UniqueID">
<xsd:selector xpath="s2k:CONSUMER_REF"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
<xsd:keyref name="CareGiver__Service_Delivery__Ref" refer="Consumer__UniqueID">
<xsd:selector xpath="s2k:CARE_GIVER_REF"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
<xsd:keyref name="Care_Recipient_Delivery__Service_Delivery__Ref" refer="ServiceDelivery__UniqueID">
<xsd:selector xpath="s2k:CARE_RECIPIENT_SERV_DELIV_REF"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
</xsd:element>
<xsd:element name="User" type="s2k:User" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>This element contains a user object.</xsd:documentation>
</xsd:annotation>
<xsd:keyref name="Users__Create_User__Ref" refer="User__UniqueID">
<xsd:selector xpath="s2k:CREATE_USER"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
<xsd:keyref name="Users__Lupdate_User__Ref" refer="User__UniqueID">
<xsd:selector xpath="s2k:LUPDATE_USER"/>
<xsd:field xpath="s2k:ObjectReference/@RefID"/>
</xsd:keyref>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:unique name="Consumer__UniqueID">
<xsd:selector xpath="s2k:Consumer"/>
<xsd:field xpath="@ID"/>
</xsd:unique>
<xsd:unique name="CareHistory__UniqueID">
<xsd:selector xpath="s2k:Consumer/s2k:CareHistory"/>
<xsd:field xpath="@ID"/>
</xsd:unique>
<xsd:unique name="ServiceDelivery__UniqueID">
<xsd:selector xpath="s2k:ServiceDelivery"/>
<xsd:field xpath="@ID"/>
</xsd:unique>
<xsd:unique name="User__UniqueID">
<xsd:selector xpath="s2k:User"/>
<xsd:field xpath="@ID"/>
</xsd:unique>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Code: Select all
<?xml version="1.0"?>
<SAMS xmlns="http://www.synergysw.com/SAMS/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header CreatedBy="Synergy Software Technologies Inc." DateCreated="06/06/2005" Version="1.5.0"/>
<Objects>
<Consumer ID="C20606">
<DOB>1913-04-27</DOB>
<GENDER>M</GENDER>
<ALT_ID_1>20606</ALT_ID_1>
<NUM_ADLS>2</NUM_ADLS>
<NUM_IADLS>6</NUM_IADLS>
<IS_NUTR_HIGHRISK>0</IS_NUTR_HIGHRISK>
<IS_RURAL>0</IS_RURAL>
<IS_LIVES_ALONE>-1</IS_LIVES_ALONE>
<IS_IN_POVERTY>0</IS_IN_POVERTY>
<IS_DISABLED>0</IS_DISABLED>
<ActionItem ID="Ac05">
<ACTION_REF>
<ObjectDescriptor RefDescriptor="Meeting"/>
</ACTION_REF>
<STATUS_CODE_REF>
<ObjectDescriptor RefDescriptor="Completed"/>
</STATUS_CODE_REF>
<SUBJECT>Meet the client to obtain more information.</SUBJECT>
<START_DATE>1991-12-30</START_DATE>
<START_TIME>14:20:00</START_TIME>
<END_DATE>1991-12-30</END_DATE>
<DUE_DATE>1991-12-30</DUE_DATE>
</ActionItem>
<UserFieldAssociation ID="usfld01">
<USER_FIELD_REF>
<ObjectDescriptor RefDescriptor="Money for food"/>
</USER_FIELD_REF>
<FIELD_VALUE>4.0</FIELD_VALUE>
</UserFieldAssociation>
<CareHistory ID="CH20606">
<CARE_PROGRAM_REF>
<ObjectDescriptor RefDescriptor="NAPIS - Title III"/>
</CARE_PROGRAM_REF>
<STATUS_CODE_REF>
<ObjectDescriptor RefDescriptor="Active"/>
</STATUS_CODE_REF>
<STATUS_DATE>1990-12-30</STATUS_DATE>
<APPLICATION_DATE>1990-12-30</APPLICATION_DATE>
<RECEIVED_DATE>1990-12-30</RECEIVED_DATE>
<START_DATE>1993-09-01</START_DATE>
<COPAY_VALUE>0</COPAY_VALUE>
</CareHistory>
<JournalEntry ID="JE01">
<IS_RESTRICTED_ENTRY>0</IS_RESTRICTED_ENTRY>
<ENTRY_DATE>1990-12-31</ENTRY_DATE>
<ENTRY_TIME>14:20:00</ENTRY_TIME>
<SUBJECT>Journal Entry example</SUBJECT>
<NOTES>Enter a Note</NOTES>
</JournalEntry>
<EthnicGroup ID="Eth01">
<ETHNIC_GROUP_CODE>Missing</ETHNIC_GROUP_CODE>
<ETHNIC_RACE_REF>
<ObjectDescriptor RefDescriptor="Origin"/>
</ETHNIC_RACE_REF>
</EthnicGroup>
<Client>
<FIRST_NAME>Raoul</FIRST_NAME>
<LAST_NAME>Jett</LAST_NAME>
<SSN>464-12-4565</SSN>
<ClientContact ID="CLC01">
<CONTACT_TYPE_REF>
<ObjectDescriptor RefDescriptor="Brother"/>
</CONTACT_TYPE_REF>
<NAME>John Leclair</NAME>
<EMAIL_ADDR>jleclair@dontknow.com</EMAIL_ADDR>
<IS_PRIMARY_CONTACT>1</IS_PRIMARY_CONTACT>
<IS_BILL_TO>0</IS_BILL_TO>
<ContactLocation ID="ConLo01">
<LOCATION_TYPE_REF>
<ObjectDescriptor RefDescriptor="Residence"/>
</LOCATION_TYPE_REF>
<ADDRESS_1>1 Bright Street</ADDRESS_1>
<ADDRESS_2>App 100</ADDRESS_2>
<TOWN_REF>
<ObjectDescriptor RefDescriptor="Emerson"/>
</TOWN_REF>
<STATE_REF>
<ObjectDescriptor RefDescriptor="Arkansas"/>
</STATE_REF>
<ZIP_REF>
<ObjectDescriptor RefDescriptor="72728"/>
</ZIP_REF>
<IS_PRIMARY_LOCATION>1</IS_PRIMARY_LOCATION>
</ContactLocation>
<ContactPhone ID="ConPh02">
<PHONE_TYPE_REF>
<ObjectDescriptor RefDescriptor="Mobile"/>
</PHONE_TYPE_REF>
<AREA_CODE>802</AREA_CODE>
<PHONE_NUMBER>324-2343</PHONE_NUMBER>
<IS_PRIMARY_PHONE>1</IS_PRIMARY_PHONE>
</ContactPhone>
</ClientContact>
<ClientLocation ID="CL20606">
<LOCATION_TYPE_REF>
<ObjectDescriptor RefDescriptor="Residence"/>
</LOCATION_TYPE_REF>
<ADDRESS_1>7610 Reading Rd., #708</ADDRESS_1>
<TOWN_REF>
<ObjectDescriptor RefDescriptor="Elm Springs"/>
</TOWN_REF>
<STATE_REF>
<ObjectDescriptor RefDescriptor="Arkansas"/>
</STATE_REF>
<ZIP_REF>
<ObjectDescriptor RefDescriptor="72728"/>
</ZIP_REF>
<IS_PRIMARY_LOCATION>1</IS_PRIMARY_LOCATION>
</ClientLocation>
<ClientPhone ID="CP0011">
<PHONE_TYPE_REF>
<ObjectDescriptor RefDescriptor="Mobile"/>
</PHONE_TYPE_REF>
<PHONE_NUMBER>564-6444</PHONE_NUMBER>
<IS_PRIMARY_PHONE>0</IS_PRIMARY_PHONE>
</ClientPhone>
<ClientCareManager ID="CLCmgr01">
<PROVIDER_REF>
<ObjectDescriptor RefDescriptor="Some Care Manager"/>
</PROVIDER_REF>
<START_DATE>2004-01-01</START_DATE>
<IS_PRIMARY>1</IS_PRIMARY>
</ClientCareManager>
<CareGiver ID="CLCareGiver01">
<CONSUMER_PROVIDER_REF>
<ObjectDescriptor RefDescriptor="20607"/>
</CONSUMER_PROVIDER_REF>
<CAREGIVER_RELATIONSHIP_REF>
<ObjectDescriptor RefDescriptor="Parent"/>
</CAREGIVER_RELATIONSHIP_REF>
<FCSP_TYPE>Federal</FCSP_TYPE>
</CareGiver>
</Client>
</Consumer>
</Objects>
</SAMS>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
Note that your schema refers to another schema that you did not provided.
Anyway, the problem is that in XML Schema keys are scoped to the elements they are defined on. In the case of DTD the support for ID/IDREF/IDREFS was global, its scope being the whole document. XML Schema enhances the DTD support with the key/keyref support that allows limiting the scope to an element.
To solve your problem you need to move the keys and key references one level up. Make sure you change the select/field XPaths according with this change.
Best Regards,
George
Note that your schema refers to another schema that you did not provided.
Anyway, the problem is that in XML Schema keys are scoped to the elements they are defined on. In the case of DTD the support for ID/IDREF/IDREFS was global, its scope being the whole document. XML Schema enhances the DTD support with the key/keyref support that allows limiting the scope to an element.
To solve your problem you need to move the keys and key references one level up. Make sure you change the select/field XPaths according with this change.
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service