I'm trying to convert an XML file into SQL queries. There's a lot of foreign characters, quotes,etc. that are stored as special characters, like &
Here's an example of what I'm doing.
<xsl:for-each select="main/test/picture">
<p>
INSERT INTO example(
id,
name,
<xsl:if test="@height">height,</xsl:if>
<xsl:if test="@width">width,</xsl:if>
<xsl:if test="description">description,</xsl:if>
uri
)
VALUES( '<xsl:value-of select="@id"/>',
'<xsl:value-of select="name"/>',
<xsl:if test="@height">'<xsl:value-of select="@height"/>',</xsl:if>
<xsl:if test="@width">'<xsl:value-of select="@width"/>',</xsl:if>
<xsl:if test="description">'<xsl:value-of select="description"/>',</xsl:if>
'<xsl:value-of select="uri"/>'
);
</p>
</xsl:for-each>
Now let's say we have
<main>
<test>
<picture id = "5" height="5" width="5">
<name>John's hat</name>
<description>"cool" hat</description>
</picture>
</test>
</main>
It's already in the xml as ", ', etc. I want it to stay that way in the database. The output converts it to ' and " no matter what I try. (The delimiter can be changed to |, there's ways around the ;, that's a nonissue.)
note:
The example above I typed up half asleep in about a minute. I couldn't copy/paste the data I'm working with since it's confidential, so if there's some minor syntax issues up there it's just because of that...
Thanks,
Gibbers