<xslt:stylesheet version="1.0" xmlns:xsl="temp" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"> <xslt:output method="xml" indent="yes"/> <!-- Disregard all whitespace in the source document --> <xslt:strip-space elements="*"/> <!-- "Rewire" xsl prefix to use xslt prefix's namespace in the result --> <xslt:namespace-alias stylesheet-prefix="xsl" result-prefix="xslt"/> <!-- Get the tablename as a parameter --> <xslt:param name="table"/> <!-- Output an xslt:stylesheet using the temporary prefix xsl --> <xslt:template match="/"> <xslt:comment> <xslt:text> Created by GenerateInsertTransform.xsl </xslt:text> </xslt:comment> <xslt:text>
</xslt:text> <xsl:stylesheet version="1.0"> <!-- Create a comment in the output --> <xslt:comment> <xslt:text> Transform XXXX into ROWSET for </xslt:text> <xslt:value-of select="$table"/> <xslt:text> </xslt:text> </xslt:comment> <!-- Create a root xslt:template in the output using xsl --> <xsl:template match="/"> <xslt:apply-templates select="page/ROWSET/ROW[1]"/> </xsl:template> </xsl:stylesheet> </xslt:template> <!-- | Match a ROW and create an xsl:for-each in the output. Needs a | priority="1" to make more important than template matching *[*] below +--> <xslt:template match="ROW" priority="1"> <ROWSET> <xslt:comment> <xslt:text> XPath for repeating source rows </xslt:text> </xslt:comment> <xsl:for-each select="page/ROWSET/ROW"> <ROW> <xslt:apply-templates/> </ROW> </xsl:for-each> </ROWSET> </xslt:template> <!-- | Match elements that contain other elements or | elements that contain text and copy them to the output. +--> <xslt:template match="*[*]|*[text()]"> <xslt:copy> <xslt:apply-templates select="*|text()"/> </xslt:copy> </xslt:template> <!-- Match text() nodes for column values & output xsl:value-of --> <xslt:template match="text()"> <xsl:value-of select="{name(..)}"/> </xslt:template> <!-- | Match an element containing an element whose name is | the concatenation of its parent's name and the suffix '_ITEM' | This matches object view nested collection columns/attributes | whose collection element name <XXX> will contain the items | in the collection named <XXX_ITEM>. | Copy the current element, add a nested comment and | process the *first* <XXX_ITEM> child +--> <xslt:template match="*[*[name(.)=concat(name(..),'_ITEM')]]"> <xslt:copy> <xslt:comment> <xslt:text> XPath for repeating </xslt:text> <xslt:value-of select="name(.)"/> <xslt:text> items from source </xslt:text> </xslt:comment> <xsl:for-each select="{name(.)}_ITEM"> <xslt:apply-templates select="*[1]"/> </xsl:for-each> </xslt:copy> </xslt:template> </xslt:stylesheet> |