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"
      year="2020"
      title = "X-Definitions" >
  <author>Tomáš Šmíd</author>
</Book>
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