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 page26

                         

  1. How do I use XML namespaces with SAX 2.0?
    A: SAX 2.0 primarily supports XML namespaces through the following methods: * startElement and endElement in the ContentHandler interface return namespace names (URIs) and local names as well as qualified names. * getValue, getType, and getIndex in the Attributes interface can retrieve attribute information by namespace name (URI) and local name as well as by qualified name
                                                             
  2. How do I use XML namespaces with DOM level 2?
    // Check the local name.
    // getNodeName() is a DOM level 1 method.
    if (elementNode.getNodeName().equals("SalesOrder"))
    {
    // Add new database record.
    }
    might become the following namespace-aware code:
    // Check the XML namespace name (URI).
    // getNamespaceURI() is a DOM level 2 method.
    String SALES_NS = "http://www.foo.com/ito/sales";
    if (elementNode.getNamespaceURI().equals(SALES_NS))
    {
    // Check the local name.
    // getLocalName() is a DOM level 2 method.
    if (elementNode.getLocalName().equals("SalesOrder"))
    {
    // Add new database record.
    }
    }
    Note that, unlike SAX 2.0, DOM level 2 treats xmlns attributes as normal attributes.
                                           
  3. Can an application process documents that use XML namespaces and documents that don't use XML namespaces?
    Yes.
    This is a common situation for generic applications, such as editors, browsers, and parsers, that are not wired to understand a particular XML language. Such applications simply treat all element type and attribute names as qualified names. Those names that are not mapped to an XML namespace -- that is, unprefixed element type names in the absence of a default XML namespace and unprefixed attribute names -- are simply processed as one-part names, such as by using a null XML namespace name (URI).
    Note that such applications must decide how to treat documents that do not conform to the XML namespaces recommendation. For example, what should the application do if an element type name contains a colon (thus implying the existence of a prefix), but there are no XML namespace declarations in the document? The application can choose to treat this as an error, or it can treat the document as one that does not use XML namespaces, ignore the "error", and continue processing.
                                                                                             
  4. Can an application be both namespace-aware and namespace-unaware?
    Yes.
    However, there is generally no reason to do this. The reason is that most applications understand a particular XML language, such as one used to transfer sales orders between companies. If the element type and attribute names in the language belong to an XML namespace, the application must be namespace-aware; if not, the application must be namespace-unaware.
    For a few applications, being both namespace-aware and namespace-unaware makes sense. For example, a parser might choose to redefine validity in terms of universal names and have both namespace-aware and namespace-unaware validation modes. However, such applications are uncommon.
                          
  5. What does a namespace-aware application do when it encounters an error?
    The XML namespaces recommendation does not specify what a namespace-aware application does when it encounters a document that does not conform to the recommendation. Therefore, the behavior is application-dependent. For example, the application could stop processing, post an error to a log and continue processing, or ignore the error.
    PART III: NAMES, PREFIXES, AND URIs
                                            
  6. What is a qualified name?
    A qualified name is a name of the following form. It consists of an optional prefix and colon, followed by the local part, which is sometimes known as a local name.
    prefix:local-part
    --OR--
    local-part
    For example, both of the following are qualified names. The first name has a prefix of serv; the second name does not have a prefix. For both names, the local part (local name) is Address.
    serv: Address
    Address In most circumstances, qualified names are mapped to universal names.
                                              
  7. What characters are allowed in a qualified name?
    The prefix can contain any character that is allowed in the Name [5] production in XML 1.0 except a colon. The same is true of the local name. Thus, there can be at most one colon in a qualified name -- the colon used to separate the prefix from the local name.
                                         
  8. Where can qualified names appear?
    Qualified names can appear anywhere an element type or attribute name can appear: in start and end tags, as the document element type, and in element type and attribute declarations in the DTD. 
    For example:
    <!DOCTYPE foo:A [
    <!ELEMENT foo:A (foo:B)>
    <!ATTLIST foo:A
    foo:C CDATA #IMPLIED>
    <!ELEMENT foo:B (#PCDATA)>
    ]>
    <foo:A xmlns:foo="http://www.foo.org/" foo:C="bar">
    <foo:B>abcd
    <foo:A>
    Qualified names cannot appear as entity names, notation names, or processing instruction targets.
                            

                         

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]