background preloader

Xml

Facebook Twitter

XSLT

Patterns. Learn 10 good XML usage habits. Introduction You love XML and the flexibility and interoperability that it offers, but you can do some things to make your interaction with XML and the tools that you use to work with it significantly easier. Picking up some basic good habits when you work with XML will ensure that you get the most efficient use out of your XML documentations and applications. Back to top Adopt 10 good habits Here are the top 10 good XML habits to adopt: Define your XML and encoding When you create an XML document quickly, it can be very tempting to create the basic structure and eschew the normal XML document requirements of specifying the XML declaration and the encoding type of the data that the XML document contains.

Consider the XML document in Listing 1. Listing 1. <phrases><phrase lang="en">Hello</phrase><phrase lang="it">Buongiorno</phrase><phrase lang="fr">Salut! As a human, you can look at that document and identify it as XML, but it is more difficult for a computer to achieve the same determination.

E4X: JavaScript on steroids. E4X adds support for XML to the JavaScript programming language. XML is widely recognized as the universally accepted means to exchange documents and data across applications and platforms. This recognition is a direct function of XML's proven track record as an efficient way to resolve interoperability problems associated with sharing documents and data. XML's versatility and strength are products of the flexibility of its structural components. E4X facilitates the use of XML's structural components, thereby enhancing that flexibility significantly. E4X is designed to simplify the task of writing JavaScript code for XML. The JavaScript language uses the E4X utility to impart new properties to global objects. E4X consumes less development time and has a very short learning curve.

To demonstrate the power and flexibility of E4X, I describe the main features employed to manipulate XML data, using a music catalog as the main input source. Listing 1. Creating the XML object Listing 2. Validating XML in PHP. Ensure data integrity and validate XML documents against an XML schema in PHP Brian CareyPublished on November 10, 2009 Why XML validation? XML is a markup language that enables you, as a developer, to create your own custom language.

This language is then used to carry, but not necessarily display, data in a platform-independent fashion. The language is defined with the use of markup tags, much like Hypertext Markup Language (HTML). XML has gained in popularity in recent years because it represents the best of two worlds: It is easily readable by humans and computers alike. Now, for example, suppose you create your own XML language, called LuresXML. Listing 1. lures.xsd This is, quite intentionally, a fairly simple example. Now, say you want to create an XML document (sometimes called an instance) based on that schema. Listing 2. lures.xml This is a simple XML document instance of the schema from Listing 1. Note the lureQuantity element as defined in Listing 1. Simple XML parsing in PHP. Harness XML with PHP 5 extensions. High performance access to file storage Hands on PHP is one of the most commonly used languages for developing web sites while XML has become an industry standard for exchanging data.

Increasingly, web sites use XML to transfer data through web feeds such as RSS and Atom, or through web services. PHP 5 XML extensions provide support for parsing, transformation, XPath navigation, and schema validation of XML documents. The SimpleXML extension in PHP 5 simplifies node selection by converting an XML document to a PHP object that may be accessed with property selectors and array iterators. The XSL extension in PHP 5 is used to transform an XML document. In this article, I'll show you how to process an example XML document, catalog.xml using the PHP 5 XML extensions. First things first, though. Extension=php_xsl.dll Restart Apache Server after modifying php.ini. Create your XML $domDocument = new DOMDocument('1.0','utf-8'); An element is represented with the DOMElement class. Part I : XRX Architecture - Unleashed. What is so unique about XRX architecture...? Generally, web application architectures accept inputs from HTML forms, which provide the user inputs in flat key-value pairs, thereafter these data structures are converted to middle tier objects such as Java or .Net and then transformed into tabular data streams so they can be stored in relational databases.

Once in the relational database, the data must then be re-serialized by doing SELECT statements, converted into objects and the objects then converted back into HTML forms. This is four-step translation architecture. In contrast to the above discussed conventional approach, XRX uses the zero-translation architecture. Zero translation implies that XML is stored in the web client, transmitted to a middle tier validation rules engine in XML and then stored in its entirety in an XML database.