Today, I'll talk about the basic of XML as part of the 'Before you start RTF Template' series.
I’m sure you have already seen XML files and known what the files look like. Especially the BI Publisher technology is designed around XML so it’s almost impossible not to see XML files when you develop any report. However, some of you might not have spent a time to learn what really the XML is more than what it looks. So, let’s spend some time (not a lot, so don’t worry!) to visit the XML basic.
What is XML ?
XML stands for eXtensible Markup Language. It is a W3C standard, and it was designed to describe data and to focus on what data is while a similar language called HTML was designed to display data and to focus on how data looks. XML uses a Document Type Definition(DTD) or an XML Schema to describe the structure of XML documents. Now it’s more common to use XML schema than the DTD to describe the data. And BI Publisher also uses XML Schema when it’s needed.
What are they? (Terminology)
Instead of going through all the detail of XML, I’ll focus on what’s really important for BI Publisher report developers. First, what are those tags inside the XML file? When you open the XML files you can see a bunch of tags and all of them looks same. However, there is some difference among them and each of them has its own name. The names you want to remember are the followings.
- Element
- Attribute
- Value
- Namespace
- Root
- Parent
- Child
- Sibling
- CDATA
Element
Element name is actually the main part of the XML and it acts as something like metadata. For example with the above sample XML the
Attribute
Attribute is an additional metadata that tag along with the Element and add more meaning to the Element. For example with the above sample XML, ‘age’ is the attribute, which describes age of the employee in the EMPLOYEE element. And you can have multiple attributes per Element.
And Element and Attribute are the main component of the XML and the backbone of the file.
Value
Value is literally the value. Both the Element and Attribute can have their own values. The Element value is surrounded by Element start tag and Element end tag. e.g.
Node
Node is similar to something like group, unit, or family. And node can contain another node or multiple nodes inside and each node can act as an unit inside the higher level of nodes. With above sample, DEPARMENT is a node and you can find EMPLOYEE node inside the DEPARTMENT node.
Namespace
Namespace is used to differentiate the elements that have same name but means different.
Root Element
Root is something like the ‘root’ that is used for Unix file system. It means a top level Element and there is only one in one XML file.
Parent/Child/Sibling
These are the terms to describe relationships of each element. And this acts as exactly same as your family hierarchy or file system. So the node that is at one level above from where you are is called Parent node while the ones that are at one level below are called Child node. With above sample ORACLE node is parent node for DEPARTMENT element and EMPLOYEE element is child node. And this is a relative concept, so while DEPARTMENT node is a child node for ORACLE node, DEPARTMENT node is at the same time a parent node for EMPLOYEE node.
CDATA
CDATA is used for a section for a comment out area, where you can type anything. Any XML standard processor will not process the content in this area. We’ll cover in the next section about XML standard rules but the content stored in this CDATA section doesn’t apply such rules so you can basically type anything here for your use. BI Publisher uses this area with Data Template to store SQL query.
No comments:
Post a Comment