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 163605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:35:47+00:00 2026-05-11T11:35:47+00:00

I’m trying to wrap my head around xml schemas and one thing I’m trying

  • 0

I’m trying to wrap my head around xml schemas and one thing I’m trying to figure out is how to do relational type schemas where on element refers to another, possibly in another schema altogether. I’ve looked at the xsd:key and xsd:keyref and it seems like the sort of thing I’m interested in, but I’m not sure. Initially I just set attributes with the type xs:ID abd xs:IDREF, which obviously doesn’t necessarily refer to a specific element as far as I could tell.

Basically, I have several different xml files where elements refer to other elements either in the same file or other files. It looks a lot like a relation database and I would love to use one, but the requirement is to only use XML files and so I’m at least trying to establish some sanity instead of just seemingly random strings relying on xml comments to define the relationships. It works for smaller projects, but it’s certainly not scalable.

Any thoughts?

  • 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. 2026-05-11T11:35:48+00:00Added an answer on May 11, 2026 at 11:35 am

    I’m not aware of anything within XML Schema that will allow you to validate multiple XML documents against one another. In the xs:id and xs:key (etc) constraints, you use xpath to apply the constraints. You can go to XML Schema Part 1: Structures and scroll down a little bit for the example to see these constraints in action.

    If you have the ability to define a meta-XML file that includes your others (perhaps by entity references if by no other way) and then use a schema for that meta file, then you should be able to use XML Schema to apply your constraints. If you define a schema for each of your XML file types, you should be able to trivially (by xs:import or xs:include) define a meta-schema for an XML file that includes all of your XML content in one XML file. This meta-schema could successfully apply the constraints you want.

    Let’s say you have to validate a Wiki that has many posts, where each post has an author and maybe many comments where each comment also has an author, and that you have one XML file for all posts, one for all comments, one for all authors, and you want to validate constraints between these files, that each post uses authors and comments that exist, that each comment uses authors that exist, and so on. Let’s say you have the following three files:

    The file /home/username/posts.xml:

    <?xml version='1.0' encoding='UTF-8' ?> <posts>   <post>     <author name='author1'/>     <comment id='12345' pos='1'/>     <comment id='12346' pos='2'/>     <body>I really like my camera...</body>   </post>    ... </posts> 

    The file /home/username/comments.xml:

    <?xml version='1.0' encoding='UTF-8' ?> <comments>   <comment id='12345' author='kindguy'>     That was a very good post   </comment>    ... </comments> 

    The file /home/username/authors.xml:

    <?xml version='1.0' encoding='UTF-8' ?> <authors>   <author name='kindguy' id='1'/>   <author name='author1' id='2'/>    ... </authors> 

    What I am suggesting is that you make a meta-XML file by using Entity References. For example, you could create the following XML file:

    <?xml version='1.0' encoding='UTF-8' ?> <!ENTITY postfile    SYSTEM 'file:///home/username/posts.xml'> <!ENTITY commentfile SYSTEM 'file:///home/username/comments.xml'> <!ENTITY authorfile  SYSTEM 'file:///home/username/authors.xml'> <root>   &postfile1;   &commentfile;   &authorfile; </root> 

    This meta-XML file (actually, a plain old XML file … the ‘meta’ is only from the perspective of your three defined XML files, and not in any XML sense) is the exact equivalent of the following file, and XML parsers will act as if you truly had the following file:

    <?xml version='1.0' encoding='UTF-8' ?> <root>   <posts>     <post>       <author name='author1'/>       <comment id='12345' pos='1'/>       <comment id='12346' pos='2'/>       <body>I really like my camera...</body>     </post>      ...   </posts>   <comments>     <comment id='12345' author='kindguy'>       That was a very good post     </comment>      ...   </comments>   <authors>     <author name='kindguy' id='1'/>     <author name='author1' id='2'/>      ...   </authors> </root> 

    From this file, you can define an XML schema that will apply the desired constraints, even though with the individual files there is no way to apply constraints. Since using XML entity notation you have ‘included’ all the XML into one file, you can use xpath in the contraint references.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.