The DTD for the original version of XSDML is JX-model3.dtd and the extended version of XSDML, called XSDML level3, is JX-model3-ext.dtd.
The original version of XSDML is generated after syntactic parsing and locally semantic analysis, which represents source code written in Java programming language (Java2 ver 1.4) as 20 non-terminal elements and 7 terminal elements as shown in the following table. The terminal element has only the textual while the non-terminal element can nest others.
Elements of XSDML
Element name Fragment of Java source code File compilation unit (File) Package package declaration Import import declaration Class class declaration Intf interface declaration Ctor constructor declaration Method method declaration SInit static initializer Field field declaration Param formal parameter Local localvariable declaration ExtdOpt superclass clause ImplOpt superinterface clause ThrwOpt throws clause Members class/Interface body QName qualified identifier Type type Stmt statement Label label declaration Expr expression ident identifier literal literal comment comment kw keyword op operator sp blank or tab character nl new line character
The extended version of XSDMLis generated after globally semantic analysis. In addition to the elements described above, 3 elements are used. These elements have no textual content and never nest others.
Additional elements of XSDML level3
Element name Fragment of Java source code Ances ancestor of the class FqnMap fully qualified name map
The original version of XSDML has the following 24 attributes.
Attributes of XSDML
Attribute name Attribute type Description id ID identification number path NMTOKEN relative path name of the file name NMTOKEN file/class name qname NMTOKEN fully qualified name line NMTOKEN line number offset NMTOKEN offset newline NMTOKEN line feed code sort NMTOKEN minor name classifying elements typefirst IDREF link to the first Type element typenext IDREF link to the next Type element that follows a Type element omitted BOOL "yes" if two or more variable names are declared continuously with commas access NMTOKEN accessibility determined as either "Public", "Protedted", "Private", or none final BOOL "yes" if the code fragment is declared final
abstract BOOL "yes" if the code fragment is declared abstract
static BOOL "yes" if the code fragment is declared static
synchro BOOL "yes" if the code fragment is declared synchronized
native BOOL "yes" if the code fragment is declared native
volatile BOOL "yes" if the code fragment is declared volatile
transient BOOL "yes" if the code fragment is declared transient
strictfp BOOL "yes" if the code fragment is declared strictfp
read BOOL "yes" if the variable is used without changing its value write BOOL "yes" if the variable is used with changing its value defid IDREF links to the definition or declaration of the elemet fqn NMTOKEN fully qualified name
The extended version of XSDML uses 4 attributes in addition to the attributes described above.
Additional attributes of XSDML level3
Attribute name Attribute type Description classpath NMTOKEN classpath used when analyzing the source code ref NMTOKEN class name that the element refers to distance NMTOKEN distance between the class and its ancestor or descendant jar NMTOKEN name of the .jar file
NOTE: The red letters indicate the target code fragment. The code enclosed by green rectangles is the converted XSDML document.
NOTE: We insert moderate blanks and new lines in the converted document so that the readers easily see it although the actual code does not contain such characters.
This element indicates the .java file and can be a document root node of the DOM tree.
...
package java2d;
package java2d ;
import java.awt.*;
import java . awt . * ;
package java2d;
public class Java2Demo {
...}
public class Java2Demo ...
package java2d;
public interface CustomControlsContext {
...}
public interface CustomControlsContext ...
public class Java2Demo {
public Java2Demo() {}
...}
...
public Java2Demo ( ) ...
public class Java2Demo {
public void actionPerformed(ActionEvent e) {}
...}
...
public void actionPerformed ( ...
public class Java2Demo {
static {}
...}
...
static ...
public class Java2Demo {
private JMenuItem ccthreadMI, verboseMI;}
...
private JMenuItem ccthreadMI , verboseMI
public class Java2Demo {
public void actionPerformed(ActionEvent e) {}
...}
...
ActionEvent e
public class Surface {
private BufferedImage createSGISurface(int w, int h, int pixelBits) {}
int rMask32 = 0xFF000000;}
...
...
int rMask32 = 0xFF000000
import javax.swing.*;
public class Java2Demo extends JPanel {
...}
JPanel
import java.awt.event.*;
public class Java2Demo implements ActionListener {
...}
ActionListener
public class Surface {
public int print(Graphics g) throws PrinterException {}
...}
...
PrinterException
public class Java2Demo {
...}
{ ...
package java2d;
java2d
public class Java2Demo {
static DemoGroup group[];}
...
DemoGroup group []
Values of the sort attribute of the Type element
sort value Description Array array type (pairs of square brackets []) Primitive primitive type (including void) Object reference type
public class Java2Demo {
public void actionPerformed(ActionEvent e) {}
if (cloningfeature == null) {}
...}
...
...
if ( cloningfeature == null ) ...
Values of the sort attribute of the Stmt element
sort value Description EMPTY empty statement EXPR expression statement BLOCK block DOWHILE do
statementWHILE while
statementFOR for
statementIFELSE if-then
statementSWITCH switch
statementBREAK break
statementCONT continue
statementRETURN return
statementSYNCHRO synchronized
statementTHROW throw
statementTRY try
statementASSERT assert
statement
public class Surface {
private BufferedImage createBinaryImage(int w, int h, int pixelBits) {}
switch (pixelBits) {}
case 1:
...}
break;
...
...
public class Java2Demo {
public void actionPerformed(ActionEvent e) {}
if (e.getSource().equals(fileMI)) {}
System.exit(0);} ...
...
System . exit ( 0 )
Values of the sort attribute of the Expr element
sort value Description MUL multiplication operator ( *
)DIV division operator ( /
)MOD remainder operator ( %
)ADD addition operator ( +
)SUB subtraction operator ( -
)SHL left shift ( <<
)SHR signed right shift( >>
)SHRZ unsigned right shift( >>>
)NOT bitwise complement operator ( ~
)AND bitwise or boolean operator ( &
)XOR bitwise or boolean operator ( ^
)OR bitwise or boolean operator ( |
)Assign assignment operator ( =
)Assign$op compound assignment operator, the $op is either MUL, DIV, MOD, ADD, SUB, SHL, SHR, SHRZ, NOT, AND, XOR, or OR ( *= /= %= += -= <<= >>= >>>= ~= &= ^= |=
)DOT dot operation ( .
)InstanceOf type comparison operator ( instanceof
)PreINC prefix increment operator ( ++
)PreDEC prefix decrement operator ( --
)PostINC postfix increment operator ( ++
)PostDEC postfix decrement operator ( --
)Plus unary plus operator ( +
)Minus unary minus operator ( -
)LogicalNOT logical complement operator ( !
)LogicalAND conditional-and operator ( &&
)LogicalXOR conditional-xor operator LogicalOR conditional-or operator ( ||
)CondLT comparison operator ( <
)CondGT comparison operator ( >
)CondLE comparison operator ( <=
)CondEQ equality operator ( ==
)CondNE equality operator ( !=
)CondGE comparison operator ( >=
)Selection conditional operator ( ? :
)CtorCall constructor call SpCtorCall call to a superclass's constructor MethodCall method call Listed sequential values delimited with commas ArrayAccess array access expression InstanceCreation class instance creation expression ArrayCreation array creation expression Cast cast expression Paren parenthesized expression VarRef variable reference; the read and write attributes are added. TypeRef type reference Literal literal This this
operationClass class literal Empty empty expression
public class Java2Demo {
...}
Java2Demo
public class Java2Demo {
public Java2Demo() {}
progressLabel.setText("Loading images");}
...
...
"Loading images"
Values of the sort attribute of the literal element
sort value Description INT integer literal FLOAT floating-point literal STR string literal CHAR character literal BOOL boolean literal NULL null literal
/*
* @(#)Java2Demo.java
*/
/* * @(#)Java2Demo.java */
public class Java2Demo {
...}
Keywords:class
abstract boolean break byte case catch char class continue default do double else extends final finally float for if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while
public class Java2Demo {
...}
Operators and separators:{
! != %| & && &= ( ) * *= + ++ += , - -- -= . / /= : ; < << <<= <= = == > >= >> >>= >>> >>>= ? [ ] ^ ^= { | |= || } ~
This element stores information about a fully-qualified name.
This element stores information about an ancestor of the class.
Values of the sort attribute of the Ances element
sort value Description CLASS the ancestor is a class INTERFACE the ancestor is an interface