XML Interviews Question page21,xml Interviews Guide,xml Interviews

This page discusses - XML Interviews Question page21,xml Interviews Guide,xml Interviews

Ads

Tutorials   
XML Interviews Question page8,xml Interviews Guide,xml Interviews XML Interviews Question page7,xml Interviews Guide,xml Interviews XML Interviews Question page6,xml Interviews Guide,xml Interviews XML Interviews Question page5,xml Interviews Guide,xml Interviews XML Interviews Question page1,xml Interviews Guide,xml Interviews XML Interviews Question page30,xml Interviews Guide,xml Interviews XML Interviews Question page29,xml Interviews Guide,xml Interviews XML Interviews Question page28,xml Interviews Guide,xml Interviews XML Interviews Question page27,xml Interviews Guide,xml Interviews XML Interviews Question page26,xml Interviews Guide,xml Interviews XML Interviews Question page25,xml Interviews Guide,xml Interviews XML Interviews Question page24,xml Interviews Guide,xml Interviews XML Interviews Question page23,xml Interviews Guide,xml Interviews XML Interviews Question page22,xml Interviews Guide,xml Interviews XML Interviews Question page21,xml Interviews Guide,xml Interviews XML Interviews Question page1,xml Interviews Guide,xml Interviews XML Interviews Question page18,xml Interviews Guide,xml Interviews XML Interviews Question page17,xml Interviews Guide,xml Interviews XML Interviews Question page16,xml Interviews Guide,xml Interviews XML Interviews Question page15,xml Interviews Guide,xml Interviews XML Interviews Question page14,xml Interviews Guide,xml Interviews XML Interviews Question page13,xml Interviews Guide,xml Interviews XML Interviews Question page11,xml Interviews Guide,xml Interviews XML Interviews Question page1,xml Interviews Guide,xml Interviews XML Interviews Question page21 XML Interviews Question page19 XML Interviews Question page12 XML Interviews Question page10 XML Interviews Question page9 XML Interviews Question page3 XML Interviews Question
Ads

XML Interviews Question page20

     

  1. When should I use the default XML namespace instead of prefixes?
    This is purely a matter of choice, although your choice may affect the readability of the document. When elements whose names all belong to a single XML namespace are grouped together, using a default XML namespace might make the document more readable. 
    For example:
    <!-- A, B, C, and G are in the http://www.google.org/ namespace. -->
    <A xmlns="http://www.google.org/">
    <B>abcd</B>
    <C>efgh</C>
    <!-- D, E, and F are in the http://www.bar.org/ namespace. -->
    <D xmlns="http://www.bar.org/">
    <E>1234</E>
    <F>5678</F>
    </D>
    <!-- Remember! G is in the http://www.google.org/ namespace. -->
    <G>ijkl</G>
    </A>
       
    When elements whose names are in multiple XML namespaces are interspersed, default XML namespaces definitely make a document more difficult to read and prefixes should be used instead. 
    For example:
    <A xmlns="http://www.google.org/">
    <B xmlns="http://www.bar.org/">abcd</B>
    <C xmlns="http://www.google.org/">efgh</C>
    <D xmlns="http://www.bar.org/">
    <E xmlns="http://www.google.org/">1234</E>
    <F xmlns="http://www.bar.org/">5678</F>
    </D>
    <G xmlns="http://www.google.org/">ijkl</G>
    </A>
    In some cases, default namespaces can be processed faster than namespace prefixes, but the difference is certain to be negligible in comparison to total processing time.
       
  2. What is the scope of an XML namespace declaration?
    The scope of an XML namespace declaration is that part of an XML document to which the declaration applies. An XML namespace declaration remains in scope for the element on which it is declared and all of its descendants, unless it is overridden or undeclared on one of those descendants.
    For example, in the following, the scope of the declaration of the http://www.google.org/ namespace is the element A and its descendants (B and C). The scope of the declaration of the http://www.bar.org/ namespace is only the element C.
    <google:A xmlns:google="http://www.google.org/">
    <google:B>
    <bar:C xmlns:bar="http://www.bar.org/" />
    </google:B>
    </google:A>
       
  3. Does the scope of an XML namespace declaration include the element it is declared on?
    Yes.
    For example, in the following, the names B and C are in the http://www.bar.org/ namespace, not the http://www.google.org/ namespace. This is because the declaration that associates the google prefix with the http://www.bar.org/ namespace occurs on the B element, overriding the declaration on the A element that associates it with the http://www.google.org/ namespace.
    <google:A xmlns:google="http://www.google.org/">
    <google:B xmlns:google="http://www.bar.org/">
    <google:C>abcd</google:C>
    </google:B>
    </google:A>
    Similarly, in the following, the names B and C are in the http://www.bar.org/ namespace, not the http://www.google.org/ namespace because the declaration declaring http://www.bar.org/ as the default XML namespace occurs on the B element, overriding the declaration on the A element.
    <A xmlns="http://www.google.org/">
    <B xmlns="http://www.bar.org/">
    <C>abcd</C>
    </B>
    </A>
    A final example is that, in the following, the attribute name D is in the http://www.bar.org/ namespace.
    <google:A xmlns:google="http://www.google.org/">
    <google:B google:D="In http://www.bar.org/ namespace"
    xmlns:google="http://www.bar.org/">
    <C>abcd</C>
    </google:B>
    </google:A>
    One consequence of XML namespace declarations applying to the elements they occur on is that they actually apply before they appear. Because of this, software that processes qualified names should be particularly careful to scan the attributes of an element for XML namespace declarations before deciding what XML namespace (if any) an element type or attribute name belongs to.

Advertisements

Share on Google+Share on Google+

XML Interviews Question page21,xml Interviews Guide,xml Interviews

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: XML Interviews Question page21,xml Interviews Guide,xml Interviews  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads