xsl702noob
MIS
Hi guys, i'm really new at xml and xsl. all im tyring to do is grab information from the xml then use an xsl file to perform a sql insert. I'm trying to get all <a> values from the different <id>'s.
Please help:
Here's the xml im using:
<?xml version="1.0" encoding="utf-8" ?>
- <survey xmlns="xmlns:xsi="xmlns:xsd="xmlns:survey="
- <questionnaire>
- <q>
<id>0</id>
</q>
- <q>
<id>1</id>
<a>40</a>
</q>
- <q>
<id>2</id>
<a>Iwork</a>
</q>
</questionnaire>
</survey>
And here's the xsl im working on:
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:s="
<xslutput method="xml"/>
<xsl:template match="/ns:survey">
<xsl:element name="SQL">
<xsl:apply-templates select="ns:questionnaire/ns:q"/>
</xsl:element>
</xsl:template>
<xsl:template match="ns:q/[child::ns:id=1]">
<xsl:element name="Command">
<xsl:attribute name="nonQuery">
<xsl:text>false</xsl:text>
</xsl:attribute>
<xsl:attribute name="type">
<xsl:text>text</xsl:text>
</xsl:attribute>
<xsl:text>INSERT INTO Staff (StaffID) VALUES ('</xsl:text>
<xsl:value-of select="ns:a"/>
<xsl:text>')</xsl:text>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Thank you in advance.
Please help:
Here's the xml im using:
<?xml version="1.0" encoding="utf-8" ?>
- <survey xmlns="xmlns:xsi="xmlns:xsd="xmlns:survey="
- <questionnaire>
- <q>
<id>0</id>
</q>
- <q>
<id>1</id>
<a>40</a>
</q>
- <q>
<id>2</id>
<a>Iwork</a>
</q>
</questionnaire>
</survey>
And here's the xsl im working on:
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:s="
<xslutput method="xml"/>
<xsl:template match="/ns:survey">
<xsl:element name="SQL">
<xsl:apply-templates select="ns:questionnaire/ns:q"/>
</xsl:element>
</xsl:template>
<xsl:template match="ns:q/[child::ns:id=1]">
<xsl:element name="Command">
<xsl:attribute name="nonQuery">
<xsl:text>false</xsl:text>
</xsl:attribute>
<xsl:attribute name="type">
<xsl:text>text</xsl:text>
</xsl:attribute>
<xsl:text>INSERT INTO Staff (StaffID) VALUES ('</xsl:text>
<xsl:value-of select="ns:a"/>
<xsl:text>')</xsl:text>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Thank you in advance.