XFA Specification
Chapter 13, Dealing with Data in Different XML Formats
XSLT Transformations
399
A common use for this extended mapping rule is to ensure that an empty element that represents a data
group is not mapped to a
dataValue
node as would occur based on the default mapping rules described
in the section
“Data Values Containing Empty Elements” on page 129.
Consider the following example:
<book>
<ISBN>15536455</ISBN>
<title>Introduction to XML</title>
<author/>
</book>
We know from previous examples that the element
author
is a data group element that usually encloses
data value elements
firstname
and
lastname
; however, in this specific example, the
author
element
is empty and therefore would, by default, map to a
dataValue
node.
To ensure that the
author
element maps to a
dataGroup
node, the following example uses this
extended mapping rule:
<book xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<ISBN>15536455</ISBN>
<title>Introduction to XML</title>
<author xfa:dataNode="dataGroup"/>
</book>
Note:
This extended mapping rule only overrides the default mapping rule for non-empty elements. It
does not override the extended mapping rule for empty elements, which is described in the section
“The ifEmpty Element” on page 377
if the extended mapping rule for empty elements is declared in
the XFA configuration document.
XSLT Transformations
XSLT is a special-purpose language defined by [XSLT]. An XSLT program or
stylesheet
can be used to
transform an input XML document into an output XML or non-XML document. XFA supports the use of
XSLT to transform arbitrary XML input data into a temporary XML document, which is then loaded by the
XFA loader. XFA also supports the use of XSLT to transform the output XML document into a final arbitrary
XML or non-XML document. Note that XSLT is not reversible, hence if it is necessary to round-trip two
different XSLT stylesheets are required, one for the input transformation and one for the output
transformation.
XSLT Preprocessing
This section describes a facility that can be used to modify the incoming data under control of an XSLT
script [XSLT]. This transformation makes changes to the XML data DOM before the XFA Data DOM is
loaded by the data loader. Thus, if a new XML data document is created it reflects the result of the XSLT
preprocessing.
Note that it is possible to incorporate a processing instruction into the XML data document that causes an
XSLT transformation to be applied before (or as) the data is loaded into the XML data DOM. This is quite
separate from the facility described here. The facility described here does not require the addition of a
processing instruction, or any other modification, to the XML data document.
The XFA Configuration DOM may include an
xsl
element. If present, the
xsl
element must contain a
uri
element that nominates the XSLT script. See
“Config Specification” on page 676
for the full schema. When
the
xsl
element is supplied, the data loader executes the script and uses its output in place of the original
XML data document.
Home Index Bookmark Pages
Pages: Home Index All Pages