Because XML contains all the necessary information to create a set of documents, there will be times when you want to store and maintain the document structure as it currently is.
For example, if you are a news publishing company that has been serving articles over the Web, you might want to maintain an archive of published articles. In such a scenario, the XML Extender lets you store your complete or partial XML articles in a column of a DB2 table. This type of XML document storage is called an XML column, as shown in Figure 1.
Figure 1. Storing structured XML documents in a DB2 table column
![]() |
The XML Extender provides following the user-defined types (UDTs) for use with XML columns:
All the XML Extender's UDTs have the prefix db2xml, which is the schema name of the DB2 XML Extender UDTs. These data types are used to identify the storage type of XML documents in the application table. The XML Extender supports legacy flat files; you are not required to store XML documents inside DB2. You can also store XML documents as files on the local file system, as specified by a local file name.
The DB2 XML Extender provides powerful user-defined functions (UDFs) to store and retrieve XML documents in XML columns, as well as to extract XML element or attribute values. A UDF is a function that is defined to the database management system and can be referenced thereafter in SQL queries. The XML Extender provides the following types of UDFs:
The extract functions allow you to perform powerful searches on general SQL data types. Additionally, you can use the DB2 UDB Text Extender with the XML Extender to perform structural and full text searches on text in XML documents. This powerful search capability can be used, for example, to improve the usability of a Web site that publishes large amounts of readable text, such as newspaper articles or Electronic Data Interchange (EDI) applications, which have frequently searchable elements or attributes.
All the XML Extender's UDFs have the prefix db2xml, which is the schema name of the DB2 XML Extender UDFs. The UDFs are applied to XML UDTs, and they are used for XML columns.
A location path is a sequence of XML tags that identify an XML element or attribute. The XML Extender uses the location path to identify the structure of the XML document, indicating the context for the element or attribute. A single slash (/) path indicates that the context is the whole document. The location path is used in the following situations:
Figure 2 shows an example of a location path and its relationship to the structure of the XML document.
Figure 2. Storing documents as structured XML documents in a DB2 table column
![]() |
To specify the location path, the XML Extender uses a subset of the XML Stylesheet Language Transformation (XSLT) and XML Path Language (XPath). This book uses the term location path, which is defined in the specification of XPath. The location path is a sequence of XML tags that identify an XML element or attribute. This book also uses the XSLT or XPath abbreviated syntax of the absolute location path, which is specified in the XPath specifications. The absolute location path is the full path name of an object.
XSLT is a language for transforming XML documents into other XML documents. It is designed for use as part of XML Stylesheet Language (XSL), which is a stylesheet language for XML. In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.
XPath is a language for addressing parts of an XML document, which is designed to be used by XSLT. Every location path can be expressed using the syntax defined for XPath.
For more information about XSLT and XPath, see the following Web pages:
See Location path for syntax and restrictions.
This section describes XML concepts and terminology that are referred to in this book.