[Home] [By Thread] [By Date] [Recent Entries]
I have a couple hundred xml files that contain html content that I
need to transform into a sql file (INSERT statement) to be imported
into a database. I'm using a simple xsl:copy element to copy all of
the xml's contents (including all html tags and it's attributes,
values) into a single insert line, but the problem arises that I'm
getting an insert line for each node in the file. If I make the
template match value to be "/content" then I get one insert line
(which is desired), but I lose all the html tags/attributes/values.
My xsl: <xsl:template match="/content/node()|@*"> <xsl:text>INSERT INTO whatsNew (approved, title, description, publishDate) VALUES </xsl:text><xsl:text>(1, </xsl:text><xsl:value-of select="//p[@class='news-content-heading']"/><xsl:text>, </xsl:text> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> <xsl:text>, </xsl:text><xsl:call-template name="date"><xsl:with-param name="filename"><xsl:value-of select="$fileName"/></xsl:with-param></ xsl:call-template><xsl:text>,1, 1)</xsl:text> </xsl:template> My sample XML file: <?xml version="1.0" encoding="UTF-8"?> <content> <p class="news-content-heading">Headline Goes here </p> <p>November 25, 2006<p/> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p> <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat</p> <p> <ul> <li>item 1</li> <li>item 2</li> </ul> </p> <p>Excepteur sint occaecat cupidatat non proident, <a href="../ contact/index.html">sunt in culpa qui</a> officia deserunt mollit anim id est laborum</p> </content> Suggestions? Alan
Utah Interactive, LLC 30 East Broadway, Suite 300 Salt Lake City, UT 84111 801-983-8424 (office) 801-698-0499 (mobile) alan@xxxxxxxxxxxxxxxxxxx
|

Cart



