I am new to XML .. I love to brew beer and want to share with you my recipe with the masses. I have created an XML and XSL file. now I want to be able to add recipes to the XML file from an HTML or similar. I would like to have a form that I can add new recipes to my collection. I do not know how I'm going to do to succeed. grateful for all the help I can get!
my XML file:
<?xml-stylesheet type="text/xsl" href="beer.xsl" ?> <Beers> <Beer> <name>BeerName</name> <type>APA</type> <end_date></end_date> <procent>4.8</procent> <made>2015-11-30</made> <units>9</units> </Beer> <Beer> <name>BeerName2</name> <type>APA</type> <end_date></end_date> <procent >4.8</procent> <made >2015-11-30</made> <units>9</units> </Beer> xsl file:
<?xml version="1.0" encoding="UTF-8"?> <xsl:output method="html" /> <xsl:template match="/"> <html> <head><title>Beer</title></head> <body> Version: <xsl:value-of select="system-property('xsl:version')" /><br /> Vendor: <xsl:value-of select="system-property('xsl:vendor')" /><br /> Vendor URL: <xsl:value-of select="system-property('xsl:vendor-url')" /><br /> <xsl:for-each select="Beers/Beer"> <a href="#{generate-id(name)}"> <xsl:value-of select="name" /></a><br /> </xsl:for-each> <br /> <xsl:for-each select="Beers/Beer"> <!-- xsl:sort sorts based on your rules select: node to base sort on order: ascending (default) or descending data-type: text or number --> <xsl:sort select="name" order="ascending" data-type="text" /> <!-- Print show name with a link to the list above --> <h3><a name="{generate-id(name)}"> <xsl:value-of select="name" /></a></h3> <!-- Here I create an img tag and add attributes to it --> <xsl:value-of select="current()"/> <p>The Beer <xsl:value-of select="name"/> is a: <xsl:value-of select="type"/> beer. the alcohol is <xsl:value-of select="procent"/>.% procent units produced <xsl:value-of select="units"/>. <xsl:value-of select="end_date"/> </p><br /> </xsl:for-each> <!-- Output Information in a table --> <table border="4"> <tr><th>Name</th><th>sort</th><th>units</th></tr> <xsl:for-each select="Beers/Beer"> <xsl:choose> <xsl:otherwise> <tr bgcolor="pink"> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="type"/></td> <td><xsl:value-of select="units"/></td> </tr> </xsl:otherwise> </xsl:choose> </xsl:for-each> </table> </body> </html> </xsl:template>
No comments:
Post a Comment