Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Programs using XML – Schema – XSLT/XSL in Java

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!-- Edited by XMLSpy® -->
  3. <breakfast_menu>
  4. <food>
  5. <name>Belgian Waffles</name>
  6. <price>$5.95</price>
  7. <description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
  8. <calories>650</calories>
  9. </food>
  10. <food>
  11. <name>Strawberry Belgian Waffles</name>
  12. <price>$7.95</price>
  13. <description>light Belgian waffles covered with strawberries and whipped cream</description>
  14. <calories>900</calories>
  15. </food>
  16. <food>
  17. <name>Berry-Berry Belgian Waffles</name>
  18. <price>$8.95</price>
  19. <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
  20. <calories>900</calories>
  21. </food>
  22. <food>
  23. <name>French Toast</name>
  24. <price>$4.50</price>
  25. <description>thick slices made from our homemade sourdough bread</description>
  26. <calories>600</calories>
  27. </food>
  28. <food>
  29. <name>Homestyle Breakfast</name>
  30. <price>$6.95</price>
  31. <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
  32. <calories>950</calories>
  33. </food>
  34. </breakfast_menu>
  35.  
  36. XSLT File
  37. <?xml version="1.0" encoding="ISO-8859-1"?>
  38. <!-- Edited by XMLSpy® -->
  39. <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
  40. <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
  41. <xsl:for-each select="breakfast_menu/food">
  42. <div style="background-color:teal;color:white;padding:4px">
  43. <span style="font-weight:bold"><xsl:value-of select="name"/></span>
  44. <xsl:value-of select="price"/>
  45. </div>
  46. <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
  47. <xsl:value-of select="description"/>
  48. <span style="font-style:italic">
  49. <xsl:value-of select="calories"/> (calories per serving)
  50. </span>
  51. </div>
  52. </xsl:for-each>
  53. </body>
  54. </html>
  55.