<NetML/>

How many ways are there to describe a computer network? Maybe one...


Disambiguation: NetML is also the name of a network design system developed by prof. Ronald G. Addie et al. If that is the system you are looking for, you may want to consider having a look at the pertaining Google Code page and at a reference paper.
Otherwise, enjoy your stay on this web site.

Home | News | Detailed Information | Download | Configuration Examples | Publications and Contacts

Index | Architecture | About XML | ER Diagrams | ER to XML | Per-vendor Comparison | Firewall Support

Detailed Information - About XML

NetML is an XML based language. There are lots of publicly available information concerning XML and the way to define schemas. This page aims at summing them up so that novice users can find here an easy to read introduction to XML, Schemas and DTDs.



HTML, SGML, and XML

The most important language exploited in defining NetML is the eXtensible Markup Language (XML), which was defined by the W3C (World Wide Web Consortium: the organization which defines the standards for the Web). XML can be used to create new elements to design a personalised markup language.

Generally, markup languages describe document formats (i.e. the way the document content will be interpreted). The most widespread language at present is HTML, which is used to create web pages. HTML tags (such as <head>, <center>, <i>, etc.) give directives to web browsers. This is exactly the role of markup languages.

Both HTML and XML are based on SGML (Standard Generalised Markup Language). SGML is extremely flexibile but could be also extremely difficult to learn. XML is a subset of SGML, while HTML is considered an implementation. The lastest version of HTML (4.01) has a total of 120 tags (which can be used mainly to construct web pages). However, these are not enough if we consider that in the Web the type of data that is being exchanged is often specific and tags must be able to describe these data. In conclusion, there are many reasons for creating markup languages and that is where XML comes in.

XML documents are structured documents and can be validated. To perform such a validation, there are different available technologies: DTDs, XML Schemas. For reasons that will be illustrated later on, we chose to use XML Schemas instead of DTDs to validate our language.

Other technologies which use XML are: XSLT (for transforming XML files into any other type of file, including XML), SVG (Scalable Vector Graphics) and many more.

XML DTDs & XML Schemas

DTDs (Document Type Definitions) and XML Schemas describe the vocabulary and structures that may appear in a document conforming to a given schema. Applications check documents against a Schema or DTD and process the documents only if they pass the inspection. DTDs provide a definition of how the structure of information in an XML document should look like, while Schemas also provide constraints to which documents must conform in order to be considered valid. Essentially, beyond simply defining the document structure, Schemas also allow to validate its content (i.e. they can do datatyping).

Of the two validation formats, DTDs are the oldest. They were used to validate SGML documents before XML was developed. For this reason, DTDs do not follow the XML rules like XML Schemas do. In particular, to define an element DTDs use the following syntax:

<!ELEMENT person (firstName,lastName)>

As it can be noted, it uses illegal name characters (i.e., ! ) and does not have a closing tag as well as quoted attributes. This element definition can be described using the following syntax in XML Schemas:

<xsd:element name="person">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="firstName" type="xsd:string"/>
      <xsd:element name="lastName" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

When choosing between DTDs and XML Schemas, it should also be taken into account that DTDs tend to be more compact with respect to Schemas. One line of code in a DTD is transformed into various (at least two) lines of code in a Schema.

Support for Namespaces

Namespaces are frequently used in different types of XML documents to prevent naming conflicts. Using namespaces allows elements that are used in different contexts and have different structures to be combined without mixing up the meaning of the elements themselves. For example, if a name element with multiple meanings is used in a document, you can introduce a namespace to clarify the meaning:

<product:name xmlns:product="http://www.acme.com/products">
Widget
</product:name>

<person:name xmlns:person="http://www.acme.com/persons">
Dave
</person:name>

Unfortunately, DTDs have no concept of namespaces. Most XML parsers allow you to "turn off" namespaces while validating an XML document against a DTD. XML Schemas, on the other hand, fully support namespaces and do so well. When you create an XML Schema document, you must declare a namespace (either a default or local namespace):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema ">

<!-- Schema definitions go here -->

</xsd:schema>

Namespaces used within the XML document being validated can be added into the schema as well.

Support for Datatypes

Much of the talk about using XML these days focuses on data exchange. With this being the case, it often happens that data within XML documents are to be imported into a permanent data store such as a relational database. Because database fields have specific data types, it's important that the data contained within the XML document matches up with the different field data types.

Unfortunately, DTDs have no real concept of data types. In fact, when you define an element in a DTD that contains a text node, you can only specify that the text node is Parsed Character Data (PCDATA). You cannot specify that the text must be a decimal, integer, date, and so on. Although DTD attribute definitions do contain a few more built-in data types such as ID, IDREF, and NMTOKEN, they still do not allow for validating against data types found in relational databases.

XML Schemas provide robust support for data types and also allow data types to be extended and customized. For example, if a particular XML element's text node needs to contain an integer ranging between 1,000 and 2,000, you can create a custom data type and use it within an XML Schema:

<xsd:simpleType name="rangeInt">
  <xsd:restriction base="xsd:integer">
    <xsd:minInclusive value="1000"/>
    <xsd:maxInclusive value="2000"/>
  </xsd:restriction>
</xsd:simpleType>

The element definition requiring this specific integer range can then reference the custom data type named "rangeInt":

<xsd:element name="range" type="rangeInt"/>

A validation error is reported if, while validating this element, its value if found to fall outside of the allowed range.

There can be constraints on the format the data can have (e.g., the contents of <SocialSecurityNumber> have to be of the form nnn-nn-nnnn, where n is a digit from 0 through 9).

Extensions

Xml Schema has a rich set of extension meccanisms including inheritance, redefinition, aggregation, and substitution. Aggregation groups a set of existing elements into a new one allowing the user to create, for example, attribute groups. Inheritance extends an already defined element so that it can stand in for the original. These meccanisms do not exist in DTDs.