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

  • Home
  • SEARCH
  • 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 3613330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:06:36+00:00 2026-05-18T22:06:36+00:00

I’m falling over on a frustrating, arbitrary restriction in XML Schema. For some reason,

  • 0

I’m falling over on a frustrating, arbitrary restriction in XML Schema. For some reason, it insists that PK-FK relationships have to be one-to-one. Why?

For example, given the schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="FutureSchema"
    targetNamespace="http://tempuri.org/FutureSchema.xsd"
    elementFormDefault="unqualified"
    xmlns="http://tempuri.org/FutureSchena.xsd"
    xmlns:mstns="http://tempuri.org/FutureSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="FUTUREFILE">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Configuration">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Experiments">

                <xs:complexType>
                  <xs:sequence>

                    <xs:element name="Experiment">

                      <xs:complexType>
                        <xs:attribute name="ID" type="xs:integer"/>
                        <xs:attribute name="Profile" type="xs:integer"/>
                      </xs:complexType>

                      <xs:keyref name="dummy" refer="LP">
                        <xs:selector xpath="Experiment"/>
                        <xs:field xpath="@Profile"/>
                      </xs:keyref>

                    </xs:element>

                  </xs:sequence>
                </xs:complexType>

                <xs:key name="LP">
                  <xs:selector xpath="*/Configuration/Profiles/Profile"/>
                  <xs:field xpath="@ID"/>
                </xs:key>

              </xs:element>
              <xs:element name="Profiles">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Profile">
                      <xs:complexType>
                        <xs:attribute name="ID" type="xs:integer"/>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

And an example instance:

<?xml version="1.0" encoding="utf-8" ?>
<b:FUTUREFILE xmlns:b="http://tempuri.org/FutureSchena.xsd">
  <Configuration>
    <Experiments>
      <Experiment ID="1" Profile="1"/>
      <Experiment ID="2" Profile="1"/>
    </Experiments>
    <Profiles>
      <Profile ID="1"/>
    </Profiles>
  </Configuration>
</b:FUTUREFILE>

Document validation throws an error if I define <Experiment ID="1" FK="1"/><Experiment ID="2" FK="1"/>, for example; i.e. more than one Experiment may not reference the same Profile. But why else would I want to use a key relationship? What use is a key relationship at all if I can’t do something so fundamental?

OK, if and won’t let me do this, how should I?

edit #1: As requested, I’ve padded out my code sample to include the full schema and a basic instance.

edit #2: Interesting. SharpDevelop’s XML editor (as opposed to Visual Studio’s) doesn’t seem to object. It doesn’t object to the foreign key value referring to a nonexistent primary key either (which IMO it should) but it’s a start.

  • 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-05-18T22:06:37+00:00Added an answer on May 18, 2026 at 10:06 pm

    What wasn’t clear ?… My english, it’s all 🙂

    Some remarqs, I’m not sure it’s solution :

    In exemple instance, it’s best to use xmlns:b="http://tempuri.org/FutureSchema.xsd">, and not xmlns:b="http://tempuri.org/FutureSchena.xsd"> (n -> m).

    Also it’s best to put b: in front of all elements names.

    According to your schema, you can’t have two Experiment in Experiments, only one.

    On xsd, put <xs:keyref name="dummy" refer="mstns:LP">, that works best for me ; it’s because xpath expression doesnt’t understand default namespace, see Correct way to use key in xsd.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build

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.