<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:template match="/Update/Object/Insert">
Insert into <xsl:value-of select="@Table" />(
<xsl:for-each select="Field">
<xsl:value-of select="@Name" />,
</xsl:for-each>)
Values(
<xsl:for-each select="Field">
<xsl:value-of select="@Value" />,
</xsl:for-each>)
</xsl:template>
Output :
Insert into Good(
GoodCode,
…
,
)
Values(
1,
…
,
)
as you can see there is a extra “,” the question is how I can correct it ?
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='book.xslt'?>
<Update>
<Object Name="Good">
<Insert Table="Good">
<Field Name="GoodCode" Value="1" Type="Integer" />
<Field Name="GoodUserCode" Value="" Type="String" />
</insert>
</object>
use something like this:
http://www.w3schools.com/xsl/el_if.asp