Re: Using Mathematica to create simple HTML webpages
- To: mathgroup at smc.vnet.net
- Subject: [mg110256] Re: Using Mathematica to create simple HTML webpages
- From: "Hans Michel" <hmichel at cox.net>
- Date: Thu, 10 Jun 2010 08:09:53 -0400 (EDT)
- References: <hul89c$ici$1@smc.vnet.net>
Robert: Mathematica's Export[ ] function in order to create a SIMPLE website . 1. Is the first tip don't do it? Try. But simple pages? See http://facstaff.unca.edu/mcmcclur/blog/08.04.09.BloggingMathematica.html Don't just use Export. There is ExportString[] Mathematica Cell are more amenable to "XML" format 2. When I export to HTML the first thing I find is the formating for Grids and Columns disappears - the text is in the right place but the Frames have gone. Is there a fix? There is the Needs["XML`"] package Use SymbolicXML In[13]:= ToSymbolicXML[Out[11]] Out[13]= XMLObject[Document][{XMLObject[Declaration][Version->1.0],XMLObject[Doctype][Expression,System->http://www.wolfram.com/XML/notebookml1.dtd]},XMLElement[Expression,{{http://www.w3.org/2000/xmlns/,mathematica}->http://www.wolfram.com/XML/,xmlns->http://www.wolfram.com/XML/},{XMLElement[Function,{},{XMLElement[Symbol,{},{PopupView}],XMLElement[Function,{},{XMLElement[Symbol,{},{List}],XMLElement[String,{},{Hello}],XMLElement[String,{},{World}],XMLElement[String,{},{Choice}],XMLElement[String,{},{End}]}]}]}],{}] Use the built in functions to do the equivalent of XSLT stylesheets. 3. At first I was amazed at how well you could use a Insert Graphic to create a drawing board in which you could place text, graphics, equations etc. All easily positioned (with some patience) and with the ability to overlay stuff giving some nice arty effects - what i had not reaslised what the result would be output to HTML as a single GIF which means Hyperlinks in the text inserted into the graphic have stopped working. Worse still, the result is slow to load when you are new to the page - i guess the GIF size is the issue but you cant change resolution and probably wouldn't want to because it already looks a little grainy. Use PNG 4. There doesn't seem to be a way of creating something like a dropdown with options - is that correct? All the Mathematica controls are converted to GIFs. Not correct. In[11]:= PopupView[{"Hello","World","Choice","End"}] Out[11]= BoxData[Hello] In[12]:= ExportString[Out[11],"XML"] Out[12]= <?xml version='1.0'?> <!DOCTYPE Expression SYSTEM 'http://www.wolfram.com/XML/notebookml1.dtd'> <Expression xmlns:mathematica='http://www.wolfram.com/XML/' xmlns='http://www.wolfram.com/XML/'> <Function> <Symbol>PopupView</Symbol> <Function> <Symbol>List</Symbol> <String>Hello</String> <String>World</String> <String>Choice</String> <String>End</String> </Function> </Function> </Expression> This style sheet in XSLT will take the XML output and transform to a Select element (XSLT is easier for me, but mathematica can mimick its functionality with its own functions. There are examples in the documentation. For the purpose of getting this response out I don't do enough transforms in mathematica from SymbolicXML to HTML for me to whip up an example in less that 5 minutes.) <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.wolfram.com/XML/" exclude-result-prefixes="a"> <xsl:output method="html"/> <xsl:template match="/"> <html> <head/> <body> <table border="1" width="100%"> <tbody> <tr> <td width="100%"> <select> <xsl:apply-templates select=""/> </select> </td> </tr> </tbody> </table> </body> </html> </xsl:template> <xsl:template match="a:Function"> <xsl:apply-templates/> </xsl:template> <xsl:template match="a:Symbol"> <xsl:if test="not(node() = 'PopupView' or node() = 'List')"> <option> <xsl:attribute name="value"> <xsl:value-of select="."/> </xsl:attribute> <xsl:value-of select="."/> </option> </xsl:if> </xsl:template> <xsl:template match="a:String"> <option> <xsl:attribute name="value"> <xsl:value-of select="."/> </xsl:attribute> <xsl:value-of select="."/> </option> </xsl:template> </xsl:stylesheet> 5. And, is there no way of creating the the equivalent of frames other than cheating again by puting the elements into separate graphics frames? Again see XML documentation. Also there are ConversionRules that can be set to guide mathematica on how to export or save HTML. Setting ConversionRules to Identity for a Cell style of your own naming/choosing will tell the conversion process to leave this Cell alone export as Raw. This is a way to inject HTML into the output. 6. My general impression is that Wolfram have set up some good basics but with gaps - so any idea what the future holds. Am I barking up the wrong tree and would webMathematica solve these problems? The HTML output is geared towards static html files. As soons as you want dynamic html forms elements you are now in a hybrid world of templates, XML, XHTML, javascript, Form, ... , jsp, asp, php... And I think the assumption that dynamic html content falls in the realm of web server familiarity and not just posting static pages and images. webMathematica would just be another tool to possible use, might be overkill for Simple HTML pages. But it is intended to do both static and dynamic. A forms based html page may seem simple to build but there is a lot going on when posting to a web server. Even if there is no postback then there will be some kind of scripting on the html page for interactivity. I think that activity goes beyond just simple static pages. Hans "Robert Wright" <mathematicauser1 at yahoo.com> wrote in message news:hul89c$ici$1 at smc.vnet.net... >I have been playing with Mathematicas Export[ ] function in order to create >a simple website and would be intereseted in others perspectives, tips and >advice. > 1. Is the first tip don't do it? > 2. When I export to HTML the first thing I find is the formating for Grids > and Columns disappears - the text is in the right place but the Frames > have gone. Is there a fix? > 3. At first I was amazed at how well you could use a Insert Graphic to > create a drawing board in which you could place text, graphics, equations > etc. All easily positioned (with some patience) and with the ability to > overlay stuff giving some nice arty effects - what i had not reaslised > what the result would be output to HTML as a single GIF which means > Hyperlinks in the text inserted into the graphic have stopped working. > Worse still, the result is slow to load when you are new to the page - i > guess the GIF size is the issue but you cant change resolution and > probably wouldn't want to because it already looks a little grainy. > 4. There doesn't seem to be a way of creating something like a dropdown > with options - is that correct? All the Mathematica controls are converted > to GIFs. > 5. And, is there no way of creating the the equivalent of frames other > than cheating again by puting the elements into separate graphics frames? > 6. My general impression is that Wolfram have set up some good basics but > with gaps - so any idea what the future holds. Am I barking up the wrong > tree and would webMathematica solve these problems? >