Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

schema key/keyref

 
Kenneth Tsuei
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, since it seems that it's so silent here, let me raise some noise here.
This question is not from any mock exam. I don't know if this is trivial to you, but I think it's a nice test on your understanding of schema key/keyref.
Schema:

XML Document:

This document is validate (as report by xsv and MSXML4.0). But as you may note that I'd like to enforce the key on B's ID attribute, with A's Ref element referencing it.
So, what's the problem??
Cheers,
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You schema fills many errors. I don't know what validator will validate it correctly.
One example here
Copied from http://www.w3schools.com/schema/el_element.asp
Definition and Usage
The element element defines an element.
Element Information
Parent elements: schema, choice, all, sequence, group

How this work? xsd:element has a wrong parent.
Copied from Kenneth Tsuei's post
<xsd:complexType>
<xsd:element ref="A"/>
<xsd:element ref="B"/>
</xsd:complexType>
 
Kenneth Tsuei
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, cox I typed it by hand in notepad so haven't verified that. This should be ok:
Schema:

Document:

Cheers
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that is valid now according to the validator. But why?
I think I've found the problem or a solution. After I made certain changes, the key/keyref both got checked by the validator. The document becomes invalid as you desired.
However, I do not quite understand it yet. I'll keep you posted probably tonight.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are touching some sensitive areas of XML Schema. It is related with QName and namespace and identity constraints. See an article here:

http://www.xml.com/lpt/a/2002/11/20/schemas.html
It is even more complicated in your case than the article described. I don't want to spend more time on it, and I'll quit for now.
However, I learned more schema during this process than I'd expected. Thanks for raising this question.
Good luck!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic