Identity transform
From Wikipedia, the free encyclopedia
In metadata, the identity transform is an example of a data transformation that copies the source data into the destination data without change.
Establishing an understanding the identity transformation is considered an essential process in creating a reusable Transformation library. By creating a library of variations of the base identity transformation, a variety of data transformation filters can be easily maintained. These filters can be chained together in a format similar to UNIX shell pipes.
Contents |
[edit] Example using XSLT
The most frequently cited example of the identity transform is the "copy.xsl" transform as expressed in XSLT. This transformation uses the xsl copy command to perform the identity transformation:
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
This template works by first matching all attributes (@*) and then all nodes (node()) and than applying the copy transformation to all sub-nodes of the current data element. This recursively descends the data element hierarchy and outputs all structures in the same structure they were found in the original file.
[edit] Remove Element Transform
The identity transformation can be modified to copy everything from an input tree to an output tree except a given node. For example the following will copy everything from the input to the output except the social security number:
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- remove all social security numbers --> <xsl:template match="PersonSSNID"/>
[edit] See also
[edit] References
- The original reference to the copy transform in the w3c recommendation document [1]
- The identity operation is also a required component of an XML Pipeline using the w3c XProc working draft [2] (accessed Nov 21, 2006)
- Use of the identity transform is covered in the book XSLT Cookbook, O'Reilly Media, Inc., December 1, 2002, by Sal Mangano, ISBN 0-596-00372-2