XML to SQL


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>

  <xsl:template match="Row">
    INSERT INTO composers (
    <xsl:apply-templates select="Field" mode="names"/>
    )
    VALUES (
    <xsl:apply-templates select="Field" mode="values"/>
    )
  </xsl:template>  
  
  <xsl:template match="Field" mode="values">
   '<xsl:value-of select="."/>'<xsl:if test="position()!=last()">, </xsl:if>  
  </xsl:template>  
  
  <xsl:template match="Field" mode="names" >
   '<xsl:value-of select="@name"/>'<xsl:if test="position()!=last()">, </xsl:if>
  </xsl:template>  
  
</xsl:stylesheet>

View Results in Browser
Previous | Next | Top | Cafe con Leche

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified March 16, 2000