Reputation: 6038
Trying to get value of xml in ID
element in a div..
<xsl:for-each select="tables">
<xsl:for-each select="table">
<xsl:for-each select="@name">
<div id="<xsl:value-of select="."/>">
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
I know this is wrong .. need help how to do it properly
Input XML
<?xml-stylesheet type="text/xsl" href="ddlms.xslt"?>
<tables>
<table name="tbl_AccountLedger">
<row>
<Field></Field>
<ColumnName>ledgerId</ColumnName>
<DataType>varchar</DataType>
<Prec tbl="krishna">50</Prec>
<Cons>PK</Cons>
<Ref></Ref>
<Coded></Coded>
<Def></Def>
<Description></Description>
</row>
</table>
</tables>
Upvotes: 1
Views: 4224
Reputation:
replace <div id="<xsl:value-of select="."/>">
with <div id="{.}">
and watch the miracle happen.
Upvotes: 3
Reputation: 116959
Try something like:
<xsl:template match="/">
<root>
<xsl:for-each select="tables/table">
<div id="{@name}">
</div>
</xsl:for-each>
</root>
</xsl:template>
Upvotes: 1
Reputation: 7173
try this stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tables">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="table">
<div id="{@name}">
</div>
</xsl:template>
</xsl:stylesheet>
try to have a read regarding attribute value templates (http://www.w3.org/TR/xslt#attribute-value-templates).
Upvotes: 1