8.2 Example of using X-components in Java

In a Java program, you must first generate X-components and compile them with the Java compiler. Only then can you get an instance of the X-component created from the input XML data:
// 1. compile X-definition sources and generate X-components
  File xdef =  ...; File data = ...;
  XDPool xpool = XDFactory.compileXD(null, xdef);
  XDDocument xdoc = xpool.createXDDocument("Test");
... compile generated X-components ...
// 2. parse the input data and get the instance of X-copmponent
  test.book.Book book = (test.book.Book) xdoc.parseXComponent(data, null, null);
  System.out.println("Book: " + book.gettitle() + ", isbn = " + book.getisbn());
If the file with data is written the XML document:
<Book isbn="123456789"
      title = "X-Definitions" >
  <author>Tomáš Šmíd</author>
you can get the instance of X-component from data by method xparseXComponent from XDDocument. The printed result will be:
Book: X-definition, isbn = 123456

Prev  Content   End of book