Created
March 29, 2018 01:43
-
-
Save JoshuaCarroll/d2efe2b9f1f65af39d5665c53e63a16b to your computer and use it in GitHub Desktop.
XSL transform to input XML of states and output SQL insert statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org"> | |
<xsl:template match="/states/state"> | |
INSERT INTO States (State, Borders) | |
VALUES ('<xsl:value-of select="@name"/>', (geography::STGeomFromText('POLYGON((<xsl:for-each select="point"><xsl:value-of select="@lng"/><xsl:text> </xsl:text><xsl:value-of select="@lat"/>,</xsl:for-each><xsl:value-of select="point[1]/@lng"/><xsl:text> </xsl:text><xsl:value-of select="point[1]/@lat"/>))', 4326))); | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment