I am really interested in how FB created FBML and how to go about creating something similar. Did they write a C++ processor that replaces FBML with HTML or do they use XSLT or what did they do to create a templating language like that? I am wanting to do this mainly for my own knowledge and fun on my spare time to see if i am able to build something similar. Ive tried looking up how they made it but all I get is wa开发者_运维问答ys to use FBML.
If it is a Facebook app, then a browser such as FF or IE connects to app.facebook.com/some_app
, and the Facebook server will connect to www.foobar.com/blah
(which the app creator register with Facebook) for the FBML code, and Facebook can change it to whatever it wants -- changing the FBML into XHTML. They can use parsers to parse the FBML code, and convert it into XHTML accordingly.
Well, there are 3 ways to write a parser for XML that converts to HTML:
- write a parser in lex and bison
- use an XML parser library to read the XML into memory, and us a "normal" programming language to convert the XML to HTML.
- use XSLT
- use some web framework that supports custom tag libraries that can convert the FBML tags to HTML.
Option #1 is bascially not done since you can always use #2 instead.
Judging from the the fact that some of the tags need to talk to resources outside of the XML file (e.g. fb:if-can-see
), #2 and #4 seem more likely than #3 -- both would have easier access to SQL databases or NoSQL databases and the like.
(The XSLT libraries in many languages allow one to define custom functions that can access arbitrary data sources in the language they are implemented, so #3 isn't impossible).
精彩评论