July 22, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

XInclude-Introduction and Usage

  • January 29, 2004
  • By Manoj Seth
  • Send Email »
  • More Articles »

Introduction to XInclude

XInlclude addresses the issue explained in the "Problem Statement" section, and provides the flexibility explained in the "Solution" section.

Standard excerpt (taken from http://www.w3.org/TR/xinclude/): Many programming languages provide an inclusion mechanism to facilitate modularity. Markup languages also often have need of such a mechanism. This specification introduces a generic mechanism for merging XML documents (as represented by their information sets) for use by applications that need such a facility. The syntax leverages existing XML constructs: elements, attributes, and URI references.

The XInclude specification specifies the processing model for the mechanism of the XML inclusions. This means that the XInclude processor includes various XML information sets into the source information set and provides the resulting information set as an output. This resulting information set will contain the source information set and all other included/merged information sets. These XML information sets can be anywhere on the network, provided they can be made available to the XInclude processor. The XInclude specification makes full use of namespace and XML base specifications.

This inclusion mechanism can be explained by the following figure:



Click here for a larger image.

This resulting information set can be treated as an input to the system for processing. This processing is of varied types, depending upon the system. For example, in the use-case introduced in this article, the resulting information set will be sent to the configuration framework for initialization and starting up the system.

Example of XInclude

The following is the excerpt of the source information set:

<Services xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="service1.xml" parse="xml"/>
  <xi:include href="service2.xml" parse="xml"/>
</Services>

service1.xml file:

<Service1>
  <!-This is the comment line in service1.xml file. -->
<Element1 name="element1"/>
</Service1>

service2.xml file:

<Service2>
  <!-This is the comment line in service2.xml file. -->
<Element2 name="element2"/>
</Service2>

After XInclude processing, the resulting information set will look like this:

<Services xmlns:xi="http://www.w3.org/2001/XInclude">
  <Service1>
    <!-This is the comment line in service1.xml file. -->
<Element1 name="element1"/>
</Service1>
  <Service2>
    <!-This is the comment line in service2.xml file. -->
<Element2 name="element2"/>
</Service2>
</Services>

The above example is self-explanatory.

Usage Areas of XInclude

As explained earlier, XInclude is a solution to provide the modularity of a system having various components and reusability of data of those components. Further, we can see the usage of XInclude in the following areas:

  • As explained in our use-case, XInclude can effectively be used in a configuration framework of varied software systems.
  • XInclude has vast scope in the distributed scenarios where various components of a system are running across the net and there is one centralized place that has the information about the location of the data of components. Now, XInclude is useful in merging the XML data of different components at the centralized place.

Note the usage areas explained above show the high-level view of the scenario. The functional and domain level areas can be inherited from these scenarios to identify the needs of XInclude.

Summary

This article explained the motivation and need to introduce XInclude as an XML specification. We, then, went through the introduction and high-level overview of XInclude.

At the end, the possible use-case scenarios are mentioned to help the readers identify the areas where they can apply the concepts of XInclude.

Acknowledgement

The author acknowledges the valuable review comments of Mr. Mayank Khare (Associate System Analyst, HP, India) in making this article more useful for the readers.

About the Author

Manoj Seth is a senior software engineer at Hewlett-Packard, India. He is a Post Graduate from the Indian Institute of Information Technology, Bangalore.

Manoj has been involved in designing and developing J2EE-based solutions over various platforms in the domains of Financial/Banking and Middleware for more than two years. He has good exposure to Web Services and their emerging standards in development/deployment and management space. Currently, he is working in the telecommunication domain.

He can be contacted at manojseth_2000@yahoo.com.





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel