Message Board
Message Board > Programming > Math XML |
April 4, 2013, 18:26 | |
Zomg
None 641 posts |
This is some cool shit. Transforming XML into mathematical expressions. ^^ http://www.mathmlcentral.com/Tools/FromMathML.jsp ____________ |
# |
April 9, 2013, 11:21 | |
Dennis
どこかにいる 2097 posts |
It basically uses the XML to draw graphics and providing the graphic. Could be useful to use as a webservice in a math-oriented application, but I can't find a webservice on that site. ____________ Kwakkel |
# |
April 9, 2013, 11:48 | |
Zomg
None 641 posts |
Not sure if this would qualify for webservice usage: http://reference.wolfram.com/m … mples.html#9741 I am still vague on what a webservice is. As far as I know it is a combination of XML+HTTP in order to let different platforms communicate with each other over the web and publish their data. What do you wish to do? Use a MathML webservice to translate mathematical expressions into MathML XML so it can be published onto a webpage? ____________ |
# |
April 9, 2013, 12:55 | |
Dennis
どこかにいる 2097 posts |
AFAIK a web service is a program that is executed through a request sent via a protocol such as HTTP or SOAP and it returns (in most cases) an XML file with structured data. Older methods were external programs that had to be on the same server, or programs that had to be written in the same environment. The usefulness is, that the code can be written in a totally different language or even environment and server. In older environments for example, data gets fetched through a database link, causing performance loss, dependency on the external system. I wrote this program using only PL/SQL. PL/SQL code: DECLARE a VARCHAR2(4000); BEGIN DBMS_OUTPUT.put_line('--------------------------------'); a := fd_get_date(35.7,139.7,'utctime'); DBMS_OUTPUT.put_line(a); DBMS_OUTPUT.put_line('--------------------------------'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE); DBMS_OUTPUT.put_line('--------------------------------'); RAISE; END; The procedure fd_get_date gets 2 parameters for coordinates to get the current timezone of that location on Earth. The procedure: PL/SQL code: -- deze webservice geeft de datum en tijd van lengetegraad en breedtegraad gkv_url_ws CONSTANT VARCHAR2(1000) := 'http://www.earthtools.org'; -- URL gkv_rs_uri CONSTANT VARCHAR2(1000) := 'timezone-1.1'; -- resource URI (...) FUNCTION fd_get_date(pin_lat IN NUMBER, pin_long IN NUMBER, piv_node IN VARCHAR2 DEFAULT 'utctime') RETURN VARCHAR2 IS lv_req UTL_HTTP.req; lv_resp UTL_HTTP.resp; lv_line VARCHAR2(2048); lv_url VARCHAR2(2048); lv_content VARCHAR2(2048); lv_parser xmlparser.parser; lv_doc xmldom.DOMDocument; lv_el xmldom.DOMElement; lv_nodeList xmldom.DOMNodeList; lv_node xmldom.DOMNode; lv_getval VARCHAR2(4000); lv_lat VARCHAR2(100); -- converted to string lv_long VARCHAR2(100); -- converted to string BEGIN lv_lat := fv_convert_number(pin_lat); lv_long := fv_convert_number(pin_long); lv_url := UTL_URL.escape(gkv_url_ws||'/'||gkv_rs_uri||'/'||lv_lat||'/'||lv_long); lv_req := UTL_HTTP.begin_request(lv_url); UTL_HTTP.set_header(lv_req, 'User-Agent', 'Mozilla/4.0'); lv_resp := UTL_HTTP.get_response(lv_req); lv_content := ''; BEGIN LOOP UTL_HTTP.read_line(lv_resp, lv_line, TRUE); lv_content := lv_content || lv_line; END LOOP; UTL_HTTP.end_response(lv_resp); EXCEPTION WHEN UTL_HTTP.end_of_body THEN UTL_HTTP.end_response(lv_resp); END; --dbms_output.put_line(lv_content); lv_parser := xmlparser.newParser; xmlparser.setValidationMode(lv_parser, FALSE); xmlparser.parseBuffer(lv_parser, lv_content); lv_doc := xmlparser.getDocument(lv_parser); lv_el := xmldom.getDocumentElement(lv_doc); lv_nodeList := xmldom.getElementsByTagName(lv_el, piv_node); lv_node := xmldom.item(lv_nodeList, 0); lv_node := xmldom.getFirstChild(lv_node); lv_getval := xmldom.getNodeValue(lv_node); RETURN lv_getval; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE); RAISE; END fd_get_date; As you can see the program calls the webservice through the UTL_HTTP package which uses the URL. The response of the URL is an XML file. Even your browser can get it. Example from above would generate this URL: http://www.earthtools.org/timezone-1.1/35.7/139.7 As you click it you'll just see the XML, I read the lines from the response "object" and parse it as an XML using XMLDOM. Then I can get the node I want and return it. The essential part is that the calculation of the time zone is not within my application, but it can be done in any application, no constraints, no database links, just HTTP access. I might be wrong here and there, since I'm still learning it myself. But this is just one example I made, and apparently it works. ____________ Kwakkel |
# |
April 9, 2013, 13:31 | |
Zomg
None 641 posts |
That is some impressive PL/SQL code there indeed. Last year in our programming project we used the concept of web services. Sort of like passing on the workload to another entity. What I think you are saying (and I am not sure of it) is this: So let's say you write some PL/SQL app, you link it to your webapp and you link it to a button 'generate' on your own website. When you click it, it then does something like POST http://www.mathml.org/first-de … uation/get-data or GET http://www.mathml.org/first-degree-equation?y=2x and then that URL would provide your PL/SQL app with a MathML node tree from which you can select results so you can insert them back into the response for the client's browser to display it. Although I think the POST request would be better since a GET request is limited to 255 chars. And security etc. I am still confused on it because I need to study now and I cannot focus much. ____________ |
# |
Message Board > Programming > Math XML