XML Problems and Solutions - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

XML Problems and Solutions

Description:

With DTDs, attributes offer limited 'datatype' support but are ... I want to embed binary data in my document but the parser complains about invalid characters. ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 12
Provided by: AndyC69
Learn more at: http://people.apache.org
Category:

less

Transcript and Presenter's Notes

Title: XML Problems and Solutions


1
XML Problems and Solutions
  • Andy Clark

2
Attributes vs. Elements
  • Problem
  • I can't decide between using attributes and
    elements.
  • Solution
  • With DTDs, attributes offer limited "datatype"
    support but are less flexible. XML Schema (among
    other schema languages) have true datatype
    support and can be used for attribute and element
    content.

3
DOM Performance
  • Problem
  • The DOM tree uses a lot of memory.
  • Solution
  • Don't use DOM. Instead, use a SAX parser and
    build custom, efficient data structures as
    needed.

4
Java Serialization of DOM
  • Problem
  • I want to use RMI to serialize my document to a
    remote object but it's not working.
  • Solution
  • DOM tree implementations are not required to be
    serializable. And since the XML format is a more
    efficient representation than Java serialization,
    use a serializable object that writes XML and
    re-parse the document on the remote end.

5
Relational Databases
  • Problem
  • I have heard XML is the next "big thing". Do I
    have to throw away my relational database?
  • Solution
  • All of the major relational database vendors are
    incorporating XML support into their products.
    Your legacy data is safe and will play well with
    all of the new kids in town.

6
Binary Data in XML
  • Problem
  • I want to embed binary data in my document but
    the parser complains about invalid characters.
  • Solution
  • The XML specification does not allow all Unicode
    characters to appear in a document. The binary
    data must be encoded using legal XML characters
    (e.g. base64). The application is then
    responsible for decoding the information.

7
Invalid Encoding
  • Problem
  • I am using ISO Latin 1 characters in my document
    but my parser doesn't like it.
  • Solution
  • You must specify the proper encoding in the XML
    Declaration line of your XML file. The encoding
    name for ISO Latin 1 is "ISO-8859-1". By default,
    XML parsers assume "UTF-8". Note that ASCII is
    equivalent to UTF-8 chars 0-127.
  • e.g. lt?xml version1.0 encodingISO-8859-1?gt

8
Publish as HTML
  • Problem
  • I want my customers to view an HTML version of my
    XML data. What can I do?
  • Solution
  • Use XSL stylesheets to transform your XML
    documents into HTML. Using stylesheets separates
    the content from the presentation and makes it
    easy to change the "look feel" of your website
    without changing your data.

9
Browser Support
  • Problem
  • Can I use the DOM and XSL in browsers on the
    client side?
  • Solution
  • Some of the latest browsers have support for
    latest DOM and XSL standards (e.g. IE 6.0). Best
    suggestion is to statically generate the pages,
    if applicable, or dynamically generate the HTML
    on the server side (e.g. using servlets).

10
Useful Links
  • World Wide Web Consortium (W3C)
  • http//www.w3.org/
  • XML.com
  • http//www.xml.com/

11
XML Problems and Solutions
  • Andy Clark
Write a Comment
User Comments (0)
About PowerShow.com