A script-enabled browser is required for this page to function properly.

XML Tag Attributes property

The XML Tag Attributes property specifies XML attributes. The purpose of adding an attribute to an object’s tag is to further describe or pinpoint the data value for that tag. Using tag attributes is one method of organizing your XML output. If you use this method, you need to enter a value for this property. The other method is to assign a separate tag for each type (group or column) of data. In this case, you would leave the property blank.

Applies to

Reports, groups, or columns

Values

See Syntax, below.

Default

Blank

Required/Optional

Optional

Syntax

XML attributes must be entered as space-separated, name-value pairs.

[attribute name]="&[report object name]"

where the text within square brackets ([ ]) is chosen by you. The report object name can be any column or user parameter in the report. You may add as many attributes to this property field as you wish by leaving a space between each one.

Usage notes

Examples

Example 1: Group level

Suppose your tabular report uses the following query:

SELECT * FROM DEPT

Your default XML output looks like the following:

<MODULE2>
  <LIST_G_DEPTNO>
    <G_DEPTNO>
      <DEPTNO>10</DEPTNO>
      <DNAME>ACCOUNTING</DNAME>
      <LOC>NEW YORK</LOC>
    </G_DEPTNO>
    <G_DEPTNO>
      <DEPTNO>20</DEPTNO>
      <DNAME>RESEARCH</DNAME>
      <LOC>DALLAS</LOC>
    </G_DEPTNO>

You want to generate XML output that folds all data associated with a given department number (DEPTNO) into each department number’s <DEPTNO> element. This enables you to reduce output elements from many to few.

From the data model, specify the following properties for the DEPTNO column:

XML Tag: DEPTNO

XML Tag Attributes: NAME="&DNAME" LOCATION="&LOC"

where &DNAME is a department name and &LOC is the location of that department. Both objects repeat at the same frequency as DEPTNO.

The new XML output resembles the following:

<G_DEPTNO>
  <DEPTNO NAME="ACCOUNTING" LOCATION="NEW YORK">10</DEPTNO>
  <DNAME>ACCOUNTING</DNAME>
  <LOC>NEW YORK</LOC>
</G_DEPTNO>
<G_DEPTNO>
  <DEPTNO NAME="RESEARCH" LOCATION="DALLAS">20</DEPTNO>
  <DNAME>RESEARCH</DNAME>
  <LOC>DALLAS</LOC>
</G_DEPTNO>

As you can see, values for DNAME and LOC are now output twice: once as attributes and once as XML elements. In order to eliminate them as XML elements, you must also use the Exclude from XML Output property.

From the data model, set the Exclude from XML Output property to Yes for the DNAME and LOC columns:

The resulting XML output will look like this:

<G_DEPTNO>
  <DEPTNO NAME="ACCOUNTING" LOCATION="NEWYORK">10</DEPTNO>
</G_DEPTNO>
<G_DEPTNO>
  <DEPTNO NAME="RESEARCH" LOCATION="DALLAS">20</DEPTNO>
</G_DEPTNO>
<G_DEPTNO>
  <DEPTNO NAME="SALES" LOCATION="CHICAGO">30</DEPTNO>
</G_DEPTNO>
<G_DEPTNO>
  <DEPTNO NAME="OPERATIONS" LOCATION="BOSTON">40</DEPTNO>
</G_DEPTNO>

Example 2: Report level

The following example demonstrates how a report-level attribute might be useful in XML.

Suppose your report uses the following query:

select deptno, job, ename, hiredate from emp

You have designed your report as group-left, with DEPTNO as the first-level group and JOB as the second-level group. For the purpose of this example, you have selected the DEPTNO and JOB columns in the data model and set the Break Order property to Descending. The arrows to the left of the DEPTNO and JOB columns in the data model should now point down.

Your data model looks like the following:

graphic depicting data model described above

Your XML output begins as follows:

<MODULE2>
<LIST_G_DEPTNO>
<G_DEPTNO>
  <DEPTNO>30</DEPTNO>
  <LIST_G_JOB>
    <G_JOB>
      <JOB>SALESMAN</JOB>
      <LIST_G_ENAME>
        <G_ENAME>
          <ENAME>ALLEN</ENAME>
          <HIREDATE>20-FEB-81</HIREDATE>
        </G_ENAME>
        <G_ENAME>
          <ENAME>WARD</ENAME>
          <HIREDATE>22-FEB-81</HIREDATE>
        </G_ENAME>
        <G_ENAME>
          <ENAME>MARTIN</ENAME>
          <HIREDATE>28-SEP-81</HIREDATE>
        </G_ENAME>

For later reference, note that within department number 30, the first three employee's hiredate ranges from 20-FEB-81 to 28-SEP-81.

Next you add a user parameter to your report that will select or exclude data according to hiredate. Double-click the query (Q_1) in the data model.

In the SQL Query Statement dialog box, add the following text at the end of the existing query:

where hiredate > :p_date

so that now your query reads:

select deptno, job, ename, hiredate from emp where hiredate > :p_date

This SQL statement directs Reports Builder to create the parameter named p_date. However, you must manually change the Datatype property to Date, as follows:

  1. In the Object Navigator, expand the Data Model node, then expand the User Parameters node.

  2. Double-click the user parameter P_DATE.

  3. In the Property Inspector, set the Datatype property to Date.

Next, you want to assign this user parameter as an attribute to the report element. The parameter will provide the rule for inclusion or exclusion of various elements throughout the report's XML output.

  1. In the Object Navigator, double-click the properties icon (the properties icon) next to your report name. In the Property Inspector, set the XML Tag Attributes property to HiredateLaterThan="&p_date".
  2. Run the report. A Runtime Parameter Form will appear, asking for a date value (P Date). Enter 1-JUL-81 and click the Run Report button.

Your XML now looks like the following:

<MODULE2 HiredateLaterThan="01-JUL-81">
<LIST_G_DEPTNO>
<G_DEPTNO>
  <DEPTNO>30</DEPTNO>
  <LIST_G_JOB>
    <G_JOB>
      <JOB>SALESMAN</JOB>
      <LIST_G_ENAME>
        <G_ENAME>
          <ENAME>MARTIN</ENAME>
          <HIREDATE>28-SEP-81</HIREDATE>
        </G_ENAME>

Note that instances of the group G_ENAME with HIREDATE values before the date 1-July-81 are no longer available in XML. The attribute which defines this parameter, HiredateLaterThan="01-JUL-81", now appears within the report element, MODULE2.