XML Interviews Question page17,xml Interviews Guide,xml Interviews

This page discusses - XML Interviews Question page17,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 page17

     

  1. Where can I declare an XML namespace?
    You can declare an XML namespace on any element in an XML document. The namespace is in scope for that element and all its descendants unless it is overridden.
      
  2. Can I use an attribute default in a DTD to declare an XML namespace?
    Yes. 
    For example, the following uses the FIXED attribute xmlns:google on the A element type to associate the google prefix with the http://www.google.org/ namespace. The effect of this is that both A and B are in the http://www.google.org/ namespace.
    <?xml version="1.0" ?>
    <!DOCTYPE google:A [
    <!ELEMENT google:A (google:B)>
    <!ATTLIST google:A
    xmlns:google CDATA #FIXED "http://www.google.org/">
    <!ELEMENT google:B (#PCDATA)>
    ]>
    <!-- google prefix declared through default attribute. -->
    <google:A>
    <google:B>abc</google:B>
    </google:A>
     
    Importent:
    You should be very careful about placing XML namespace declarations in external entities (external DTDs), as non-validating parsers are not required to read these. For example, suppose the preceding DTD was placed in an external entity (google.dtd) and that the document was processed by a non-validating parser that did not read google.dtd. This would result in a namespace error because the google prefix was never declared:
    <?xml version="1.0" ?>
    <!-- google.dtd might not be read by non-validating parsers. -->
    <!DOCTYPE google:A SYSTEM "google.dtd">
    <!-- google prefix not declared unless google.dtd is read. -->
    <google:A>
    <google:B>abc</google:B>
    </google:A>
      
  3. Do the default values of xmlns attributes declared in the DTD apply to the DTD?
    No.
    Declaring a default value of an xmlns attribute in the DTD does not declare an XML namespace for the DTD. (In fact, no XML namespace declarations apply to DTDs.) Instead, these defaults (declarations) take effect only when the attribute is instantiated on an element. For example:
    <?xml version="1.0" ?>
    <!DOCTYPE google:A [
    <!ELEMENT google:A (google:B)>
    <!ATTLIST google:A
    xmlns:google CDATA #FIXED "http://www.google.org/">
    <!ELEMENT google:B (#PCDATA)>
    ]>
    <google:A> <========== Namespace declaration takes effect here.
    <google:B>abc</google:B>
    </google:A> <========= Namespace declaration ends here.
      
  4. How do I override an XML namespace declaration that uses a prefix?
    To override the prefix used in an XML namespace declaration, you simply declare another XML namespace with the same prefix. For example, in the following, the google prefix is associated with the http://www.google.org/ namespace on the A and B elements and the http://www.bar.org/ namespace on the C and D elements. That is, the names A and B are in the http://www.google.org/ namespace and the names C and D are in the http://www.bar.org/ namespace.
    <google:A xmlns:google="http://www.google.org/">
    <google:B>
    <google:C xmlns:google="http://www.bar.org/">
    <google:D>abcd</google:D>
    </google:C>
    </google:B>
    </google:A>
    In general, this leads to documents that are confusing to read and should be avoided.
     

Advertisements

Share on Google+Share on Google+

XML Interviews Question page17,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

Ads
 

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

Post your Comment


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

Ads

 

Ads