Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: transform XML to SQL by XSL

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 9/8/2008 8:17:00 AM

Something like:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="Order"/>
</xsl:template>
<xsl:template match="Order">
<xsl:text>update order_details set quantity = </xsl:text>
<xsl:value-of select="OrderItem/QuantityIncrease"/>
<xsl:text> where orderid = </xsl:text>
<xsl:value-of select="@ID"/>
<xsl:text> and productid = </xsl:text>
<xsl:value-of select="OrderItem/@ProductID"/>
</xsl:template>
</xsl:stylesheet>

depending on how dynamic the actual names , like ProductID, are.

-- 
Joe Fawcett (MVP - XML)
http://joe.fawcett.name

<andie.du168@g...> wrote in message 
news:1f3d63e5-12cf-4a6b-9920-70cb1d40061d@p......
On Sep 5, 5:37 pm, "Joe Fawcett" <joefawc...@newsgroup.nospam> wrote:
> <andie.du...@gmail.com> wrote in message
>
> news:e2bfc74a-4dc8-4ea2-b40a-47f860265457@b......
>
>
>
> > i have thisxmlhere, and now i would like to usexsltotransform
> > into an Updatesqlstatement like this:
> > Here is theXMLdocument:
>
> > <Order ID="10248">
> > <OrderItem ProductID="11">
> > <QuantityIncrease>2</QuantityIncrease>
> > </OrderItem>
> > </Order>
>
> > Here is a bit i did:
>
> > <?xmlversion="1.0" encoding="UTF-8">
> > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
> >Transform">
> > <xsl:input href ="WriteXMLToDBTest_Order.xml"/>
> > <xsl:output method="text" encoding="UTF-8"/>
>
> > <xsl:template match="/">
> > <xsl:apply-templates select="Order"/>
> > </xsl:template>
>
> > <xsl:tempalte match="Order">
> > <xsl:text>update</xsl:text>
> > <xsl:value-of select="Order Details"/>
> > </xsl:tempalte>
> > </xsl:stylesheet>
>
> > as i am still new in this field, can someone guide me through?
>
> > Many thanks
>
> What is thexsl:input element? I haven't seen that one before, did you 
> meanxsl:include orxsl:import?
> Can you show an example of whatSQLstatement should be produced by theXML
> you gave?
>
> --
>
> Joe Fawcett (MVP -XML)http://joe.fawcett.name- Hide quoted text -
>
> - Show quoted text -

Hi Joe,

Thanks very much for your reply.

what i need in here is:
I want the xsl read the xml, so i think it is xsl:import, which is the
one that i provided at the very beginning, and i want to transform to
this sql statement:
update order_details set quantity = 12 where orderid = 10248 and
productid = 11 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent