Chapter 8: Examples and Other Technologies
Examples
We can do thousands of examples with this technology. It is as simple as taking any other example from another language and see how it would be written in STxT. Perhaps the simplest would be an example that comes from XML, as it has many things in common with STxT (the next chapter discusses this topic in particular).
I have obtained many examples from Wikipedia.
One (invented) xml example would be:
<Library> <Book id="1"> <Title>The Fellowship of the Ring</Title> <Author>J.R.R. Tolkien</Author> <Language>EN</Language> <Published>29 July 1954</Published> <Genre>High fantasy Adventure</Genre> </Book> <Book id="2"> <Title>The Two Towers</Title> <Author>J.R.R. Tolkien</Author> <ISBN>76542</ISBN> <Language>EN</Language> <Published>11 November 1954</Published> <Genre>High fantasy Adventure</Genre> </Book> <Book id="3"> <Title>The Return of the King</Title> <Author>J.R.R. Tolkien</Author> <ISBN>12345</ISBN> <Language>EN</Language> <Published>20 October 1955</Published> <Genre>High fantasy Adventure</Genre> </Book> </Library>
The same thing if we pass it to STxT:
Library (www.examples.com/demo.stxt): Book: id: 1 Title: The Fellowship of the Ring Author: J.R.R. Tolkien Language: EN Published: 29 July 1954 Genre: High fantasy Adventure Book: id: 2 Title: The Two Towers Author: J.R.R. Tolkien ISBN: 76542 Language: EN Published: 11 November 1954 Genre: High fantasy Adventure Book: id: 3 Title: The Return of the King Author: J.R.R. Tolkien ISBN: 12345 Language: EN Published: 20 October 1955 Genre: High fantasy Adventure
Another example in XML:
<email> <from>John Smith</from> <to>Mery Adams</to> <cc>Keyla Brown<cc> <title>Project report</title> <body>Hello Mery!! The book is finished!!</body> </email>
In STxT it transforms into:
Email (www.example.com/email.stxt): From: John Smith To: Mery Adams Cc: Keyla Brown Title: Project report Body: Hello Mery!! The book is finished!!
We see that the conversion between the two formats is immediate, but the STxT is much better looking. By the way, STxT always has a grammar, while XML does not until a dtd or an xsd are not applied.
Wikipedia (*)
I feel great admiration for wikipedia. I think it is one of the best projects that have been created on the Internet.
How could it benefit from STxT?
Well, wikipedia could have different templates: actors, politicians, tv series, films, cities, countries, rivers,... sharing grammars in many cases. For example, both actors and politicians can have biographies, but actors can also have a listing of films.
In addition, a mixture of STxT with the wikipedia language would be very interesting. I think that this is a point where STxT beats most languages. The mixture with the so-called "lightweight markup languages" is really spectacular.
Thus, mixed texts can be made of the following style:
City (www.wikipedia.org/city.stxt): Name: Barcelona Autonomous Community: Catalonia Country: Spain History: {{Main|History of Barcelona}} The founding of Barcelona is the subject of two different legends. The first attributes the founding of the city to the mythological [[Hercules]]. The second legend attributes the foundation of the city directly to the historical [[Carthage|Carthaginian]] [[Hamilcar Barca]], father of [[Hannibal]], who named the city ''Barcino'' after his family in the 3rd century BC. ...
Another advantage is that with STxT we would not only have "templates" of how a city information should be, but we could also apply styles and formats depending on the document type.
STxT and other technologies
Lightweight markup language
Lightweight markup languages have had a spectacular boom thanks to projects like Wikipedia. Thanks to them we can define text in a much simpler way than having to write tags as with HTML. But they have a big deficiency: They do not have a clear structure and semantics.
What's more, almost all of them deal with the text style:
- Bold
- Italic
- Lists of elements
- Data tables
- ...
It’s surprising to see what we can achieve if we combine these languages with STxT. We get text that is easy to interpret, with defined semantics, and with the expressiveness of both languages.
One example:
Product: Name: Magic memory Price: €10 Description: This product produces a //magical rejuvenation// of your memory and provides an **immediate** effect on everyone who tries it. Effects: * Quick memorization * Automatic learning * Greater concentration
We see that we have given structure thanks to STxT, but the description is given with a wikipedia style.
The union of STxT with Lightweight markup languages is simply spectacular
Tex, Latex
Please forgive me if I criticize a lot. I never do it without giving an alternative or a reason. I like constructive criticism ;-) I've seen that one of the objectives of TeX is that a document be printed the same now as in 100 years. It had seemed perfect... until now. Now I believe that the objective should be that it means the same now as 100 years from now, and that it is understood now and in 100 years. And the more people the better. This is not achieved with TeX, but it is with STxT. A document is understood today and 100 years from now. How do I think it should evolve? I would make documents in STxT, would specify a grammar for the different types of documents, would allow TeX elements (such as formulas) in the same way that is done with lightweight markup languages, and would use TeX as rendering engine.
I dare say that TeX is unbeatable in terms of rendering; and I think that it will be at least for 100 years more ;-)
What would a document look like? Well, a simple example would be something like this:
Article (www.latex.com/article.stxt): Title: Author: References: Reference: Title: Year: ISBN: Reference: Title: Year: ISBN: Paragraph: This is a mathematical formula: Formula: \begin{eqnarray} x&=&y\\ x^2&=&xy\\ x^2-y^2&=&xy-y^2\\ (x+y)(x-y)&=&y(x-y)\\ x+y&=&y\\ 2y&=&y\quad \mbox{(first ecuation)}\\ 2&=&1 \end{eqnarray} Paragraph: Hello World!!
In fact, now that we can think in STxT, maybe it’s time to make formulas a different way, or a more simplified notation, such as:
Article (www.latex.com/article.stxt): Title: Author: References: Reference: Title: Year: ISBN: Reference: Title: Year: ISBN: Paragraph: This is a mathematical formula: Formula: Array: Element: x&=&y Element: x^2&=&xy Element: x^2-y^2&=&xy-y^2 Element: (x+y)(x-y)&=&y(x-y) Element: x+y&=&y Complex: Element: 2y&=&y\quad Element: mbox{(first ecuation)} 2&=&1 Paragraph: Hello World!!
Well, there are thousands of possibilities and ways of approaching the problem, I leave it up to you to practice with them ;-D
What have we gained with respect to just TeX?
- Ease in creating documents
- UTF-8
- Defined structure
- Semantic text
- Readable text
And in addition, we have kept the compactness in the creation of mathematical formulas and in other elements where TeX is really a great language.
JSON (*)
JSON in general has nothing to do with STxT, but there are certain moments where they might compete with each other. I am thinking in web services with REST. I bet for STxT, because it is as easy (or more) to parse as JSON, and it gives documents a clear meaning. In addition, it is more flexible and easier to read when we embed a large quantity of text, whereas in JSON all the escape characters must always be taken into account.
But you there is no need to worry too much. Apart from web services, I don't think that JSON and STxT are direct competitors, due to their different field of application.
Other (*)
There are other languages that may be similar to STxT, but I believe that none of them have been made with the same approach. For example, YAML has some similarities in the way that it uses indentation, or CofeeScript, which having a sometimes similar appearance, has nothing to do with STxT.
STxT aims to provide structure and semantics to the document, while at the same time allowing a readable text for the majority of people, regardless of their computer knowledge.