Welcome!

Java IoT Authors: Pat Romanski, Roger Strukhoff, Liz McMillan, Yeshim Deniz, Elizabeth White

Related Topics: Industrial IoT

Industrial IoT: Article

Applying Java/XML/XSL Technology

Applying Java/XML/XSL Technology

XML/XSL are widely used for publishing and EDI. This article shows how XML/XSL can be used effectively for IT Web development by overcoming the disparities between relational data and XML.

What's the best way to develop Web applications driven by relational databases (the backbone of current IT)? Would the answer lead us down the road to XML/XSL? If so, how can we convert relational data to XML?

In Part 1, I describe the appeal of XSLT as a presentation engine, why we should retrieve relational data as XML, and briefly review how XSQL, a promising tool from Oracle, converts relational data to XML. I'll show how an HTML page's data requirements can be displayed as an XML structure and a set of Java interfaces at the same time.

In Part 2, I'll present a design that lets you obtain these page-level data interfaces from a series of data sources including SQL, Stored Procedures, Java objects, and session beans in a declarative manner, outline why XSLT is not suited for large data sets, and why you should choose JSP in those circumstances.

The Role of XML/XSL/Relational Data in IT Development
Since XML is structured data, its uses are quite extensive. EDI, B2B, and the publishing industry are using XML as part of a central development strategy. But XML hasn't found widespread use yet for IT applications that depend on relational data for the back end and HTML for the browser side. This is contrary to the initial enthusiasm generated by the widespread availability of XSLT. XSLT allows for the true separation of presentation from data so why isn't it used much? In my view, there are two reasons.

First, XSLT as a general purpose transformation language for XML has features and complexity that exceed the needs of simple HTML conversion. XSL transformation source files appear daunting to the first-time developer, thereby hindering their adoption. There's also a latent fear that you might need to access something other than data on the Web page, so you want to be able to use Java on the page as well.

The second reason pertains to the fact that for an IT developer, XML data isn't obvious, so using XSLT isn't encouraged. All an IT developer sees is relational data. Until an efficient mechanism is available to convert this data to XML, the IT developer is not apt to receive the benefits of XSLT.

The first problem is addressed in this article by presenting a template substitution subset of XSLT for HTML transformation, and the second is addressed by a detailed Java-based design that allows conversion of relational data to XML. To allay fears that this is brand-new territory, let me start by reviewing a tool from Oracle called XSQL.

Introduction to XSQL
Using XSQL from Oracle, it's possible to retrieve the output of a set of SQL and Stored Procedures as an XML document. The resulting document can be passed through XSLT for browser consumption. XSQL accomplishes this by embedding SQL and Stored Procedures in an XML document as XML tags to be processed. When processed, this document will have the original XML plus the output of the executed SQL embedded in it. Oracle provides the necessary servlet support for the immediate use of this facility for Web development via XSL and XSLT. The following example demonstrates the central concept of XSQL conversion:

<?xml version="1.0">
<xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo_database">
select 'hello' as Greeting from dual
</xsql:query>

When passed through the XSQL processor, this becomes:

<?xml version="1.0">
<rowset>
<row id="1">
<GREETING>hello</GREETING>
</row>
</rowset>

This means you can construct your XML skeleton and fill it up with rows and columns from Oracle. Note that the conversion from relational to XML in this example took place declaratively. The database and connection details are hidden under the symbolic name "demo_database." XSQL is responsible for managing the connections and all the JDBC-related issues you'd have to worry about if you were writing this in Java.

From the design of tags, it can be easily extrapolated that you can introduce data sources other than relational databases into this framework by providing custom tags and custom tag handlers. It's also possible to carry database inserts, deletes, and updates through XSQL. XSQL is expected to support applications that are Web browser-based, database export/import-based, and XML messaging-related.

XSQL seems to be a good fit if you're using XSLT as your primary presentation engine and you have custom tags for all your data sources, for example, your favorite database environment and your favorite EJB server if you're using EJBs. I'm not too confident this will scale for HTML pages that have to display hundreds of rows and have hundreds of users. This is because the XML has to be fully formed for XSLT. This means you have to retrieve all the rows from the database, and you won't be able to use cursors effectively. I don't see a way to work around this problem as long as XSLT is used. Nevertheless, with a prudent page design, you should be able to develop a good number of form-based, e-commerce applications.

With that said, let me show you a similar design that's more Java-centric and allows for JSP as a transformation engine, in addition to XSLT.

HTML Page Data as an XML Stream
Let's talk about the data needs of an HTML page, irrespective of what business object is being displayed on that page. An HTML page has a series of key/value pairs that define both entry and text fields. It'll also have a series of loop-related data representing the multiple tables, list boxes, and other replicated structures. It's also possible to have loops inside loops, such as list boxes inside tables. This structure can be expressed as XML.

The rationale is that even if you have thousands of pages on your Web site, all their data needs can be satisfied by this same XML structure. This is a powerful abstraction that opens up for Java-based horizontal interfaces (a term borrowed from CORBA architectures). Without further ado, let's see the corresponding XML structure followed by the Java interfaces needed to support the same structure in Java (see Listing 1).

XSLT can retrieve key/value pairs at the root level and also at the row level of every named loop and substitute them into an appropriate XSLT template. Let's see a pair of Java interfaces that a JSP page can use to get access to the same data (see Listing 2).

Page Data Java Interfaces
Page-level data is accessed from the IPageData interface. Loop data is accessed through ILoopData. All URL, session, application-level, and relational data are channeled through these interfaces. This simple model allows for rapid JSP page development.

Using these interfaces has another not so subtle benefit. Loop data can be loaded on a demand basis. As long as the JSP pages walk through this data sequentially, it's possible to use cursors that greatly aid in memory requirements. In a multiuser situation these savings could be significant.

Converting XML to HTML (Sample XSL Page)
To demonstrate the conversion of the resulting XML data to HTML, let me introduce some book-related XML data (see Listing 3).

Listing 4 is a sample of XSLT that converts this data into an HTML file using the XSLT template substitution approach. (More on this approach later.)

Sample JSP Page
Listing 5 shows how the same transformation is accomplished using JSP.

The JSP page starts by obtaining a reference to the IPageData interface. This object reference is passed to the JSP page by a controller servlet. Typically, the same controller servlet passes these IPageData references to all the JSP pages based on their URL name.

The similarities of the XSL and JSP approaches provide an easy migration from one to the other while maintaining the same back-end abstraction. This migration becomes important as you need to move a few of your pages to meet the high volume of your users.

Summary
In Part 1, I discussed why we should adapt XSL and JSP transformations to transform the pervasive relational data to HTML. To support that vision, I proposed a way to convert relational data to XML in such a way that it can be used by both XSL and JSP. I utilized XSQL as one of the approaches for dealing with a set of the same issues and provided an example of how JSP and XSL are applied to the same data stream.

In Part 2 I'll cover a Java-centric design approach for converting the relational data to an XML DOM for access by Xalan, which in turn will be transformed into HTML.

More Stories By Satya Komatenini

Satya Komatineni is Chief Technology Officer of INDENT, Inc and the author of a Java based RAD framework for developing J2EE based HTML applications. The product has the distinction of supporting multiple html transformations (XSL,JSP, proprietary templates) while utilizing the same data abstraction to interact with EJBs, relational databases and ERP systems. After earning an M.S. in Electrical Engineering from Indian Institute of Technology, New Delhi, worked with LAN based collaboration technologies, C++ patterns and frameworks, Java and Web based frameworks in a distributed environment.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...