This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Product and Other Certifications and the fly likes Same element name but different content. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Reply Bookmark "Same element name but different content." Watch "Same element name but different content." New topic
Author

Same element name but different content.

Karthik Jayaraman
Greenhorn

Joined: May 06, 2003
Posts: 25
I have been blowing my mind on this for a while now. Let me try to explain the best I can.
XML Schemas have this advantage that multiple elements with the same name and different content can be present.
Lets look at it at a different aspect. In DTDs, element names, attribute names should be unique throughout the document. But in schemas, the element names are in the element symbol space, attributes in the attribute symbol space and types in the type symbol space. So, we can have an element, attribute and a type with the same name
OK. thats pretty clear.
Now look at this schema snippet
<complexType>
<sequence>
<element name="title" type="string" />
<element name="title" type="string" />
</sequence>
</complexType>
This is a legal schema where we define two elements in a sequence with a same name and they can have different content in the instance document
[Question 1: Why would anyone want to do this? Can anyone help me out with a practical example for this.]
Secondly if the types were different, the schema is illegal. Ok. Lets look at another way of it. I have two types booktype and magazine type. both have title elements within them.
In the namespace, isnt there a name conflict for the two title elements. No, because we can have the elementFormDefault to be "unqualified". This way we can say that only the root elements need to be in the namespace and the local elements would indirectly be associated with the namespace through the parent element.
Fine, pretty understandable.
[Qustion 2: what if the elementFormDefault was "qualified" would it be illegal?
Question 3: If elementFormDefault was "unqualified" and the type of the elements were different, would it be illegal?]
Please help. Thx in advance.


Karthik Jayaraman.<br />IBM Certified Developer - XML and Related Technologies.<br />Sun Certified Developer for java WebServices.<br />Sun Certified Java Programmer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Same element name but different content.
 
Similar Threads
Why qualified XML elements are erroring out ?
How to use elementFormDefault and attributeFormDefault?
Doubt in xsd
Help with TypeMapping
namespace and targetnamespace