Subject: [xsl] transforming Content Markup (not presentation) similar to MML From: Dan Diebolt <dandiebolt@xxxxxxxxx> Date: Wed, 9 May 2001 06:35:18 -0700 (PDT) |
I have been exploring using "content markup" (chapter 4) (http://www.w3.org/TR/2001/PR-MathML2-20010108/chapter4.html) of the Mathematical Markup Language to represent sets of equations. For example, the following MML represents the quadratic equation y1 = (a*x+b)*x+c : <apply> <eq/> <ci>y1</ci> <apply> <plus/> <apply> <times/> <apply> <plus/> <apply> <times/> <ci>a</ci> <ci>x</ci> </apply> <ci>b</ci> </apply> <ci>x</ci> </apply> <ci>c</ci> </apply> </apply> I need a set of general purposes xslt templates that will reconstruct the inline equation "y1=(a*x+b)*x+c;" given the MML above. One issue that comes up is precedence of the operators (<plus/>, <minus/>, <times/> ...). For example the following XML: <apply> <times/> <ci>a</ci> <apply> <plus/> <ci>b</ci> <ci>c</ci> </apply> </apply> Needs to be rendered as a*(b+c) not a*b+c. My approach has been to use an external precedence document to lookup the precedence of operators using Ogbuji's Lookup method (http://www-106.ibm.com/developerworks/ library/x-xsltip.html): <precedences> <item apply="eq" precedence="1"/> <item apply="plus" precedence="2"/> <item apply="minus" precedence="2"/> <item apply="times" precedence="3"/> <item apply="divide" precedence="3"/> </precedences> and to surround the output of inner <apply>'s with balanced parentheses whenever the precedence of the inner apply is higher than the precedence of the outer <apply>'s. The goal then would be able to transform MML representing lengthy code fragments such as: y=(a*x+b)+c; } maybe a ... } hundred z=(A*y+B)*y+C; } lines *including* constructs for program flow (for, do, while, if, case, etc.). The stylesheets may need to target different langauges, so I would like to set things up to be as general as possible to allow for extension. So these are my questions for the list: 1) Has anyone attempted this type of application (styling MML into inline equations, ie what MML calls content markup - chap 4)? 2) How would you approach this problem? Do utilities already exist? 3) MML does not have constructs for program flow. The closest MML comes to program flow is piecewise definition of functions via <piecewise>, conditionals <condition> and a "such that" tag. How would you represent tags for if statements, loops, switch or case statements keeping in mind the XML will need to be transformed via XSLT into standard looking c-code (for example). My emphasis for this questions is to insure the XML can be easily styled into a target language (such as c-code). Please don't submit code (unless you need an end of the day challenge!) as I am looking first at the big picture and trying to evaluate among alternatives. Regards, Dan __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] URL Encoding, Michael Kay | Thread | Re: [xsl] transforming Content Mark, David Carlisle |
Re: [xsl] Ordering of Blocks based , Francis Norton | Date | [xsl] JAXP Transformer contract, Nestel, Frank |
Month |