Given the following code:
<database>
<table name="table1">
<column name="id"/>
<column name="created_at"/>
</table>
<table name="table2">
<column name="id"/>
<column name="updated_at"/>
</table>
</database>
I want to be able to test using an xsl:key if specific table has a specific column by name. For instance, I want to know if a table has a 'created_at' column so I can write specific code within the transformation.
I've gotten a general key that will test if any table has a given column by name, but have not figured out how to make it specific to the table the transformation is currently working with.
<xsl:key name="columnTest" match="column" use="@name"/>
<xsl:for-each select="database/table">
<xsl:choose>
<xsl:when test="key('columnTest', 'created_at')">
<xsl:text>true</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>false</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
So I end up with 'true' for all the tables. Any guidance would be appreciated.