Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <update-this>
  3. <document name="http://blah">
  4. <amount>015-39</amount>
  5. <shipping>US::Ground:0.00</shipping>
  6. <url>http://www.blah.com/my-spade-clothing-11176/487/878765?dn_hhe=mylist-_-nothing-_-nothing-_-nothing</url>
  7. <size>11.5 D</size>
  8. <price>100.00 USD</price>
  9. <stock>present in stock </stock>
  10. </document>
  11. </update-this>
  12.  
  13. <?xml version="1.0" encoding="UTF-8"?>
  14. <document name="http://blah">
  15. <amount>015-39</amount>
  16. <shipping>US::Ground:0.00</shipping>
  17. <url>http://www.blah.com/my-spade-clothing-11176/487/878765?dn_hhe=mylist-_-nothing-_-nothing-_-nothing</url>
  18.  
  19. <size>11.5 D</size>
  20. <price>100.00 USD</price>
  21. <stock>present in stock </stock>
  22. <discounted_price>90 USD</discounted_price>
  23. <increased_price>110 USD</increased_price>
  24. <my_id>487</my_id>
  25. <set_id>878765</set_id>
  26. </document>
  27.  
  28. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  29. <xsl:output indent="yes"/>
  30. <xsl:strip-space elements="*"/>
  31.  
  32. <xsl:template match="@*|node()">
  33. <xsl:copy>
  34. <xsl:apply-templates select="@*|node()"/>
  35. </xsl:copy>
  36. </xsl:template>
  37.  
  38.  
  39. <xsl:template match="document">
  40. <xsl:variable name="price" select="substring-before(normalize-space(price),' ')"/>
  41. <xsl:variable name="currency" select="substring-after(normalize-space(price),' ')"/>
  42. <xsl:variable name="difference" select="number($price) * .10"/>
  43.  
  44. <xsl:copy>
  45. <xsl:apply-templates select="@*|node()"/>
  46. <discounted_price><xsl:value-of select="concat(format-number($price - $difference,'#,###.00'),' ',$currency)"/></discounted_price>
  47. <increased_price><xsl:value-of select="concat(format-number($price + $difference,'#,###.00'),' ',$currency)"/></increased_price>
  48.  
  49. </xsl:copy>
  50.  
  51.  
  52. </xsl:template>
  53.  
  54. <xsl:template match="size_present | size_stock">
  55. <xsl:copy>
  56. <xsl:value-of select="translate(., ' ', '')"/>
  57. </xsl:copy>
  58. </xsl:template>
  59. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement