jQuery in Action, 2nd edition*
The moose likes Product and Other Certifications and the fly likes schema key/keyref Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "schema key/keyref" Watch "schema key/keyref" New topic
Author

schema key/keyref

Kenneth Tsuei
Greenhorn

Joined: Jan 26, 2003
Posts: 9
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,


-----------------------------------<br />-- Learning is a never-ending story: the more u learn, the less u found u've known
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
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

Joined: Jan 26, 2003
Posts: 9
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

Joined: Nov 14, 2000
Posts: 1953
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

Joined: Nov 14, 2000
Posts: 1953
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: schema key/keyref
 
Similar Threads
minOccurs, maxOccurs
How to make an element value unique within entire instance document?
xsd unique identity constraint (parent and child)
Web Service message level Encryption Decryption through public and private key
Top_Level Definition