Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-234

Improve key not found error message

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Version 2, Version 2.1
    • TBD
    • Validator
    • None

    Description

      I think the idea of appending the two paths (the field to the selector) is interesting, so I will add a JIRA to track it. The only difficulty that I see with it is that the key corresponding to a keyref may not be in the same element, and explictly identifying the element the corresponding key belongs to becomes exceedingly difficult in complex cases.

      Radu
      ----Original Message----
      From: Samuel B. Quiring sbq@cayuse.com
      Sent: Thursday, November 24, 2005 3:08 PM
      To: Radu Preotiuc-Pietro
      Subject: Re: Key 'Yes' not found for keyref constraint ...

      <snip/> Here's an approximation:

      The reference "TotalFundForAttachedKeyPersonsExistKeyRef2" requires that:
      ./RR_Budget:TotalFundForAttachedKeyPersons"@RR_Budget:TotalFundForAttachedKeyPersonsExist"
      point to
      ./RR_Budget:AttachedKeyPersons@RR_Budget:TotalFundForAttachedKeyPersonsExist,
      but ./RR_Budget:AttachedKeyPersons@RR_Budget:TotalFundForAttachedKeyPersonsExist does not exist

      or

      The reference "TotalFundForAttachedKeyPersonsExistKeyRef2" refers to an item that does not exist: ./RR_Budget:AttachedKeyPersons@RR_Budget:TotalFundForAttachedKeyPersonsExist,

      I'm not sure if I got the notation right. I believe that either of these messages would have been far more helpful than:

      Key 'Yes' not found for keyref constraint 'TotalFundForAttachedKeyPersonsExistKeyRef2@http://apply.grants.gov/forms/RR_Budget-V1.0'
      <snip/>

      I think your problem lies in the fact that keyref "TotalFundForAttachedKeyPersonsExistKeyRef2" doesn't in fact refer to key "TotalFundForAttachedKeyPersonsExistKey" as you seem to be thinking, but to "TotalFundForAttacheKeyPersonsExistKey2", so it looks for the element "AttachedKeyPersons", which is in fact missing....

      Radu

      --------------------------------------------------------------------------------
      From: Samuel B. Quiring sbq@Cayuse.com
      Sent: Wednesday, November 23, 2005 7:35 AM
      To: user@xmlbeans.apache.org
      Subject: Re: Key 'Yes' not found for keyref constraint ...

      I want to clarify one item in the email below: The 'validation error' comes from calling:

      org.apache.xmlbeans.XmlObject.validate().

      We call this routine all over in our code, it is great for debugging. This is the first time
      we've been totally stumped.
      ----- Original Message -----
      From: Samuel B. Quiring
      To: user@xmlbeans.apache.org
      Sent: Tuesday, November 22, 2005 3:09 PM
      Subject: Key 'Yes' not found for keyref constraint ...

      I'm getting a validation error on the XML generated for the schema snippet below:

      validationError: error: cvc-identity-constraint.4.3: Key 'Yes' not found for keyref constraint 'TotalFundForAttachedKeyPersonsExistKeyRef2@http://apply.grants.gov/forms/RR_Budget-V1.0'

      Does anyone have any idea what this means? I've been trying to figure this out for a couple of hours. Here is the relevant XML that is generated:

      --------------------------------------------------------------------------------

      <rr:FundsRequested>40</rr:FundsRequested>
      <rr:BaseSalary>90</rr:BaseSalary>
      </rr:Compensation>
      </rr:KeyPerson>
      <rr:TotalFundForAttachedKeyPersons rr:TotalFundForAttachedKeyPersonsExist="Yes">101</rr:TotalFundForAttachedKeyPersons>
      <rr:TotalFundForKeyPersons>51</rr:TotalFundForKeyPersons>
      </rr:KeyPersons>

      --------------------------------------------------------------------------------

      Schema Snippet (http://apply.grants.gov/forms/schemas/RR_Budget-V1.0.xsd)
      <xs:schema xmlns:RR_Budget="http://apply.grants.gov/forms/RR_Budget-V1.0"
      xmlns:att="http://apply.grants.gov/system/Attachments-V1.0"
      xmlns:globLib="http://apply.grants.gov/system/GlobalLibrary-V1.0"
      . . .
      <xs:import namespace="http://apply.grants.gov/system/Global-V1.0"
      schemaLocation="http://apply.grants.gov/system/schemas/Global-V1.0.xsd" />
      . . .
      <xs:element name="KeyPersons">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="KeyPerson" type="RR_Budget:KeyPersonDataType" maxOccurs="8"/>
      <xs:element name="TotalFundForAttachedKeyPersons" minOccurs="0">
      <xs:complexType>
      <xs:simpleContent>
      <xs:extension base="glob:DecimalMin1Max15Places2Type">
      <xs:attribute name="TotalFundForAttachedKeyPersonsExist" type="globLib:YesNoDataType" use="required" fixed="Yes"/>
      </xs:extension>
      </xs:simpleContent>
      </xs:complexType>
      </xs:element>
      <xs:element name="TotalFundForKeyPersons" type="glob:DecimalMin1Max15Places2Type"/>
      <xs:element name="AttachedKeyPersons" minOccurs="0">
      <xs:complexType>
      <xs:complexContent>
      <xs:extension base="att:AttachedFileDataType">
      <xs:attribute name="TotalFundForAttachedKeyPersonsExist" type="globLib:YesNoDataType" use="required" fixed="Yes"/>
      </xs:extension>
      </xs:complexContent>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      <xs:key name="TotalFundForAttachedKeyPersonsExistKey">
      <xs:selector xpath="./RR_Budget:TotalFundForAttachedKeyPersons"/>
      <xs:field xpath="@RR_Budget:TotalFundForAttachedKeyPersonsExist"/>
      </xs:key>
      <xs:keyref name="TotalFundForAttachedKeyPersonsExistKeyRef" refer="RR_Budget:TotalFundForAttachedKeyPersonsExistKey">
      <xs:selector xpath="./RR_Budget:AttachedKeyPersons"/>
      <xs:field xpath="@RR_Budget:TotalFundForAttachedKeyPersonsExist"/>
      </xs:keyref>
      <xs:key name="TotalFundForAttachedKeyPersonsExistKey2">
      <xs:selector xpath="./RR_Budget:AttachedKeyPersons"/>
      <xs:field xpath="@RR_Budget:TotalFundForAttachedKeyPersonsExist"/>
      </xs:key>
      <xs:keyref name="TotalFundForAttachedKeyPersonsExistKeyRef2" refer="RR_Budget:TotalFundForAttachedKeyPersonsExistKey2">
      <xs:selector xpath="./RR_Budget:TotalFundForAttachedKeyPersons"/>
      <xs:field xpath="@RR_Budget:TotalFundForAttachedKeyPersonsExist"/>
      </xs:keyref>
      </xs:element>

      From globLib (http://apply.grants.gov/system/schemas/Global-V1.0.xsd)
      <xs:simpleType name="YesNoDataType">
      <xs:restriction base="xs:string">
      <xs:enumeration value="Yes"/>
      <xs:enumeration value="No"/>
      </xs:restriction>
      </xs:simpleType>

      Attachments

        Activity

          People

            radup Radu Preotiuc
            radup Radu Preotiuc
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: