7.2 Example of using Xcomponents in Java

In a Java program, you must first generate Xcomponents and compile them with the Java compiler. Only then can you get an instance of the Xcomponent created from the input XML data:
// 1. compile Xdefinition sources and generate Xcomponents
  File xdef =  ...; File data = ...;
  XDPool xpool = XDFactory.compileXD(null, xdef);
  XDDocument xdoc = xpool.createXDDocument("Test");
... compile generated Xcomponents ...
// 2. parse the input data and get the instance of Xcopmponent
  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 = "Xdefinitions" >
  <author>Tomáš Šmíd</author>
</Book>
you can get the instance of Xcomponent from data by method xparseXComponent from XDDocument. The printed result will be:
Book: Xdefinition, ISBN = 123456