Welcome!

Industrial IoT Authors: Liz McMillan, Pat Romanski, Ravi Rajamiyer, Stackify Blog, Yeshim Deniz

Related Topics: Industrial IoT

Industrial IoT: Article

Getting Up To Speed With XML

Getting Up To Speed With XML

XML. And XSLT, DTD, XPath, XSL-FO, XLink, XPointer, SAX, and DOM. To the uninitiated, all the talk about XML quickly dissolves into an alphabet soup of W3C recommendations, abbreviations, and acronyms.

This column, with a minimum of technobabble and a good dose of hands-on work, aims to indoctrinate you into the world of XML and to teach you how to use it for Web publishing. In the next 12 issues of XML-Journal, I'll use tutorials to expand your knowledge of XML and, after the first couple of columns, expose you to a different member of the XML family of technologies or to one of its close relatives.

Today I'll introduce you to XML and show how to create a simple XML document. The next column will pick up where this one leaves off and will discuss the fundamentals of structuring and marking up data. Subsequent columns will address such core XML technologies as XSL, DTDs, and XLink. Later in the year I'll turn to more advanced XML topics and related technologies: XSLT, XSL-FO, XML Schema, XPath, DOM, SAX, JSP, and Web publishing frameworks such as Apache Cocoon. Along the way I'll also touch on Cascading Style Sheets (CSS), XHTML, and Wireless Markup Language (WML) as well as on XML parsers, XSL processors, and a few handy XML tools.

To help you learn, each column will assign some related hands-on work to spur you to think about and work with the technology. The work will be of two kinds: 1. Reading references: To provide additional information.

2. Working with XML code or files: The coding will, at least during the first few columns, center on converting your résumé to XML and readying it for publication on the Web.

The degree of difficulty of the hands-on work - and indeed the column itself - is geared toward new users of XML, though I'll assume you have some knowledge of HTML. The column's primary target audience is anyone without a formal programming background - content authors, Web designers, HTML coders, technical writers, and amateur programmers - who wants to learn XML. Others are, of course, welcome, too.

For continuity each column will be structured in a similar manner. It will begin with an introduction that lays out its objectives and scope. The next section will present the background, concepts, and terminology necessary to understand the tutorial and to perform the hands-on work. Then the tutorial will demonstrate how to develop and apply the XML technology in question. The column's final section will assign a new hands-on task, review last month's column, and address e-mail from readers. Throughout the column I'll provide plenty of points of departure - references and resources, both online and in books - that you can pursue to find out more about those aspects of XML that interest you. As we proceed in this way, each subsequent column will extend the knowledge gained the previous month.

All this talk about XML begs the question: What is it anyway? And what about the jumble of abbreviations that cloaks XML from the curious eyes of an HTML coder or content author? How do XSLT, DTD, XLink, and all the rest fit into the XML equation?

Extensible Markup Language is, first and foremost, a metalanguage for describing and structuring data with tags. Metalanguage means a language used to describe other languages. Like HTML, XML uses tags (words bracketed by "<" and ">"), but, unlike HTML, XML has neither a predefined set of tags nor rules on how to use them (though XML does have generic rules governing markup; for instance, tags may not overlap). In XML, tags and their rules or grammar are defined by the users themselves. XML programmers use tags and their corresponding grammar to describe and structure data in a simple text format similar to HTML (as opposed to a binary format). Because users can define their own tags, XML, as its full name implies, is also extensible, meaning that unlike HTML it's capable of being extended. You'll begin learning how to create your own XML tags today in the tutorial section.

The hodgepodge of abbreviations and acronyms surrounding XML points up another of its characteristics: it's a family of technologies designed to be used over the Internet. Some of XML's family members and their main functions are as follows.

  • Extensible Stylesheet Language (XSL) XSL comprises Extensible Stylesheet Language Transformations (XSLT) and Extensible Stylesheet Language Formatting Objects (XSL-FO). It's an XML-based language for expressing stylesheets. XSLT is a language for transforming XML documents into (typically) other XML documents, HTML, and WML. XSL-FO is used to format XML documents for printing. My third column will present a tutorial on XSLT. Later columns will delve into XSL-FO and expand on XSLT.
  • Document Type Definition (DTD) Stemming from Standard Generalized Markup Language, the progenitor of both HTML and XML, a DTD defines the rules that constrain an XML document or a set of XML documents. In my fourth column I'll teach you how to construct a DTD.
  • XML Schema Thankfully we've been spared yet another abbreviation to remember. XML Schema may eventually supplant DTDs as the primary mechanism for constraining XML data. An XML Schema, which is in the format of an XML document, serves the same function as a DTD while correcting some of its limitations. This column will cover XML Schema later in the year.
  • XLink, XPath, and XPointer Together these provide the foundation for creating links and asserting relationships within and among XML documents. XLink describes how to create hyperlinks among XML documents and provides mechanisms for advanced capabilities such as multidirectional linking. XPath, widely used by XSLT, allows users to locate specific nodes or node sets within XML documents (you'll learn about nodes in the next column). XPointer specifies how to describe and point to locations of various kinds within an XML document. My fifth column will address linking in XML. For a quick description of it, check out "XML Linking: An Introduction" at www.stg.brown.edu/~sjd/xlinkintro.html.
  • Namespaces A specification that describes how to associate a URL with all the tags in an XML document to ensure they're unique, thereby eliminating ambiguity when the same tag is used by different XML coders. I'll introduce you to namespaces after we move through some of the more fundamental aspects of XML.
  • The Document Object Model (DOM) and the Simple API for XML (SAX) The Document Object Model, an application programming interface (API), is used to represent the structure and content of XML (and other) documents and provides an interface that allows programs and scripts to manipulate them. SAX, like DOM, also allows applications to get information from an XML document and do something with it. This column will provide an introductory tutorial on DOM and SAX toward the end of the year.
These are some of the XML-related technologies relevant to a broadly focused XML tutorial. As you may have guessed, there's a plethora of other XML-related specifications and applications, most of which are still evolving: XML Query, XML Base, XML Signature and Canonicalization, XML Protocol, MathML, SMIL, SVG, and FpML, to name a few. You can visit the World Wide Web Consortium's (W3C) Web site, www.w3c.org, for the rundown on most of these initiatives.

For a more complete description of what XML is and what its core-related technologies are, I'd like you to read two short pieces: an article on the W3C Web site called "XML in 10 Points," at www.w3.org/XML/1999/XML-in-10-points, and the first half of Chapter 1 in Brett McLaughlin's book, Java and XML, published by O'Reilly. For a slightly more technical introduction to XML, visit www.xml.com/pub/a/98/10/guide0.html.

Now that you have a sense of what XML is, let's jump into the language and begin working with it by creating a simple XML document from the top down.

An XML document typically comprises several fundamental components, all of which must be enclosed in angle brackets ("<" and ">"):

  • A processing instruction containing an XML declaration; this should be the first line of your XML document
  • A document type declaration
  • A root element
  • Other elements
  • Attributes
  • Comments
Processing instructions, which identify a task for an application to execute, start with <? and end with ?>. XML documents begin with a processing instruction that contains an XML declaration:

<?xml version="1.0" standalone="yes"?>

The attribute-value pair version="1.0" signals to the XML processor that the document conforms to version 1.0 of the XML specification, which was developed under the auspices of the W3C and is available at www.w3.org/TR/2000/REC-xml-20001006. The stand-alone attribute, which is optional and takes yes or no in either single or double quotation marks as its value, specifies whether an external DTD is required to parse the XML document. If the value of "standalone" is yes, an external DTD is not required.

Document type declarations, not to be confused with document type definitions, begin with <!DOCTYPE and perform two functions. They provide a list of document type definitions or specify the location of the file's external document type definition, and they identify the document's root element, also called its root node. Since XML documents don't need a document type definition to be well formed, I will, for now, skip this aspect of the declaration.

A root element, however, is required. All XML documents must have one (though it's not required to be declared with a document type declaration if the document doesn't use an internal or external DTD). In the following declaration, the root element is the word after <!DOCTYPE:

<!DOCTYPE resume>

Remember, you define your own tags in XML, so the root element can be any combination of permitted characters that you choose. Even though the root element has been specified in the document type declaration, it must still appear as the document's first element:

<resume>

Besides a root element, XML documents typically contain a hierarchy of other elements, as this example shows:

<contactInfo>
<name>Steve Hoenisch</name>
<email>[email protected]</email>
<phone></phone>
<address type="business">
<street>10 First Avenue</street>
<city>New York</city>
<state>New York</state>
<zip>10101</zip>
</address>
</contactInfo>
All elements, including the root, may optionally take one or more attribute-value pairs:

<resume name="Hoenisch" field="IT" date="February 2001">

In XML, all values of attributes, including those in the processing instructions and declarations, must be enclosed in either single or double quotation marks. XML is not forgiving like HTML: no quotation marks around attribute values, no disco.

Comments begin with <!-- and end with -->. Almost anything except a double hyphen ("--") may be placed inside the comment tags and be ignored by the XML processor. Comments may appear anywhere after the XML declaration. They may not, however, be embedded inside an element tag: <resume <!-- my resume ... -->> won't work.

Listing 1 shows how these fundamental components can appear together in a simple document.

Let's consider some markup rules to which XML documents must adhere to be considered well formed. A well-formed document is one that conforms to XML syntax rules and contains correctly positioned elements and attributes. A valid XML document, in contrast, is one that conforms to the constraints of its DTD. For more on well-formed and valid documents, see Robert Eckstein's XML Pocket Reference, published by O'Reilly.

First, notice in Listing 1 that some of the elements are in mixed case. Unlike HTML, XML is case-sensitive: <contactinfo> is, to the XML processor parsing your document, a completely different tag from <contactInfo>. Though it doesn't matter what case or combination of cases you use, the name of an opening tag must match the name of its closing tag; otherwise your XML document is not well formed and the XML parser will fail to process it.

Second, an empty element - that is, one that contains no other elements or text, like <phone/> in the previous examples - must have a closing tag, which may be combined with the starting tag. Thus an empty element can be marked up either as <phone></phone> or as <phone/>.

Third, every nonempty element's opening tag must have a corresponding closing tag. If you open a nonempty element with <resume>, it must have a corresponding closing tag of </resume> that's properly nested, which brings us to our fourth rule: XML documents, again unlike HTML, may not contain any overlapping tags. Whereas <h2> Headline</h2> might work in HTML, it won't in XML.

Finally, as I've already mentioned, all attribute values must be enclosed in either single or double quotes.

Now I'd like you to start getting your hands dirty with XML by doing the following work to prepare for my next column:

  • Make sure you have version 5.0 or greater of Microsoft Internet Explorer installed on your computer. You can download it for free from www.microsoft.com/windows/ie/. Internet Explorer's XML parser allows you to debug and view XML files, and we'll be using it to do just that.
  • Use Notepad or, better, UltraEdit, a trial version of which is available at www.ultraedit.com/, to mark up your résumé or part of it with tags using not only elements but also attributes. As you do so, try to create tags that describe the structure or content of your résumé. Also, think about what aspects of your résumé's structure or content should be captured in attributes as opposed to elements. Don't worry about using a document type definition (but remember to set the value of the stand-alone attribute in the XML declaration to yes):

    <?xml version="1.0" standalone="yes"?>)

  • Edit your marked-up document to make sure it's well formed, according to the rules I set out. Save it on your hard drive as a plain old text file (ASCII or Unicode on Windows NT) with an .xml file extension.
  • Next, open it in Internet Explorer and use Explorer to debug any problems with your markup. If you didn't craft your tags according to the rules I described, Explorer will display an error message that usually provides enough information to find and fix the offending code. Continue debugging your file until it displays as an XML page.
