Java: A platform for platforms
Sun's reorg may seem promising to shareholders but it's also a scramble for position. The question now is whether Sun can, or wants to, maintain its hold on Java technology. Especially with enterprise leaders like SpringSource and RedHat investing heavily in Java's future as a platform for platforms

Also see:

Discuss: Java: A platform for platforms?

Featured Whitepapers
Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

XML glossary

XML acronyms for Java developers

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 4 of 5

XLink uses XML:Base (see below).

Back to index

XML Base

The XML Base attribute is analogous to the HTML <BASE> element. In HTML, you can use <BASE HREF="http://www.foo.com/"> to instruct the browser to resolve relative URLs using the base given in the href. XML:Base resembles the cd command under DOS or Unix. Here's an example of XML:Base working with XLink:

<doc xml:base="http://foo.com/" xmlns:xlink="http://www.w3.org/1999/xlink">
 <link xlink:type="simple" xlink:href="new.xml">new</link>
</doc>


In the code above, XLink looks for http://foo.com/new.xml when it must resolve the link.

Back to index

XPath

XPath, a language for selecting an XML document's parts, lets you treat an XML document like a filesystem. XPath queries start with a current element or attribute (much like a current directory within a filesystem) and let you specify other nodes relative to your location.

For example, the path ".." takes you to the parent element. "aaa" takes you to a child node called <aaa> and the path "/aaa/*" jumps to the root element called <aaa> and selects the elements inside. While that resembles a filesystem, XPath gets much cleverer. For example:

  • "ccc[5]" selects the fifth <ccc> element
  • "ddd//eee" selects all <eee> elements with ancestors (however distant) called <ddd>
  • "//fff[@name='foo']" selects all <fff> elements with the attribute name set to foo
  • "//ggg/following::*" selects the elements following the first <ggg> element


Xalan, Saxon, Jaxen, and DOM4J let you select nodes using XPath expressions. XPath is particularly valuable here if you use XML to configure an application: rather than digging around your document using DOM or SAX, you can simply request the element you want to read. XPath is the platform upon which XSLT, XPointer, and other technologies are built.

Back to index

XPointer

XPointer closely resembles XPath by letting you specify an XML document's parts. Further, XPointer and XPath share a similar syntax. However, XPointer differs from XPath in that the XPointer specifies only a location or contiguous region of the original document; XPath can select many unconnected elements. Compared to XPath, XPointer allows finer control over what you select, down to selecting parts of a text node.

However, XPointer remains controversial because Sun holds a key XPointer patent which the company refuses to freely license. Instead, Sun licenses it on the condition that XPointer improvements go to the W3C (World Wide Web Consortium). With the license, Sun aims to keep XPointer free, or, to read between the lines, to keep Microsoft from embracing and extending this one.

Back to index

XInclude

Unfortunately, XML documents can quickly become lengthy. XML is quite verbose, and sometimes we just want to store a lot of data. Editing 20 MB files can be memory hungry, and finding your way around them, nearly impossible. XInclude solves the problem by enhancing XML with an <xi:include> element that lets you build composite documents.

XInclude lets you specify a file or URI (Uniform Resource Identifier) that should be treated as if it replaced the <xi:include> element.

Back to index

XSLT

XSLT (Extensible Stylesheet Language Transformations) converts any XML document into another XML, HTML, or plaintext document. Some developers find XSLT difficult to grasp because it is a rule-based language, not primarily a procedural or object-based language (although with effort you can make it work in a procedural way).

With XSLT, you specify a set of rules—called templates—that describe how the output document should be created, for example:

<xsl:template match="data">
 <table border="1">
 <xsl:apply-templates/>
 </table>
<xsl:template>


The above template tells the XSLT processor to find elements in the source document called <data>, then create an HTML table. You would define other templates to create the table's content.

The match="" attribute uses XPath to specify to what elements or attributes the rules apply.

Back to index

Communicate with XML

This section contains technologies that let computers communicate using XML. Each depends on the technologies outlined in the "Develop with XML" and "XML Building Blocks" sections. For example, SOAP (Simple Object Access Protocol) uses XML Schema, and most SOAP implementations expose you to some XML API. I could have called this section a business-to-business section because, generally speaking, we don't expect customers to be using SOAP much.

Messages and methods

Messages and methods represent two closely related XML communication concepts. Methods are synchronous, just like Java method calls (so a method's caller must wait until the method replies before doing anything else). Messages, in contrast, are asynchronous (so the caller sends a message, then carries on; doing so in plain Java requires a new thread, like an email or text message in the real world).

Back to index

SOAP

SOAP (Simple Object Access Protocol), an XML-based protocol, uses HTTP or sometimes SMTP (Simple Mail Transfer Protocol) as a transport layer. SOAP adds a few headers to an HTTP request and, where HTTP would post form parameters, SOAP puts a function call request in XML. You can use SOAP in either a method and messaging style.

SOAP heavily uses XML Schema to define the sent data types. The SOAP equivalent of example.method(42); without headers would look like:

<soap:Envelope xmlns:soap='urn:schemas-xmlsoap-org:soap.v1'>
  <soap:Body>
    <example:method xmlns:example='http://www.example.com'>
      <param>42</param>
    </example:method>
  </soap:Body>
</soap:Envelope>


A big question when it comes to SOAP is: Why, when we already have RMI (Remote Method Invocation), CORBA/IIOP (Internet Inter-ORB Protocol), DCOM (Distributed Component Object Model), and so on, do we need yet another remote method protocol? The simple answer: The others have fatal flaws when interoperating over the Internet. For example, RMI is Java only, IIOP uses too many ports, making it firewall unfriendly, and DCOM is Windows only.

Back to index

XML-RPC

XML-RPC (Remote Procedure Call) resembles SOAP and shares a similar heritage. SOAP was effectively XML-RPC before being developed by the W3C. Despite that "S" in SOAP stands for "simple," in comparison to XML-RPC, SOAP is anything but simple.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources