The xml litmus test understanding when and why to use xml

xiaoxiao2021-03-06  110

Introduction

As the popularity of XML has grown, its usage has spread to every nook and cranny of software application development. This is due to the fact that, unlike previous data formats, XML can easily represent both rigid, highly structured data (such as relational data from a database, program configuration files, or spreadsheets) and semi-structured data (such as a Web page or business document). Besides being able to represent both structured and semi-structured data, XML has a number of characteristics that have caused it to be widely adopted as a data representation format. XML is extensible, platform-independent, and supports internationalization by being fully Unicode compliant. The fact that XML is a text-based format means that when the need arises, one can read and edit XML ...........................

This popularity has meant that in certain cases XML is chosen as a data representation format when it is not the best tool for the job. This article provides a clear set of guidelines for determining when XML is the right choice as a data representation for a particular Situation. Additionally, Some Examples of Appropriate and INAPPRIKEES OF XML Are Described.

The XML Litmus Test

In my article Understanding XML I described some of the benefits of using XML as a data representation format. Due to widespread support for XML across various software platforms, the primary benefit of using XML is that it is easier to interoperate between applications on different platforms using XML than with most other data representation formats. The second major benefit of using XML is a side effect of its popularity. There are a large number of off-the-shelf tools for dealing with XML including parsers, schema languages, query languages, programming models, editors, and much more. No other data representation format has such a wide array of tools for processing instances of the format on so many platforms.The aforementioned benefits give us the XML Litmus Test. XML is the appropriate tool for the job if The Following Criteria Are Satisfied by Choosing XML As The Data Reperestation Format for a Given Application:

There is a need to interoperate across multiple software platforms. One or more of the off-the-shelf tools for dealing with XML can be leveraged when producing or consuming the data. Parsing performance is not critical. The content is not primarily binary content, Such as a music or image file. The Content Does Not Contain Control Characters That Aren't Carriage Return, Line Feed, or Tab Because They Are Illegal in XML.

If The Expected Usage Scenario Does Not Satisfy at Least Four of the Above Criteria, The IT MAY NOT Make Much Sense To Use Xml As The Data Reperestation Format for the Situation In Question.

Even when the usage of XML satisfies the criteria, there are still trade-offs that need to be considered. For example, because XML is a text based format and uses redundant tags for labeling content, there are often complaints about the bloat caused by choosing XML as a data representation format. However, in cases where XML brings the benefit of interoperability and a wide array of technologies for describing and processing the data, then this trade off is worth it. This is exactly the trade off in using XML as the basis for network protocols such as XMPP and SOAP.Using XML as an application configuration file format is another area where a trade-off has to be considered as well. On the surface, XML seems more complex than is needed for most application configuration file needs In Most Cases this is true. Honefits to the table. These benefits include Internationalization, BUILT IN MECHANISMS for Creating Comments and escaping text, and widely deployed tools for consuming and producing XML. It is often the case that the cost of writing a parser for a custom configuration file format, as well as other tools, outweighs any benefits from the formats simplicity over XML. Considering this trade off, XML is usually , But Not Always, The Right Tool for the Job When COMING UP WITH Application Configuration Files.

The Rest of this article applies the xml litmus test to a number of established uses of xml.

Some appriate Uses of XML

XML was originally intended as a language for defining new document formats for the World Wide Web. XML is derived from the Standard Generalized Markup Language (SGML), and can be considered to be a meta-language, a language for defining markup languages. The benefits of using XML on the Web are self-apparent. On a widespread global network such as the World Wide Web, interoperability across platforms is key, as is the fact that it fully supports internationalization by being Unicode compliant.One popular usage of XML on The Web Today Is for XML Syndication Feeds Such AS RSS 1.0 or RSS 2.0. Below Is A Sample RSS 2.0 feed.