In next month's column I'll review an example of this hands-on assignment as well as cover the XML hierarchical tree model, examine different approaches to tagging, and discuss the importance of structured data.

More Stories By Steve Hoenisch

Steve Hoenisch is a technical writer (consultant) with Verizon
Wireless. Before becoming a technical writer and a Web developer, he
worked as a journalist and teacher. Steve has been developing Web
sites since 1996.

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 Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...
SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
In his session at @ThingsExpo, Greg Gorman is the Director, IoT Developer Ecosystem, Watson IoT, will provide a short tutorial on Node-RED, a Node.js-based programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using a wide range of nodes in the palette that can be deployed to its runtime in a single-click. There is a large library of contributed nodes that help so...
What is the best strategy for selecting the right offshore company for your business? In his session at 21st Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, will discuss the things to look for - positive and negative - in evaluating your options. He will also discuss how to maximize productivity with your offshore developers. Before you start your search, clearly understand your business needs and how that impacts software choices.
SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads. In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, will discuss how data centers of the future will be managed, how th...
There is huge complexity in implementing a successful digital business that requires efficient on-premise and cloud back-end infrastructure, IT and Internet of Things (IoT) data, analytics, Machine Learning, Artificial Intelligence (AI) and Digital Applications. In the data center alone, there are physical and virtual infrastructures, multiple operating systems, multiple applications and new and emerging business and technological paradigms such as cloud computing and XaaS. And then there are pe...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that Keisoku Research Consultant Co. will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Keisoku Research Consultant, Co. offers research and consulting in a wide range of civil engineering-related fields from information construction to preservation of cultural properties. For more information, vi...
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" 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. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/.
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets. In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...
SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/.
SYS-CON Events announced today that B2Cloud 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. B2Cloud specializes in IoT devices for preventive and predictive maintenance in any kind of equipment retrieving data like Energy consumption, working time, temperature, humidity, pressure, etc.
SYS-CON Events announced today that NetApp has been named “Bronze 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. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp em...
Elon Musk is among the notable industry figures who worries about the power of AI to destroy rather than help society. Mark Zuckerberg, on the other hand, embraces all that is going on. AI is most powerful when deployed across the vast networks being built for Internets of Things in the manufacturing, transportation and logistics, retail, healthcare, government and other sectors. Is AI transforming IoT for the good or the bad? Do we need to worry about its potential destructive power? Or will we...
SYS-CON Events announced today that SIGMA Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. uLaser flow inspection device from the Japanese top share to Global Standard! Then, make the best use of data to flip to next page. For more information, visit http://www.sigma-k.co.jp/en/.
Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...