Sunteți pe pagina 1din 9

INTRODUCTION TO XML

The essence of XML is in its name: Extensible Markup Language.

Extensible
XML is extensible. It allows you define your own tags, the order in which they occur, and
how they should be processed or displayed.
We also say that that XML allows all of us to extend our thought of what a document is

Markup
The most recognizable feature of XML is its tags, or elements (to be more accurate).
XML allows you to define your own set of tags.

Language
it is a data-description language.

Describing the XML Document


All XML documents can optionally begin with an XML declaration. The XML
declaration provides at a minimum the number of the version of XML in use:
<?xml version="1.0"?>
Currently, 1.0 is the only approved version

The simplest XML elements contain an opening tag, a closing tag, and some content.

The opening tag begins with a left angle bracket (<), followed by an element name that
contains letters and numbers (but no spaces), and finishes with a right angle bracket
(>).Following the content is the closing tag, which exhibits the same spelling and
capitalization as your opening tag, but with one tiny change: a / appears right before the
element name.

e.g <element name="LEDGER_ID" dataType="NUMBER" value="LEDGER_ID"/>

Components of XML document

There are terms used to describe parts of an XML document: tags, elements,
and attributes.

XML tags begin with the less-than character (“<”) and end with the greater-than character
(“>”).

You use tags to mark the start and end of elements, which are the logical units of
information in an XML document.
An element consists of a start tag, possibly followed by text and other complete
elements, followed by an end tag

THE DATA TEMPLATE DEFINITION

The data template is an XML document that consists of four basic sections:

Parameters,

Triggers,

Data query,

Data structure

Here is a sample data template:


1] Parameters Section:

A parameter is a variable whose value you can set at runtime. Parameters are especially
useful for modifying SELECT statements and setting PL/SQL variables at runtime.
However, the Parameters section of the data template is optional.

How to Define Parameters:

<parameters>
<parameter name="P_PERIOD_FROM" dataType="character" />
<parameter name="P_PERIOD_TO" dataType="character" />
</parameters>

How to Pass Parameters:


To pass parameters, (for example, to restrict the query), use bind variables in your query.

For example:

Select * from per_all_people_f


Where employee_number between :P_NUM_FROM AND :P_NUM_TO

2] Data Query Section:

The <dataQuery> section of the data template is required.

How to Define SQL Queries


The <sqlStatement> element is placed between the open and close dataQuery tags. The
<sqlStatement> element has a related attribute, name. It is expressed within
the <sqlStatment> tag. The query is entered in the CDATA section.

<dataQuery>

<sqlStatement name="Q1">

<![CDATA[

Select * from per_all_people_f

Where employee_number between :P_NUM_FROM AND :P_NUM_TO

]]>

</sqlStatement>

</dataQuery>
3. Using Data Triggers:

Data triggers execute PL/SQL functions at specific times during the execution and
generation of XML output. Using the conditional processing capabilities of PL/SQL for
these triggers, you can do things such as perform initialization tasks and access the
database.

Data triggers are optional, and you can have as many <dataTrigger> elements as
necessary. The <dataTrigger> element has a set of related attributes. These are expressed
within the <dataTrigger> tag.

For example:

1 <dataTrigger name="beforeReport1" source=" xxfin_test_pkg.beforeReport()"/>

2 <dataTriggername="beforeReport2"source=" fin_test_pkg.beforeReport(:Parameter)"/>
Name: The event name to fire this trigger.

Source: The PL/SQL <package name>.<function name> where the executable code
resides.

4] Data Structure Section:


In the data structure section you define what the XML output will be and how it will be
structured. The complete group hierarchy is available for output. You can specify all the
columns within each group and break the order of those columns; you can use
summaries, and placeholders to further customize within the groups.

Sample Data Structure:

<dataStructure>

<group name="GROUP_1" source="Q1">

<element name="LEDGER_ID" value="LEDGER_ID" />

<element name="LEDGER_SHORT_NAME"
value="LEDGER_SHORT_NAME" />

<element name="LEDGER_DESCRIPTION" value="LEDGER_DESCRIPTION" />

<element name="LEDGER_NAME" value="LEDGER_NAME" />

<element name="LEDGER_SUM_BAL_DR" value="ACCT_SUM_BAL_DR"


function="SUM()" />

<element name="LEDGER_SUM_BAL_CR" value="ACCT_SUM_BAL_CR"


function="SUM()" />

<group name=" GROUP_2" source="Q1">

<element name="CODE_COMBINATION_ID"
value="CODE_COMBINATION_ID" />

<element name="ACCOUNTING_CODE_COMBINATION"
value="ACCOUNTING_CODE_COMBINATION" />

<element name="CODE_COMBINATION_DESCRIPTION"
value="CODE_COMBINATION_DESCRIPTION" />

<element name="ACCT_SUM_PR_DR" value="PERIOD_NET_DR"


function="SUM()" />

<element name="ACCT_SUM_PR_CR" value="PERIOD_NET_CR"


function="SUM()" />

<element name="ACCT_SUM_BAL_DR" value="BEGIN_BALANCE_DR"


function="SUM()" />

<element name="ACCT_SUM_BAL_CR" value="BEGIN_BALANCE_CR"


function="SUM()" />

<group name=" GROUP_3" source="Q1">

<element name="PERIOD_YEAR" value="PERIOD_YEAR" />

<element name="PERIOD_NUMBER" value="PERIOD_NUMBER" />

<element name="PERIOD_NAME" value="PERIOD_NAME" />

</group>

</group>

</group>

</dataStructure>

Methods for RTF template creation

There are 2 methods for creating RTF templates:

 Basic RTF Method


 Form Field Method

Basic RTF Method

Enter the placeholder syntax in your document where you want the XML data value to
appear.

Enter the element's XML tag name using the syntax:

<?XML element tag name?>

In the example, the template field "Employee" maps to the XML element
EMPLOYEE_NAME. In your document, enter:

<?EMPLOYEE_NAME?>
EMPLOYEE NUMBER EMPLOYEE NAME AGE POSITION
<?EMPLOYEE_NUMBER?> <?EMPLOYEE_NAME?> <?AGE?> <?POSITION?>

Form Field Method

Use Microsoft Word's Text Form Field Options window to insert the placeholder tags:

1. Enable the Forms toolbar in your Microsoft Word application.


2. Position your cursor in the place you want to create a placeholder.
3. Select the Text Form Field toolbar icon. This action inserts a form field area in
your document.
4. Double-click the form field area to invoke the Text Form Field Options dialog
box.

Line Number Description Quantity


F LINE_NUMBER DESCRIPTION QUANTITY E

Grouping scenarios

<?for-each:G_EMPLOYEE_NAME?>

EMPLOYEE NUMBER EMPLOYEE NAME AGE POSITION


<?EMPLOYEE_NUMBER?> <?EMPLOYEE_NAME?> <?AGE?> <?POSITION?>

<?end for-each?>

for each

Customer number Line Number Description Quantity


F CUSTOMER LINE_NUMBER DESCRIPTION QUANTITY E
NUMBER
end for each

Create an RTF template: Practical

Creating a cross tab report

Example 1:

Select employee_number, department,gender from xxxx

CH G GENDERE
DEPARTMEN Total
T

G G 999E 999E
DEPARTMEN
T

G 999E 999

Creating a chart

The below example shows the amount remitted to a different banks


Amount based on date

S-ar putea să vă placă și