Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Problems and Solutions

Similar presentations


Presentation on theme: "XML Problems and Solutions"— Presentation transcript:

1 XML Problems and Solutions
Andy Clark 17 Apr 2002

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: Solution: The DOM tree uses a lot of memory.
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: Solution:
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: Solution:
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: Solution:
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 ". By default, XML parsers assume "UTF-8". [Note that ASCII is equivalent to UTF-8 chars ] e.g. <?xml version=‘1.0’ encoding=‘ISO ’?>

8 Publish as HTML Problem: Solution:
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: Solution:
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) XML.com
XML.com

11 XML Problems and Solutions
Andy Clark


Download ppt "XML Problems and Solutions"

Similar presentations


Ads by Google