Hi, This is a lab given in Rogers ppt on XML schema. Its lab no. 6. Current XSD contains the following.
XML source file structure is:
The question is to separate the <description> and <warranty> element in the XSD to a new type called "appliance" and then use that to derive (by extension) another new type called "juicerappliance". Finally declare the <juicer> element to be of type "juicerappliance". Now, the problem I having is how do we use "derive by extension" for elements that are present in the middle of the sequence. The answer given in the lab also seems to be not working fine. I have seen examples where "derive by extension" is used to extend the type by appending elements to it..but not in the middle of the sequence. If you have Rogers's labs, you can try lab 6 to see if it works for you in XMLSPY and let me know. I am trying to see if I am doing something wrong. Please help. Thanks, Hari. [ February 09, 2003: Message edited by: Hariharan Raman ]
I was going through the lab6 and I really don’t see any problem. I may be wrong but let me try to explain.
Lab 6. Using Derived Types Modify the schema that you created in Lab 5. Create a type called appliance. Define appliance to contain declarations for description and warranty. Create a type called juiceAppliance, which is derived from appliance (by extension). Make juicer of type juiceAppliance. As always, validate the instance document against your schema. Note: You will need to rearrange the contents of each juicer in the instance document!
lab is asking you to do following tasks: #1 Define appliance to contain declarations for description and warranty.
#2 Create a type called juiceAppliance, which is derived from appliance (by extension).
Since in the original Schema file we had following elements.
Since we have seperated the “description” and “warranty” element in “appliance” type, that is why “juiceAppliance” have rest of the elements. #3 Make juicer of type juiceAppliance.
#4 Note: You will need to rearrange the contents of each juicer in the instance document!
I guess every thing is clear. Event I tried to validate the file and it is fine in “xerces-2-2_0”. I would advise you to, not to use XMLSpy. It would give you very hard time and all sort of problem.
Let me know If I can help you. thnaks [ February 10, 2003: Message edited by: Vivek Saxena ]
Joined: Dec 30, 2002
Thanks a lot Vivek..! I got everything right except for the last one - change in the instance document.. It works fine now..! Hari.