1 / 11

XML Problems and Solutions

XML Problems and Solutions. Andy Clark. Attributes vs. Elements. Problem: I can't decide between using attributes and elements. Solution:

mahon
Télécharger la présentation

XML Problems and Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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: • 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. <?xml version=‘1.0’ encoding=‘ISO-8859-1’?>

  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

More Related