<?xml version="1.0" encoding="UTF-8"?>

<sample>

  <name>accessible</name>
  <title>Accessible Reports Sample</title>
  <description>Shows how to create accessible reports.</description>

  <mainFeature ref="accessible"/>
  
  <!-- accessible -->
  
  <feature name="accessible" title="Designing Accessible Reports">
    <description>
Explains how to design reports that produce accessible content.
    </description>
    <since>6.19.0</since>
    <documentedBy>
      <author>
    	<name>Teodor Danciu</name>
    	<email>teodord@users.sourceforge.net</email>
      </author>
    </documentedBy>
  	<otherSample ref="crosstabs"/>
  	<otherSample ref="markup"/>
  	<otherSample ref="styledtext"/>
  	<otherSample ref="table"/>
  	<otherSample ref="pdfa"/>
    <content>
JasperReports library accessibility support currently covers HTML and PDF export formats and allows screen readers 
to correctly identify and read through the following types of structured content:
<ul>
  <li>headings (h1 to h6)</li>
  <li>bulleted and numbered lists</li>
  <li>images and graphics alternate texts</li>
  <li>tables</li>
  <li>crosstabs</li>
</ul>
Special markup properties are used in the report templates to identify these types of structured content. 
Some of these markup properties need to be specified manually, while for others the reporting engine can help set them 
automatically in the generated output, if certain specialized reporting features or components are used.
For example, in order to specify that a certain text element represents a level 2 heading, the person creating the report 
needs to use the following custom property at text element level:
<pre><![CDATA[<property name=”net.sf.jasperreports.export.accessibility.tag” value=”h2”/>]]></pre>
On the other hand, if the report renders data in the form of a table, it would be enough for the person designing the report 
to make use of the table component. The table component would automatically add the following custom property to the top 
level frame that contains the table output in the resulting document:
<pre><![CDATA[<property name=”net.sf.jasperreports.export.accessibility.tag” value=”table”/>]]></pre>
Not only this, but the table component would also automatically inject similar custom properties to markup the column headers, 
the rows and the individual cells and thus make up the entire table structure readable by screen readers.
<br/>
<br/>
The HTML and PDF exporters have different mechanisms to expose accessible content to the screen reader. 
While in HTML, the screen reader recognizes standard HTML tags and attributes as headings, bulleted and numbered list and 
semantic tables, in PDF, special metadata tags need to be inserted into the output to give it more structure.
<br/>
<br/>
By default, the JasperReports Library does not produce accessible HTML and PDF exports. This behavior needs to be activated 
using dedicated exporter configurations as follows:
<br/>
<pre>
net.sf.jasperreports.export.html.accessible
net.sf.jasperreports.export.pdf.tagged
</pre>
<subtitle name="headings">Headings (h1 to h6)</subtitle>
<br/>
<br/>
Specifying that a certain text element represents a heading of level 1 up to level 6 can be done using the following custom 
property with a value from „h1” to „h6” respectively.
<br/>
For example, using the following custom property attached to the text element, a level 2 heading can be marked for the screen reader:
<pre><![CDATA[<property name=”net.sf.jasperreports.export.accessibility.tag” value=”h2”/>]]></pre>
This property works for both the HTML and the PDF exporters.
<br/>
<br/>
<subtitle name="lists">Bulleted and Numbered Lists</subtitle>
<br/>
<br/>
Creating accessible bulleted and/or numberer lists in the HTML output can be achieved using styled text content or HTML markup text 
content in a text element.
<br/>
The styled text feature as well as the HTML markup feature of text elements in the report templates have support for nested &lt;ul> and 
&lt;ol> tags as well as their children &lt;li> tags. This type of text markup has its structure preserved when exported to HTML and 
thus is recognized as such by the screen readers.
<br/>
<br/>
Simply by using &lt;ul>, &lt;ol> and &lt;li> tags in a text field configured to render styled text or HTML markup text is enough to create 
accessible bulleted or numbered lists.
<br/>
<br/>
For numbered lists, the &lt;ol> tag should be used and this tag supports two attributes:
<ul>
  <li>type: Specifies the kind of marker to use in the list. The possible values for the type attribute are as follows:
<br/>1 Default. Decimal numbers (1, 2, 3, 4)
<br/>a Alphabetically ordered list, lowercase (a, b, c, d)
<br/>A Alphabetically ordered list, uppercase (A, B, C, D)
<br/>i Roman numbers, lowercase (i, ii, iii, iv)
<br/>I Roman numbers, uppercase (I, II, III, IV)</li>
  <li>start: Specifies the start value of an ordered list</li>
</ul>
<subtitle name="images">Alternate Text for Images and Graphics</subtitle>
<br/>
<br/>
Making images or graphics accessible to screen readers means an alternate text needs to be provided for them so that the screen reader 
reads it out when going over the image or graphic. This alternate text is usually a short description of what the image or graphic represent.
<br/>
<br/>
The alternate text for an image or chart element in the report template can be specified using the &lt;hyperlinkTooltipExpression>.
<br/>
<br/>
<subtitle name="tables">Tables</subtitle>
<br/>
<br/>
The easiest way to create an accessible table in the HTML or PDF export of a report is by using the table component in the report template.
<br/>
The table component has built-in capability to produce its own metadata that would ensures its content keeps its semantic table nature when 
exported to HTML or that specific tags are inserted into the PDF output to fully describe the tabular structure in the resulting PDF document.
<br/>
<br/>
By default, the table component does not generate at report fill time the structural metadata needed later for accessibility during HTML and 
PDF export. This behavior needs to be activated by using the following custom property either globally, at report level or table component level:
<pre><![CDATA[<property name=”net.sf.jasperreports.components.table.accessible” value=”true”/>]]></pre>
Not every table is truly accessible if it does not meet certain criteria with respect with simplicity and clearness. If a table has a structure 
that is too complicated, then users would have a hard time understanding them even if the screen reader can properly read through them.
<br/>
Having said that, here are the main rules to follow when designing accessible tables in reports:
<ul>
  <li>use a single text element in each table cell;</li>
  <li>make the text element as big as the parent table cell;</li>
  <li>make sure all text elements on the same row grow in height in unison by setting stretchType="ContainerHeight" to each text element in each cell;</li>
  <li>make use of the text element border and padding properties and not the border or padding properties of the parent table cell;</li>
</ul>
Table-like structures can be rendered without using the table component. But in such case, it would be the responsibility of the person designing 
the report to make use of the appropriate custom properties at element level to markup the overall table container, its column headers, its rows 
and cells, which otherwise would not be recognizable as a semantic table by the screen reader tool, but seemingly as a flat series of text 
elements without structure.
<br/>
This is not a recommended technique to produce accessible tables, but if needed, an example can be found in the /demo/samples/tabular sample.
<br/>
<br/>
<subtitle name="crosstabs">Crosstabs</subtitle>
<br/>
<br/>
Just like in the case of tables, the easiest way to create accessible crosstabs in the HTML and PDF exported reports is to make use of 
the crosstab component at report design time.
<br/>
Crosstab components have too the built-in ability to produce their own metadata needed to describe their structure at export time and thus produce 
semantic tables that are recognizable as such by the screen readers.
<br/>
<br/>
Unlike table components, crosstabs always produce their structural metadata at report fill time and there is no configuration property to turn off 
this behavior. This is mostly because crosstabs are supposed to be limited in size and the extra information attached to the output they produce 
does not significantly increase the size of the overall report output.
<br/>
<br/>
Crosstabs accessibility can also be affected by their design complexity and this is why it is important to follow certain rules when designing 
accessible crosstabs:
<ul>
  <li>use a single text element in each crosstab cell;</li>
  <li>make the text element as big as the parent crostab cell;</li>
  <li>make sure all text elements on the same row grow in height in unison by setting stretchType="ContainerHeight" to each text element in each cell;</li>
  <li>make use of the text element border and padding properties and not the border or padding properties of the parent crosstab cell;</li>
</ul>
    </content>
  </feature>

</sample>
