| [ directory ] |
|
16.4 Interworking with Other SoftwareA Web application is constructed from not only XML technologies but also other technologies, most notably programming languages and relational database management systems (RDBMSs). In this section, we consider the gaps between schema languages and these technologies. 16.4.1 Interworking with Programming LanguagesThis book concentrates on Java, but other programming languages, such as Visual Basic, C++, C#, Perl, Python, and Ruby, are also widely used. We certainly would like to handle XML documents from these languages. Here, we consider the similarities and differences between schema languages and such programming languages. First, the data structures of XML and those in programming languages exhibit different characteristics.
There are no standard ways to bridge these gaps. Some features of schema lan guages can be considered as mechanisms for narrowing the gaps (for example, all of W3C XML Schema and interleave of RELAX NG). However, the gaps are still large, and they are patched by data binding tools. Second, inheritance is a controversial issue. Many programming languages provide inheritance, but different languages have different styles. Java has single inheritance, interfaces, and inner classes. On the other hand, C++ does not have interfaces but provides multiple inheritance and inner classes. Features of other languages are also different from Java or C++. To make XML programming easier (possibly by using data binding tools), should a schema language support inheritance? If so, which style of inheritance should be adopted, and how should inheritance be integrated with content models? W3C XML Schema and RELAX NG have very different answers, and we consider them in Section 16.5. Third, both schema languages and programming languages need datatypes. It is obviously useful to share datatypes. In fact, many datatypes of W3C XML Schema are borrowed from Java, and other schema languages in turn use datatypes of W3C XML Schema. We have already shown correspondences between W3C XML Schema and Java in Chapter 9, Section 9.2.2. 16.4.2 Relational DatabasesThe structures of RDBMSs are flatter than those of XML documents. The former are basically collections of tables, while the latter are ordered trees without any upper bound on the height or width. There have been many attempts to bridge this gap. However, it is still difficult to convert arbitrary XML documents to RDBMS data. Chapter 10 gives design guidelines for implementing such a conversion but does not provide automatic conversion. On the other hand, if an XML document already has a tabular structure, it is easy to store it in RDBMS. It is also easy to output the contents of an RDBMS as XML documents. Again, it is useful to share datatypes between XML and RDBMS. W3C XML Schema borrows date-time-related datatypes from SQL, and other schema languages further borrow these datatypes. We have already seen correspondences between W3C XML Schema and SQL in Section 9.2.2. 16.4.3 Desiderata for Schema LanguagesWe have observed that data models of programming languages and RDBMSs differ significantly from schema languages. We have also observed that data binding tools patch the gaps. Can and should schema languages fill the gaps? Some people (including the designers of W3C XML Schema) believe that schema languages should borrow mechanisms from programming languages and RDBMS to narrow the gaps. This approach may facilitate conversion from other technologies to schema languages, but may complicate schema languages and hamper conversion in the other direction. Others (including the designers of RELAX NG) believe that schema languages should stay neutral from programming languages and RDBMSs by not incorporating any mechanisms specific to some of them. This approach makes schema languages simpler. However, the gaps have to be filled by data binding tools. We revisit this issue in sections 16.5.2 and 16.5.3. |
| [ directory ] |
|