Hi, I am not clear about targetNamespace. Hope you can help me. .. <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:mh="http://www.Monson-Haefel.com/jwsbook" targetNamespace="http://www.Monson-Haefel.com/jwsbook">
"targetNamespace declare the XML namespace of all NEW TYPES explicitly created within the schema"(from RMH book-p36).I understand that USAddress belongs to targetNamespace, because it is a new types created in the schema. The schema also declare a default namespace. The namespace(default namespace) "is the standard namespace defined by the XML schema specification-all the XML schema elements must belong to this namespace"(from RMH book-p36).Does that mean "address","name" and "street" belong to the default namespace? Thanks for your help.
address","name" and "street" are the element identifiers.
I would say address","name" and "street" are more like the class/instance variables in a Java Class, it can be any valid name.
targetnamespace is saying this is the namespace that these new element belong to.
Hope I did not confuse you :roll:
Joined: Jan 06, 2003
If I understand correctly, you mean "address", "name" and "street" element belong to targetNamespace, right? Then no element in above XML schema belong to default namespace. If that's true, no need to define default namespace in schema, am I right? I don't understand "all the XML schema elements must belong to this namespace(defult Namespace)"(from p36 of RMH book). In above XML schema, what are "XML schema elements"? If above XML schema define elementFormDefault="qualified", then "name" and "address" in xml document must belong to targetNamespace, if no elementFormDefault defined, then "name" and "address" in xml document may not from targetNamespace. Am I right? I am still confused, and please help me out. Thanks, Nancy
According to XML-Schema spec. (http://www.w3.org/TR/2004/PER-xmlschema-1-20040318/), we have the following definition of targetNamespace: "[Definition:] Several kinds of component have a target namespace, which is either �absent� or a namespace name, also as defined by [XML-Namespaces]. The �target namespace� serves to identify the namespace within which the association between the component and its name exists. In the case of declarations, this in turn determines the namespace name of, for example, the element information items it may �validate�." And there is a note in the same document: "At the abstract level, there is no requirement that the components of a schema share a �target namespace�. Any schema for use in �assessment� of documents containing names from more than one namespace will of necessity include components with different �target namespaces�. This contrasts with the situation at the level of the XML representation of components, in which [i]each schema document contributes definitions and declarations to a single target namespace[i]."
Thus, single schema definition might address not more than 1 targetNamespace