Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:44:33+00:00 2026-06-08T20:44:33+00:00

I have several xml files, but I will present only one and the xsd

  • 0

I have several xml files, but I will present only one and the xsd against which I validate it. Let me describe the problem at first. I edit the files in VS2010 and the VS run time parser shows no errors while editting the xml file. Then when I run a php command line script which loads the xml file and validates it against the xml schema, it ends with an excption saying

Warning: DOMDocument::schemaValidate(): Element ‘element’: No match found for key-sequence [‘answers’] of keyref ‘elementRef’.

However, I really cannot see a mistake in the xsd file.

Xml file:

<domain xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Answer" namespace="Custom\Surveys" xsi:noNamespaceSchemaLocation="../../xsd/domain.xsd">
    <entities>
        <entity name="Answer" main="true" schema="answers"/>
    </entities>
    <bindings>      
    </bindings>
    <key>
        <element entity="answers" property="question_option_id"/>
        <element entity="answers" property="survey_voter_id"/>
    </key>
</domain>

Xml schema in an xsd file:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">   
    <xs:element name="domain">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="entities">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="entity" minOccurs="1" maxOccurs="unbounded">
                                <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required" id="entityName" />
                                    <xs:attribute name="main" type="xs:boolean" use="optional" default="false" />
                                    <xs:attribute name="schema" type="xs:string" use="required" id="schemaName" />                                  
                                </xs:complexType>                               
                            </xs:element>
                            <xs:element name="multientity" minOccurs="0" maxOccurs="1">
                                <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required" />
                                    <xs:attribute name="schema" type="xs:string" use="required" />
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>                   
                </xs:element>
                <xs:element name="bindings" minOccurs="0" maxOccurs="1">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="bind" minOccurs="0" maxOccurs="unbounded">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="referenced">
                                            <xs:complexType>
                                                <xs:attribute name="entity" type="xs:string" use="required" />
                                                <xs:attribute name="property" type="xs:string" use="required" />
                                            </xs:complexType>
                                            <xs:keyref name="referencedRef" refer="entityId">
                                                <xs:selector xpath="." />
                                                <xs:field xpath="@entity" />
                                            </xs:keyref>
                                        </xs:element>
                                    </xs:sequence>
                                    <xs:attribute name="entity" type="xs:string" use="required" />
                                    <xs:attribute name="property" type="xs:string" use="required" />
                                </xs:complexType>
                                <xs:keyref name="bindRef" refer="entityId">
                                    <xs:selector xpath="." />
                                    <xs:field xpath="@entity" />
                                </xs:keyref>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="key">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="element" minOccurs="1" maxOccurs="unbounded">
                                <xs:complexType>
                                    <xs:attribute name="entity" type="xs:string" use="required" />
                                    <xs:attribute name="property" type="xs:string" use="required" />
                                </xs:complexType>
                                <xs:keyref name="elementRef" refer="entityId">
                                    <xs:selector xpath="." />
                                    <xs:field xpath="@entity" />
                                </xs:keyref>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>                   
                </xs:element>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required" />            
            <xs:attribute name="namespace" type="xs:string" use="required" />
        </xs:complexType>
        <xs:key name="entityId">
            <xs:selector xpath="./entities/entity|./entities/multientity" />
            <xs:field xpath="@schema" />
        </xs:key>
    </xs:element>
</xs:schema>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:44:35+00:00Added an answer on June 8, 2026 at 8:44 pm

    I have found a solution, I had to define all the keys and keyrefs in the root element at the end.

    Here goes the new xsd file:

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">   
        <xs:element name="domain">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="entities">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="entity" minOccurs="1" maxOccurs="unbounded">
                                    <xs:complexType>
                                        <xs:attribute name="name" type="xs:string" use="required" id="entityName" />
                                        <xs:attribute name="main" type="xs:boolean" use="optional" default="false" />
                                        <xs:attribute name="schema" type="xs:string" use="required" id="schemaName" />                                  
                                    </xs:complexType>                               
                                </xs:element>
                                <xs:element name="multientity" minOccurs="0" maxOccurs="1">
                                    <xs:complexType>
                                        <xs:attribute name="name" type="xs:string" use="required" />
                                        <xs:attribute name="schema" type="xs:string" use="required" />
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>                   
                    </xs:element>
                    <xs:element name="bindings" minOccurs="0" maxOccurs="1">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="bind" minOccurs="0" maxOccurs="unbounded">
                                    <xs:complexType>
                                        <xs:sequence>
                                            <xs:element name="referenced">
                                                <xs:complexType>
                                                    <xs:attribute name="entity" type="xs:string" use="required" />
                                                    <xs:attribute name="property" type="xs:string" use="required" />
                                                </xs:complexType>                                           
                                            </xs:element>
                                        </xs:sequence>
                                        <xs:attribute name="entity" type="xs:string" use="required" />
                                        <xs:attribute name="property" type="xs:string" use="required" />
                                    </xs:complexType>                               
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="key">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="element" minOccurs="1" maxOccurs="unbounded">
                                    <xs:complexType>
                                        <xs:attribute name="entity" type="xs:string" use="required" />
                                        <xs:attribute name="property" type="xs:string" use="required" />
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>                   
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="name" type="xs:string" use="required" />            
                <xs:attribute name="namespace" type="xs:string" use="required" />
            </xs:complexType>
            <xs:key name="entityId">
                <xs:selector xpath="./entities/entity|./entities/multientity" />
                <xs:field xpath="@schema" />
            </xs:key>
            <xs:keyref name="elementRef" refer="entityId">
                <xs:selector xpath="./key/element" />
                <xs:field xpath="@entity" />
            </xs:keyref>
            <xs:keyref name="bindRef" refer="entityId">
                <xs:selector xpath="./bindings/bind" />
                <xs:field xpath="@entity" />
            </xs:keyref>
            <xs:keyref name="referencedRef" refer="entityId">
                <xs:selector xpath="./bindings/bind/referenced" />
                <xs:field xpath="@entity" />
            </xs:keyref>
        </xs:element>
    </xs:schema>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a system that will have several hundred thousand XML files,
I have several xml files, the names of which are stored in another xml
I have several xml files with different node structure. I want to extract xml
I have several xml files that are formated this way: <ROOT> <OBJECT> <identity> <id>123</id>
I have several existing XML schema files with a defined data model. I would
I have an XML document, several actually, that will be editable via a front-end
I am working on getting an xml file to validate against an XSD schema
I have several large XML files that have been corrupted in strange ways... certain
I have several large DTD files. I've used trang to convert them into XSD
I'm trying to have a script automatically transform an xml file into several html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.