Welcome!

Java IoT Authors: Elizabeth White, Yeshim Deniz, Liz McMillan, Pat Romanski, ManageEngine IT Matters

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 Datanami has been named “Media Sponsor” of 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. Datanami is a communication channel dedicated to providing insight, analysis and up-to-the-minute information about emerging trends and solutions in Big Data. The publication sheds light on all cutting-edge technologies including networking, storage and applications, and the...
SYS-CON Events announced today that EnterpriseTech has been named “Media Sponsor” of 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. EnterpriseTech is a professional resource for news and intelligence covering the migration of high-end technologies into the enterprise and business-IT industry, with a special focus on high-tech solutions in new product development, workload management, increased effi...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
In this presentation, Striim CTO and founder Steve Wilkes will discuss practical strategies for counteracting fraud and cyberattacks by leveraging real-time streaming analytics. In his session at @ThingsExpo, Steve Wilkes, Founder and Chief Technology Officer at Striim, will provide a detailed look into leveraging streaming data management to correlate events in real time, and identify potential breaches across IoT and non-IoT systems throughout the enterprise. Strategies for processing massive ...
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of 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. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organi...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
SYS-CON Events announced today that TMC has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo and Big Data at Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Global buyers rely on TMC’s content-driven marketplaces to make purchase decisions and navigate markets. Learn how we can help you reach your marketing goals.
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
"MobiDev is a Ukraine-based software development company. We do mobile development, and we're specialists in that. But we do full stack software development for entrepreneurs, for emerging companies, and for enterprise ventures," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of 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. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
Multiple data types are pouring into IoT deployments. Data is coming in small packages as well as enormous files and data streams of many sizes. Widespread use of mobile devices adds to the total. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists looked at the tools and environments that are being put to use in IoT deployments, as well as the team skills a modern enterprise IT shop needs to keep things running, get a handle on all this data, and deliver...
The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.