This is the project update for the 25th August which I was unable to upload.
Query Module - 25/08/14 - X Query Language
X-Queries are exclusively used by the X-Producer, Sports Fiction and your ZeroOne applications to obtain results from an inquiry. X-Queries are an X-Element which you may also compile in your own
ZeroOne applications deployed by the X-Producer or may be a part of a DBPRO application you use with my
ZeroOne foundation plugin.
Note that as was not long ago discussed; ZeroOne applications compiled from my editor
will not include any of my SportsFiction or XProducer DarkBASIC programs including their viewports and physics executables; you must construct your own DarkBASIC programs (or what ever Windows compatible development tool you wish to integrate ZeroOne with); which should not take long with the X-Producers code generation features. In other words, compiling your DBPRO application is performed in DarkBASIC, and its ZeroOne features are to be compiled in the X-Producer and loaded by your copy of the ZeroOne foundation plugin for DarkBASIC.
To confuse you even more, your copy of the X-Producer can compile your DBP project... it runs the DarkBASIC compiler for you... but all of this is what takes place after effortlessly clicking a conveniently simple compile button, so all of the complicated work is done for you behind the scenes.
I emphasize these points to make clear why X-Queries are not just for x-production and sportsfictioning.
With that out of the way, we can all now look at the X-Query Language in trust that whether you are to become a Sports Architect, ZeroOne application developer, X-Producer module developer or X-Producer presentation developer, you can make use of these query features in your own works.
XQL
The features of X-Queries and the X-Query Language (XQL).
This is a comparison of the current state of XQL and the commonly used Structured Query Language (rarely refereed to as Server Query Language which is my personal preferred name).
* Structured Query Language (SQL) is used to access or manipulate information in databases. Databases store information arranged in tables used for access and manipulation. We use databases because they handle the complexities of validations, data-corruptibility, discrepancies, data-transactions, isolated storage and shared access without us having know about it.
* X Query Language is associated with ZeroOne and the X-Producer and is used to access or manipulate X; or anything that can be accessed or manipulated by ZeroOne and the X-Producer, which includes XML, images, databases and the windows operating system. XQL is processed in the ZeroOne application on the local computer; SQL is generally processed on a remote dedicated database server.
Although I do not know of any query language that is not structured; replacing the prefix with an X aligns the technology with the X-Producer and clears confusion between the two. Differentiating SQL and XQL is important because
both have a role in ZeroOne and may be used and discussed vigorously, and sometimes, side-by-side in future updates.
* By principle SQL is a standard raised by the ANSI (American National Standards Institute) which "constituents to strengthen the U.S. marketplace position in the global economy while helping to assure the safety and health of consumers and the protection of the environment". It is established, trusted, safe and omnipresent. (http://www.ansi.org/)
* By principle XQL is derived and must derive from SQL to adhere to such industry standards; however, it must be tailored to work closely with ZeroOne applications and to incorporate ZeroOne-integral XML in its syntax. Where SQL is consistently keyword orientated XQL can contain keywords and XML, and thus introduces XML standards inforced by the World Wide Web Consortium (W3C).
With all of the institutionalized requirements out of the way, let us take a look at the language itself.
Obtaining information
SELECT * FROM xmlDocument
SELECT * FROM <xmlDocument><FirstElement /><SecondElement /></xmlDocument>
These two examples above contain query language statements with a similar outcome; they gather all XML elements from within a certain xmlDocument element. The SELECT keyword tells the computer to pick something, and the next keyword indicates what it is. In this case, *, anything, FROM within something. In this case, from an XML document.
The former example uses a variable to obtain the XML and the latter example literally declares what xmlDocument is, as the query is declared. As far as I know, only XQL can perform both statements as they have been written.
These examples are not the most practical use for the querying feature. More practical examples will be introduced when this discussion progresses from basic to advanced. We do not want to leave not even one person behind.
Another interesting thing about the XQL statements is the fact that both deliver XML content by reference. The XML can be manipulated elsewhere for its lifetime, which is until nothing refers to the XML in memory.
Why XML
Quite simply because most of what ZeroOne is composed of, and what X-Producer can create, is defined by it. When you create XML, you can create X-Elements, which inturn creates the entities of your ZeroOne world.
Inserting information
INSERT xmlParagraph INTO xmlDocument
INSERT <paragraph>My Text<paragraph/> INTO xmlDocument.<FirstElement>
INSERT <paragraph>My Text<paragraph/> INTO xmlDocument.Element("FirstElement")
INSERT xmlParagraph INTO ( <xmlDocument><FirstElement /><SecondElement /><xmlDocument> ).<FirstElement>
In all of the four above examples, a paragraph XML element which contains the text 'My Text' are added to the FirstElement node inside of the xmlDocument node. The first and last examples add a previously declared XML element. The second and third examples insert an XML element declared immediately inside of the XQL statement.
Inserting information at a specified location in a list
The following three statements adds a box to the start of a list, which must not be a readonly list.
INSERT box IN listOfBoxes AT INDEX 0
INSERT AT 0, box INTO listOfBoxes
PUSH box INTO listOfBoxes
listOfBoxes.Insert(0,box)
The following three statements adds a box to the at the end of a list, which must not be a readonly list.
INSERT box INTO listOfBoxes
ADD box TO listOfBoxes
listOfBoxes.Add(box)
The following three statements adds a box as the third item in the list, which must not be a readonly list. Zero based indexes are used in X-Queries, zero is the first, one is the second and two is the third, and so on.
INSERT box IN listOfBoxes AT 2
INSERT box AT INDEX 2 IN listOfBoxes
INSERT AT 2, box INTO listOfBoxes
listOfBoxes.Insert(2, box)
Note that the INDEX keyword is optional for readability.
The last examples of the previous two sets of examples feature function syntax; they use programming syntax instead of query syntax. It is fine to use function syntax in XQL statements, as is the case in some SQL, but the use of query-styled syntax over functional syntax is more easy for most readers of English to interpret. Note that in theory, function syntax is marginally faster
when X-Queries are declared at runtime, but this is not a good reason to use such syntax prior to seeing
evidence.
Named queries
The following three statements are named by assignment to variables. Each example will return the same number of results, but with a slight difference in behaviour.
XQuery = SELECT * FROM list
XQuery = SELECT FROM list
XQuery = list
In the previous examples; the XQuery variable will contain the content of the list. In the second example, the SQL styled asterisk (*) symbol usage was removed because in XQL the symbol is optional. In the third example the XQuery variable and list become the same thing; when the XQuery variable is manipulated, the list is manipulated; this is not true of the first two examples where they become a read only list of results.
All three XQuery variables have deferred results, with content of the first two XQuery variables empty, or unprocessed, until something makes the inquiry, and each time something makes the inquiry. The third variable being a reference to the list, does no filtering (unless the list in-question happens to be an enumeration of something else).
The FROM keyword is optional, and is often more easier to read than when it is omitted.
Counting the results
In the following examples, if there are 10 players and
XQuery = SELECT FROM players, then all of the examples will display how many players there are. The print statement is a utility keyword used to output text to the XQuery console. The exceptions are that the first example runs a deferred query assumed to be declared as a variable in a previous statement, the second example declares and runs the query at the same time, and the last example gets the count directly.
Print XQuery.Count
Print (SELECT FROM players).Count
Print (SELECT players).Count
Print players.Count
All four examples return the number of players. They are all processed because the Count property will run the inquiry immediately.
Forecast
In a near future X-Query update; we will have introduced more XQL statements, more detailed queries and videos demonstrating X-Queries in action. Further along in time, my first simple ZeroOne application compiled by the X-Producer will be used to demonstrate X-Queries in deployed software. We will also demonstrate the connection between X-Reasons, X-Queries and X-Unions in ZeroOne's processing of game logic.