• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Namespace and XML Schema

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In XML Schema, when we define the elements with the target namespace, does it imply that we are defining the name space with the elements defined in the schema?
Another clarification,
When we define an XML document like the following:

<xsl:root xmlns:xsl='http://www.w3.org/XSLT'>
<xsl:child>HELLO</xsl:child>
</xsl:root>

From the above it means that the elements root and child belong to
the namespace http://www.w3.org/XSLT. Right? How does an XSLT application(Transformer) really differentiate the elements that are inbuilt belonging to the w3c XSLT namespace and the elements that i have defined saying that it belongs to the w3c XSLT namespace. How is it said that these are the elements that are belonging to this namespace(from where will get the list of elements that are belonging to a particular namespace, and suppose i have my own domain and i want to associate some of my own tags(elements) to that namespace?)
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In XML Schema, when we define the elements with the target namespace, does it imply that we are defining the name space with the elements defined in the schema?


By associating a target namespace, you are simply telling the parser that the tags defined in the Schema belongs to the specified namespace. This will help the parser distinguish your symbols ie., yourNameSpace:YourTag elements from other tags that may be in the document having the same tag name ie., YourTag. Note that you are defining a new namespace by associating an URI with the namespace. This target namespace is not a resource that actually contains definitions of the tags used. It is simply an unique identifier, a kind of UUID.



When we define an XML document like the following:

<xsl:root xmlns:xsl='http://www.w3.org/XSLT'>
<xsl:child>HELLO</xsl:child>
</xsl:root>

From the above it means that the elements root and child belong to
the namespace http://www.w3.org/XSLT. Right? How does an XSLT application(Transformer) really differentiate the elements that are inbuilt belonging to the w3c XSLT namespace and the elements that i have defined saying that it belongs to the w3c XSLT namespace. How is it said that these are the elements that are belonging to this namespace(from where will get the list of elements that are belonging to a particular namespace, and suppose i have my own domain and i want to associate some of my own tags(elements) to that namespace?)


You are correct. Standard xsl tags are defined in the W3C namespace (http://www.w3.org/XSLT) which is some what like a default namespace for stylesheets. You can declare your own tags that belong to your own namespace and use them in the xsl document. Since xsl tags are already defined by W3C XSLT namespace, if you redefine the same tags your own namespace, it will not conflict the standard names since the namespace prefix would help the XSLT engine to distinguish between what you have defined and it understands as the "standard". Ofcourse, you give the XSLT a "hint" to resolve ambiguities by prefixing the tags with namespace. The ones that don't have any prefix naturally would be associated with the default namespace.
Hope that clarifies your doubts.
Cheers!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Aravind Ravi
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ajith,
Thanks a lot for your reply. It cleared my doubt to a certain extent. I have a my domain(which is a URI- to uniquely identify the namespace) say 'http://www.aravind.com'. Each namespace has a set of vocabulary. Right? When I write an XML document like this,
<aravind:root xmlns:aravind='http://www.aravind.com'>
Aravind Ravi
</aravind:root>

it just means that the element root is associated with the aravind namespace. It does not mean that the element root is now a part of the vocabulary of the aravind namespace.

Am I right in this understanding?

How do my expilicitly say that these are the set of elements(tag names) that can belong to my namespace? and ensure that in the XML document like the above case which has associated the root element to be belonging to my namespace, when I do not want the root element to be defined as a part of my namespace.
Where do I go and specify the list of elements that belong to mynamespace and ensure that no one else tampers with the list of elements(tags)in my namespace?

Thanks once again for your reply,
Aravind Ravi.
-----------------------------------------------------------------
Sun Certified Programmer for the Java2 Platform.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic