I have never tried this kind of reporting before. Mail from a friend prompted me that I should start creating this report and also publish an article which shows a step-by-step process of creating one.
So here is the list that we are going to achieve:
- Create a DTD file
- Create an XML file
- Create a report based on the two files created.
First step is to create a DTD file.
Our XML file contains details of all database environments in use by a team.
The following is our DTD file. Save the following contents as c:\database.dtd:
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT DatabaseInventory (DatabaseName+)>
<!ELEMENT DatabaseName ( GlobalDatabaseName
, OracleSID
, DatabaseDomain
, Administrator+
, DatabaseAttributes
, Comments)
>
<!ELEMENT GlobalDatabaseName (#PCDATA)>
<!ELEMENT OracleSID (#PCDATA)>
<!ELEMENT DatabaseDomain (#PCDATA)>
<!ELEMENT Administrator (#PCDATA)>
<!ELEMENT DatabaseAttributes EMPTY>
<!ELEMENT Comments (#PCDATA)>
<!ATTLIST Administrator EmailAlias CDATA #REQUIRED>
<!ATTLIST Administrator Extension CDATA #IMPLIED>
<!ATTLIST DatabaseAttributes Type (Production|Development|Testing) #REQUIRED>
<!ATTLIST DatabaseAttributes Version (7|8|8i|9i) "9i">
<!ENTITY AUTHOR "Anantha Narayanan">
<!ENTITY WEB "http://askanantha.blogspot.com">
The contents of the structure is as follows:
- DatabaseInventory (Row of type DatabaseName)
- DatabaseName is a type of fields (GlobalDatabaseName, OracleSID, DatabaseDomain, Administrator+, DatabaseAttributes, Comments)
- GlobalDatabaseName is a field of type PCDATA
- OracleSID is a field of type PCDATA
- DatabaseDomain is a field of type PCDATA
- Administrator is a field of type PCDATA
- DatabaseAttributes is EMPTY by default
- Comments is a field of type PCDATA
In the ATTLIST tag, we are defining the properties of the fields of type PCDATA.
Now the second step is to create XML file as below. Save the following contents as database.xml:
<?xml version="1.0"?>
<!DOCTYPE DatabaseInventory SYSTEM "db.dtd">
<DatabaseInventory>
<DatabaseName>
<GlobalDatabaseName>mydb.myspace.com</GlobalDatabaseName>
<OracleSID>production</OracleSID>
<DatabaseDomain>myspace.com</DatabaseDomain>
<Administrator EmailAlias="tlananthu" Extension="2354">Anantha</Administrator>
<DatabaseAttributes Type="Production" Version="10g"/>
<Comments>
This is production database.
</Comments>
</DatabaseName>
<DatabaseName>
<GlobalDatabaseName>prod.myspace.com</GlobalDatabaseName>
<OracleSID>development</OracleSID>
<DatabaseDomain>myspace.com</DatabaseDomain>
<Administrator EmailAlias="tlananthu" Extension="2354">Anantha</Administrator>
<DatabaseAttributes Type="Production" Version="10g"/>
<Comments>
This is development database.
</Comments>
</DatabaseName>
<DatabaseName>
<GlobalDatabaseName>test.myspace.com</GlobalDatabaseName>
<OracleSID>testing</OracleSID>
<DatabaseDomain>myspace.com</DatabaseDomain>
<Administrator EmailAlias="tlananthu" Extension="2354">Anantha</Administrator>
<DatabaseAttributes Type="Production" Version="10g"/>
<Comments>
This is testing database.
</Comments>
</DatabaseName>
</DatabaseInventory>
Now start Report Builder.
- Create a New report using the wizard
- Click next on Welcome wizard
- Select Create both Web and Paper Layout option and click Next
- Choose a Tabular report
- Choose XML Query
- In the Query Source definition choose Query Definition button
- In the Define XML Query choose the database.dtd and choose select columns button
- Choose all columns
- In the Data source field choose the database.xml file and click OK
- Click next
- Choose all fields and click next
- Click next
- Edit the labels if necessary.
- Click next
- Choose a template if necessary
- Click Finish.
Congratulations, you have created a report based on an XML query successfully.