Hello I'm taking a xml with arbitrary data and trying to create a html table with it. The following is a sample of what a input xml would look like.
Code:
<?xml version="1.0" encoding="utf-8"?>
<query>
<schema>
<column name="bi_PUID" />
<column name="si_CredentialID" />
<column name="si_CredentialType" />
<column name="vc_CredentialName" />
<column name="ti_NeedsRepl" />
<column name="si_HashBucket" />
<column name="dt_ChangeDatetime" />
<column name="dt_DeleteDatetime" />
</schema>
<record>
<bi_PUID>844427077615872</bi_PUID>
<si_CredentialID>1</si_CredentialID>
<si_CredentialType>0</si_CredentialType>
<vc_CredentialName>bob%[email protected]</vc_CredentialName>
<ti_NeedsRepl>1</ti_NeedsRepl>
<si_HashBucket>9216</si_HashBucket>
<dt_ChangeDatetime>6/22/2007 11:32:22 PM</dt_ChangeDatetime>
<dt_DeleteDatetime />
</record>
<record>
<bi_PUID>844427077615873</bi_PUID>
<si_CredentialID>1</si_CredentialID>
<si_CredentialType>0</si_CredentialType>
<vc_CredentialName>george%[email protected]</vc_CredentialName>
<ti_NeedsRepl>1</ti_NeedsRepl>
<si_HashBucket>9216</si_HashBucket>
<dt_ChangeDatetime>6/22/2007 11:32:22 PM</dt_ChangeDatetime>
<dt_DeleteDatetime />
</record>
</query>
Now, the problem for me is to keep the name of the column and use that to get the values of the spcific records.
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<h2>Users</h2>
<table border="1">
<xsl:for-each select="query/schema/column">
<xsl:variable name="column" select="@name"/>
<td>
<th bgcolor="#9acd32">
<xsl:value-of select="@name"/>
</th>
<xsl:for-each select="../../record">
<tr>
<xsl:value-of select ="$column/text()"/>
</tr>
</xsl:for-each>
</td>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
As you can see the i'm trying to store the @name as a variable, but i think it's saving it as a node instead of a string. I want something like:
Code:
<td>
<th>bi_puid</th>
<tr>844427077615872<tr>
<tr>844427077615873<tr>si_CredentialID
<td>
<td>
<th>si_CredentialID</th>
<tr>1<tr>
<tr>1<tr>
<td>
...