Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Features

Struts Tutorials
*Stuts TOC
*Apache Struts Introduction
* Struts Controller
* Struts Action Class
* Struts ActionFrom Class
* Using Struts HTML Tags
*Struts Validator Framework    
*Client Side Address Validation    
*Struts Tiles
*tiles-defs.xml
*Struts DynaActionForm
*Struts File Upload
*Struts DataSource
*AGGREGATING ACTIONS
*Internationalization
Struts Resources
*Struts Books
*Struts Articles
*Struts Frameworks
*Struts IDE
*Struts Links
*Struts Presentations
*Struts Projects
*Struts Software
*Other Struts Tutorial
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

XML Interviews Question page22

                         

  1. From other XML namespaces?
    A: Yes and no.The answer to this question is yes in the sense that a qualified name in a content model can have a different prefix than the qualified name of the element type being declared. For example, the following is legal:
    <!ELEMENT google:A (bar:B, baz:C)>
    The answer to this question is no in the sense that XML namespace declarations do not apply to DTDs so the prefixes used in an element type declaration are technically meaningless. In particular, they do not specify that the name of a certain element type belongs to a certain namespace. Nevertheless, the ability to mix prefixes in this manner is crucial when: a) you have a document whose names come from multiple XML namespaces , and b) you want to construct that document in a way that is both valid and conforms to the XML namespaces recommendation .
                                                   
  2. Can the attribute list of an element type contain attributes whose names come from other XML namespaces?
    Yes and no.
    For example, the following is legal:
    <!ATTLIST google:A
    bar:B CDATA #IMPLIED>
                             
  3. How can I construct an XML document that is valid and conforms to the XML namespaces recommendation?
    In answering this question, it is important to remember that:
    * Validity is a concept defined in XML 1.0,
    * XML namespaces are layered on top of XML 1.0 , and
    * The XML namespaces recommendation does not redefine validity, such as in terms of universal names .
    Thus, validity is the same for a document that uses XML namespaces and one that doesn't. In particular, with respect to validity:
    * xmlns attributes are treated as attributes, not XML namespace declarations.
    * Qualified names are treated like other names. For example, in the name google:A, google is not treated as a namespace prefix, the colon is not treated as separating a prefix from a local name, and A is not treated as a local name. The name google:A is treated simply as the name google:A.
    Because of this, XML documents that you might expect to be valid are not. For example, the following document is not valid because the element type name A is not declared in the DTD, in spite of the fact both google:A and A share the universal name {http://www.google.org/}A:
    <?xml version="1.0" ?>
    <!DOCTYPE google:A [
    <!ELEMENT google:A EMPTY>
    <!ATTLIST google:A
    xmlns:google CDATA #FIXED "http://www.google.org/"
    xmlns CDATA #FIXED "http://www.google.org/">
    ]>
    <A/>
    Similarly, the following is not valid because the xmlns attribute is not declared in the DTD:
    <?xml version="1.0" ?>
    <!DOCTYPE A [
    <!ELEMENT A EMPTY>
    ]>
    <A xmlns="http://www.google.org/" />
    Furthermore, documents that you might expect to be invalid are valid. For example, the following document is valid but contains two definitions of the element type with the universal name {http://www.google.org/}A:
    <?xml version="1.0" ?>
    <!DOCTYPE google:A [
    <!ELEMENT google:A (bar:A)>
    <!ATTLIST google:A
    xmlns:google CDATA #FIXED "http://www.google.org/">
    <!ELEMENT bar:A (#PCDATA)>
    <!ATTLIST bar:A
    xmlns:bar CDATA #FIXED "http://www.google.org/">
    ]>
    <google:A>
    <bar:A>abcd</bar:A>
    </google:A>
    Finally, validity has nothing to do with correct usage of XML namespaces. For example, the following document is valid but does not conform to the XML namespaces recommendation because the google prefix is never declared:
    <?xml version="1.0" ?>
    <!DOCTYPE google:A [
    <!ELEMENT google:A EMPTY>
    ]>
    <google:A />
    Therefore, when constructing an XML document that uses XML namespaces, you need to do both of the following if you want the document to be valid:
    * Declare xmlns attributes in the DTD.
    * Use the same qualified names in the DTD and the body of the document.
    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 EMPTY>
    ]>
    <google:A>
    <google:B />
    </google:A>
    There is no requirement that the same prefix always be used for the same XML namespace. For example, the following is also valid:
    <?xml version="1.0" ?>
    <!DOCTYPE google:A [
    <!ELEMENT google:A (bar:B)>
    <!ATTLIST google:A
    xmlns:google CDATA #FIXED "http://www.google.org/">
    <!ELEMENT bar:B EMPTY>
    <!ATTLIST bar:B
    xmlns:bar CDATA #FIXED "http://www.google.org/">
    ]>
    <google:A>
    <bar:B />
    </google:A>
    However, documents that use multiple prefixes for the same XML namespace or the same prefix for multiple XML namespaces are confusing to read and thus prone to error. They also allow abuses such as defining an element type or attribute with a given universal name more than once, as was seen earlier. Therefore, a better set of guidelines for writing documents that are both valid and conform to the XML namespaces recommendation is:
    * Declare all xmlns attributes in the DTD.
    * Use the same qualified names in the DTD and the body of the document.
    * Use one prefix per XML namespace.
    * Do not use the same prefix for more than one XML namespace.
    * Use at most one default XML namespace.
    The latter three guidelines guarantee that prefixes are unique. This means that prefixes fulfill the role normally played by namespace names (URIs) -- uniquely identifying an XML namespace -- and that qualified names are equivalent to universal names, so a given universal name is always represented by the same qualified name. Unfortunately, this is contrary to the spirit of prefixes, which were designed for their flexibility. For a slightly better solution.

                         

Ask programming questions?

 

 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.

[an error occurred while processing this directive]