MSDN XML Developer Center </ Title></p> <p><link> http://msdn.microsoft.com/xml/ </ link></p> <p><Description> EXTENSIBLE MARKUP LANGUAGE (XML) Is The Universal</p> <p>Format for data on the web. XML Allows Developers to Easily</p> <p>Describe and Deliver Rich, Structured Data from Any Application</p> <p>In a standard, consistent Way. Xml does not replace HTML; Rather,</p> <p>IT is a complementary format.</p> <p></ description></p> <p><item></p> <p><title> XML Files: XPath Selections and Custom Functions,</p> <p>And more </ title></p> <p><link></p> <p>http://msdn.microsoft.com/msdnmag/issues/03/02/xmlfiles/toc.asp</p> <p></ link></p> <p><Description> Get Your Questions About Xpath Selections,</p> <p>Custom Functions, And More Answeled in this Month's Column.</p> <p></ description></p> <p></ item></p> <p><item></p> <p><title> Extreme XML: XML Serialization In the .NET Framework </ Title></p> <p><link></p> <p>http://msdn.microsoft.com/library/en-us/dnexxml/html/xml01202003.asp</p> <p></ link></p> <p><description> Dare Obasanjo Discusses XML Serialization and How</p> <p>You can use it with me .NET Framework to ImproveInteropeRability and Meet W3c Standards.</p> <p></ description></p> <p></ item></p> <p></ CHANNEL></p> <p></ rss></p> <p>Using XML as the data representation format for syndication feeds passes the XML Litmus Test. Interoperability and support for internationalization is a goal of every Web technology, so the benefits of using XML for content syndication is clear in this regard. Secondly, syndication feeds are primarily textual and do not usually contain significant amounts of binary data or control characters. Finally, a number of applications can be built for processing and displaying syndication using off-the-shelf XML technologies. for example, desktop aggregators like RSS Bandit use XSLT for displaying RSS feeds using multiple layouts. Another example is the MSDN Web site, which uses XSLT for rendering RSS feeds to Web browsers in a human readable format as shown by the RSS feed for the MSDN XML Developer Center.</p> <p>Another area where XML usage is beginning to flourish is as the data representation format for business documents. Not only have office productivity suites such as Microsoft Office begun to use XML as the basis of their document storage formats, but a number of vertical industries have standardized on XML schemas for information interchange. Examples of standardized XML vocabularies for information exchange in specific vertical industries include HR-XML for human resources, HL7-XML for the healthcare industry, XBRL for financial reporting, and much more.</p> <p>Applying the criteria in the XML Litmus Test to using XML for representing business documents also shows this to be an appropriate usage of XML. First of all, business documents are primarily text so they satisfy the criteria around binary data and illegal XML characters. When exchanging business documents with other entities, ensuring that the documents are platform neutral is an significant factor. This is particularly important because it is unlikely that different business entities run their software on the same platforms or even that different organizations within a particular business entity are running a homogenous network. In typical usage scenarios for business documents, parsing performance is important. After all, no one wants a word processor to take minutes to load a file, and using XML does not require significant enough overhead to make this suboptimal. Finally, the Wide Array of Tools for Processing XML Comes In Very Handy for Creating and Managing Business Document Wor kflows. Declarative schema languages ​​such as W3C XML Schema and Schematron can be used to enforce constraints on business documents entering or leaving the system. XML Transformation languages ​​such as XSLT can be used to convert between different XML business document formats or publish them as non- XML formats, such as HTML or PDF. Documents can be filtered and routed using XML pattern languages, such as XPath to find documents with characteristics of interest. and the list goes on.An Inappropriate Use of XML</p> <p>One usage of XML that I've considered to be inappropriate is the use of XML as a syntax for programming languages, such as is done in o:. XML Consider the following o: XML fragment for a method that takes three string arguments and returns A Date Element. "" - Procedure Definition -></p> <p><o: procedure name = "ex: formatdate"></p> <p><o: param name = "day" /></p> <p><o: param name = "month" /></p> <p><o: param name = "year" /></p> <p><o: do></p> <p><Date></p> <p><day> <o: evAl select = "$ day" /> </ day></p> <p><MONTH> <o: evAl select = "$ month" /> </ month></p> <p><year> <o: evAl select = "$ Year" /> </ year></p> <p></ date></p> <p></ o: do></p> <p></ o: procedure></p> <p><! - procedure call -></p> <p><! - 'Year' Has A Default Value and So IS Optional -></p> <p><ex: formatdate year = "2002" MONTH = "'aug'" day = "31" /></p> <p>Compare That Snippet To The Following XQuery Expression That Does The Same Thing:</p> <p>Declare Function EX: FORMATDATE ($ MONTH AS XSD: STRING, $ YEAR AS XSD: STRING)</p> <p>As Element (date)</p> <p>{</p> <p><Date></p> <p><day> {$ day} </ day></p> <p><MONTH> {$ Month} </ month></p> <p><Year> {$ Year} </ year></p> <p></ date></p> <p>}</p> <p>EX: Formator, "AUG", "2002")</p> <p>The XQuery version is less verbose than the o: XML version, yet performs the same task The question then is whether the benefits of XML make up for the increased verbosity of the formatDate function in o:.. XML Applying the XML Litmus Test, I 'd say the answer is no. The ASCII-based text format of a language such as XQuery is just as interoperable as creating an equivalent language with similar identifiers, but using XML instead. Secondly, of the myriad tools for working with XML, the main one that applies in the case of o: XML is the existence of XML parsers that make processing language tokens in o:. XML easier than parsing XQuery However, as someone who's written his share of language parsers, in a previous life I designed and implemented SiXDML, I'd argue that the bulk of the work of creating a compiler has little to do with processing language tokens and more to do with the execution logic. The amount of development time saved is a small part of the overall cost of writing a compiler. HOWEVER, EVERY User of the language now Has to DEAL with the more complex syntax of the language and incsearated verbositi chosing o: XML over xquery.conclusion</p> <p>XML is a powerful tool in the software developer's toolbox, but like all tools it has tasks it is excels at and others for which it is not as well suited. The XML Litmus Test provides a simple set of guidelines for weighing the costs and benefits of Using XML IN A Software Application Or Architecture.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-103926.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="103926" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.054</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'fTz1KZW2kB24V0ZDG5_2FJUcbgJg1Egpm_2FgbuGHXXBa7RnfqKWinpAvqLSlmQe8z1CQCZxL_2BjmNp80vZxB6R2isg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>