1. where is "xmlns:xs="http://www.w3.org/2001/XMLSchema" defined. When we try to validate an XML against a schema where
does it look for the schema.
2. The significance of targetNamespace and elementFormDefault attributes in XSD document.
Can someone please explain me with this.
Thanks and Regards, Pradeep Kumar
SCJP 1.6, SCWCD 5.0
1) Try pasting http://www.w3.org/2001/XMLSchema.xsd into your web browser.
That is where the XML "schema of schemas" is defined. However, I assume that for most cases, this schema is built-in to the basic XML processing APIs.
Regretfully, I have not been able to come up with any proof of this.
Declaring a target namespace is significant in the way that it determines to which namespace the definitions in a schema belong.
A namespace is like a box with a name on it. In this box you can put things, but in order to find things in a box, you first have to supply the name of the box in which to look, i.e. the namespace, and then what item to look for. Instead of having all things in one big box (in one namespace) namespaces helps you to group things into smaller groups. This also allows you to define items with the same names without name collisions (as long as they belong to different namespaces).
If elementFormDefault="qualified" means that the elements defined in the schema with this declaration must be qualified with a namespace prefix in an instance of the XML schema. A qualified element looks like this: <tns:someElement/>, an unqualified element looks like this <someElement/>
Please refer to these URLs for more information and examples:
http://www.w3.org/TR/xmlschema-0/#UnqualLocals http://www.w3.org/TR/xmlschema-0/#QualLocals Best wishes!