Java
  Home arrow Java arrow Page 3 - Integrating XML with J2EE
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Integrating XML with J2EE
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 18
    2004-11-16

    Table of Contents:
  • Integrating XML with J2EE
  • Benefits and Characteristics of XML
  • Structure and Syntax of XML
  • Structure of an XML Document
  • Well-formed XML Documents
  • Namespaces
  • Element Type Declarations
  • XML Schemas
  • Parsing XML
  • Parsing XML Using SAX
  • Document Object Model (DOM) Parser
  • Modifying a DOM Tree
  • Java Architecture for XML Binding
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Integrating XML with J2EE - Structure and Syntax of XML
    (Page 3 of 14 )

    In this section, you will explore the syntax of XML and understand what is meant by a well-formed document.


    Note - You will often encounter the terms "well-formed" and "valid" applied to XML documents. These are not the same. A well-formed document is structurally and syntactically correct (the XML conforms to the XML language definition, that is all tags have a correctly nested corresponding end tag, all attributes are quoted, only valid characters have been used, and so on), whereas a valid document is also semantically correct (the XML conforms to some external definition stored in an XML Schema or Document Type Definition). A document can be well-formed but may not be valid.


    The best way to become familiar with the syntax of XML is to write an XML document. To check your XML, you will need access to an XML-aware browser or another XML validator. The XML-aware browser or XML validator will allow you to ensure that the XML is well-formed. If the XML references an XML Schema or Document Type Definition (more on these later) the validator can also check that the XML is valid.

    An XML browser includes an XML parser. To get the browser to check the syntax and structure of your XML document, simply use the browser to open the XML file. Well-formed XML will be displayed in a structured way (with indentation). If the XML is not well-formed, an appropriate error message will be given.


    Tip - An easy way to validate XML is to use an XML aware browser. The latest versions of most popular browsers are now XML aware. You can download validating XML parsers from Sun Microsystems at http://www.sun.com/software/xml/developers/multischema/ and the Microsoft Developers Network at http://msdn.microsoft.com/downloads/samples/internet/xml/xml_validator/. There are numerous other XML validators and XML editors vailable from the Internet.


    HTML and XML

    At first glance, XML looks very similar to HTML. An XML document consists of elements that have a start and end tag, just like HTML. In fact, Listing 16.1 is both well-formed HTML and XML.

    Listing 16.1 Example XML and HTML

    <html>
    <head><title>Web Page</title></head>
    <body>
    <h1>Teach Yourself J2EE in 21 Days</h1>
    <p>Now you have seen the web page – buy the book</p>
    </body>
    </html> 

    An XML document is only well-formed if there are no syntax errors. If you are familiar with HTML, you will be aware that many browsers are lenient with poorly formed HTML documents. Missing end tags and even missing sections will often be ignored and therefore unnoticed until the page is displayed in a more rigorous browser, and fails to display correctly.

    XML differs from HTML in that a missing end tag will always cause an error.

    We will now look at XML syntax so you can understand what is going on.

    This chapter is from Teach Yourself J2EE in 21 Days, second edition, by Martin Bond et. al. (Sams, 2004, ISBN: 0-672-32558-6). Check it out at your favorite bookstore today. Buy this book now.

    More Java Articles
    More By Sams Publishing


     

       

    JAVA ARTICLES

    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway