Introduction to XML part 2

November 3rd, 2007

XML

I wrote a post in the past about the basics of XML structure and how to build a DTD to define your document type. DTDs describe well how elements are arranged in a document but say very little about the content in the document. Also any element in a document has to have a corresponding declaration in the DTD. These problems and limitations could be solved using schemas. Schemas support rules (and ability to define content) which should be followed in order for a document to be valid. For example lets say that you need to describe a city element. The schema code should look like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name=”city” type=”xs:string”/>
</xs:schema>

The xs:element element acts like the !ELEMENT declaration in DTDs. Its name declares a name and its type attribute defines the data type. The xs:string describes the data type of the element “city”. Schemas provide many more features. For example lets say that you want to describe a date element. Date should have some restrictions, for example month should be filled with certain numbers (from 1 to 12) and so on. Enhancing these restrictions in a schema is very easy:

<xs:simpleType name="month"
  <xs:restriction base=”xs:integer”>
     <xs:minInclusive value=”1″/>
     <xs:maxInclusive value=”12″/>
  </xs:restriction>
</xs:simpleType>

To sum up, schemas are more powerfull than DTDs and allow more flexible data quality control. DTDs though are commonly used and more easy to structure.

Tags: , , , ,

Grab our OPML file!

September 20th, 2007

Opml

OPML is an XML-based format that allows exchange of outline-structured information between applications running on different operating systems and environments. With an OPML file you are able to add multiple feeds to your favorite feed reader, without having to add each feed url seperately. Most feed readers (like RSS owl, Google Reader) allow users to export their feeds in an OPML file and share them or import them in another reader. You can download our OPML file and see what we are reading (we read Greek blogs too, but the file contains only the those that are written in English), including Java blogs, tech blogs and news-based blogs.

You can get the official OPML icon or read about how it was created here.

Tags: , , , ,

Introduction to XML

September 15th, 2007

XML

XML (eXtensible Markup Language) is a meta-language built on SGML. XML can be used to describe data (for example database data) and can be also used for creating other markup languages. HTML was rewritten in XML and the result was XHTML.

With HTML tags, users can format or style pages. With XML users can only describe data. To make it easy for XML parsers to read XML data, users must be aware of uppercase and lowercase syntax. XML provided the background for technologies like RSS, OPML and SAML. XML applications contain typically the following:

  • The .xml file containing the XML data
  • The DTD (.dtd) or XML schema (.xsd) file that defines the structure of the main file.
  • A stylesheet file (optional).

Here is a very simple example to understand how XML works. Let’s say that we have to describe user account data. Our main file (.xml) will have the following code in it:

<?xml version="1.0" encoding="utf-8"?>
<store>
<account>
<username>Typpz</username>
<city>Athens</city>
<realname>Nikos</realname>
</account>

<account>
<username>Johnny</username>
<city>Thessaloniki</city>
<realname>John</realname>
</account>
</store>

For this code above the DTD (.dtd) file should contain the following elements to define the tags used.

<!ELEMENT store (account)*>
<!ELEMENT account (username, city, realname)>
<!ELEMENT username (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT realname (#PCDATA)>

After building your DTD file, save it as example.dtd (name the file as you want). Then you have to call the .dtd file from your .xml file. To do that, just place the followng line after <?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE store SYSTEM "example.dtd">

The main code will look like this:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE store SYSTEM "example.dtd">
<store>
<account>
<username>Typpz</username>
<city>Athens</city>
<realname>Nikos</realname>
</account>

<account>
<username>Johnny</username>
<city>Thessaloniki</city>
<realname>John</realname>
</account>
</store>

That was a very simple example for understanding XML structure. DTD files have many disadvantages, that can be solved using XML Schemas. These disadvantages and basic schema structure will be part of a following post.

Tags: , ,

Web 3.0 logo

As you probably know, we live in the web 2.0 time. Social websites are everywhere and users are now part of the Internet world and not just readers that read information. Now they express themselves (through blogs), they are part of social sites like digg, slashdot and so on. Broadband connections gave the ability for video calls, VOIP, IPTV and fast video streaming. What about the next version of web called Web 3.0?

Up to now we do not know much for Web 3.0, but it will for sure feature better and smarter search engines. Now search engines search using the keywords we provide. In web 3.0 they will have smart feature and they will be able to “understand” what the user looks for (according to his habits and his previous searches). In addition to this, users will be able to search using files and not only keywords. For example: today, if a user looks for Paris Hilton’s photos, he opens the search engine, types “Paris Hilton” and gets in the results every image that contains the words Paris Hilton in its file name or in the page where the image is stored. In web 3.0 users will be able to upload files and search using them (some sites like like.com and Pandora are already following that trend). Automatic tagging will be another feature in the future. Social sites will be able to understand information like human do (or almost like) and add tags automatically. All these has to do with semantic web abilities but web does not stop there: technologies like 3d web will change the way we surf in the Internet. Users will be able to virtually travel to places they haven’t visited before (something like Google Earth but not from above and with the ability to move inside the cities like in real-time). Mobile phones will become also smarter, they will be probably able to inform your friends if something happens and you cannot meet them, or send an email to your co-worker to remind him of your meeting.

Web 3.0 is not so far as we think. Large companies like Yahoo and HP have spent lot of money on researches and accepted the Semantic Web stanrdards, while others like Google and Microsoft work on the 3D web area. Nobody can tell for sure how the Web will look like in a few years but the evolution has already become with web 2.0. Maybe web will become a second world much more than second life is today.

Tags: , , , , ,

TopTOP