Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. xsl formating

xsl formating

Scheduled Pinned Locked Moved XML / XSL
xmlannouncementdatabasewpfregex
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndieDu
    wrote on last edited by
    #1

    Hi All, I have this XML document: <?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xsl" href="WriteXMLToDBTest_SQLScript.xsl"?> <OrderDetails> <Order ID="10248"> <OrderItem ProductID="11"> <QuantityIncrease>2</QuantityIncrease> </OrderItem> </Order> <NewOrder ID ="10249"> <OrderItem ProductID ="12"> <QuantityIncrease>3</QuantityIncrease> </OrderItem> </NewOrder> </OrderDetails> and have applied this XSL: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method ="text" encoding ="utf-8"/> <xsl:output indent ="yes"/> <xsl:template match ="/"> <xsl:apply-templates select ="OrderDetails/Order"/> <xsl:apply-templates select ="OrderDetails/NewOrder"/> </xsl:template> <xsl:template match ="Order"> xsl:textUpdate [Order Details] Set Quantity = 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:template match ="NewOrder"> xsl:textUpdate [Order Details] Set Quantity = 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> and it generates two sql statements: Update [Order Details] Set Quantity = Quantity + 2 Where OrderID = 10248 And ProductID = 11Update [Order Details] Set Quantity = Quantity + 3 Where OrderID = 10249 And ProductID = 12 problems in here is that two "update statements" on the single line and i would like to know how to seperate them like this: Update [Order Details] Set Quantity = Quantity + 2 Where OrderID = 10248 And ProductID = 11 Update [Order Details] Set Quantity = Quantity + 3 Where OrderID = 10249 And ProductID = 12 Thanks a lot

    L 1 Reply Last reply
    0
    • A AndieDu

      Hi All, I have this XML document: <?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xsl" href="WriteXMLToDBTest_SQLScript.xsl"?> <OrderDetails> <Order ID="10248"> <OrderItem ProductID="11"> <QuantityIncrease>2</QuantityIncrease> </OrderItem> </Order> <NewOrder ID ="10249"> <OrderItem ProductID ="12"> <QuantityIncrease>3</QuantityIncrease> </OrderItem> </NewOrder> </OrderDetails> and have applied this XSL: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method ="text" encoding ="utf-8"/> <xsl:output indent ="yes"/> <xsl:template match ="/"> <xsl:apply-templates select ="OrderDetails/Order"/> <xsl:apply-templates select ="OrderDetails/NewOrder"/> </xsl:template> <xsl:template match ="Order"> xsl:textUpdate [Order Details] Set Quantity = 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:template match ="NewOrder"> xsl:textUpdate [Order Details] Set Quantity = 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> and it generates two sql statements: Update [Order Details] Set Quantity = Quantity + 2 Where OrderID = 10248 And ProductID = 11Update [Order Details] Set Quantity = Quantity + 3 Where OrderID = 10249 And ProductID = 12 problems in here is that two "update statements" on the single line and i would like to know how to seperate them like this: Update [Order Details] Set Quantity = Quantity + 2 Where OrderID = 10248 And ProductID = 11 Update [Order Details] Set Quantity = Quantity + 3 Where OrderID = 10249 And ProductID = 12 Thanks a lot

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Do you realize that depending on the source of the XML you could be exposing your system to SQL Injection[^] attacks due to your antiquated technique of updating a database? Antiquated in this case means generating SQL statements.

      led mike

      A 1 Reply Last reply
      0
      • L led mike

        Do you realize that depending on the source of the XML you could be exposing your system to SQL Injection[^] attacks due to your antiquated technique of updating a database? Antiquated in this case means generating SQL statements.

        led mike

        A Offline
        A Offline
        AndieDu
        wrote on last edited by
        #3

        ok, cool, i just realise this, thanks to mention that to me.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups