Fork me on GitHub

Tutorial 6

E06: Creating a XHTML document from scratch

Finally we go the other way around. We create a new document and fill the content via a projection. (Not that it would not be productive to create a website this way, just a demonstration.)

  • Create a new document from scratch
  • Usage of configuration injection to modify the output transformer.

Projection API

public interface XHTML {
     
    @XBWrite("/html/@xmlns")
    XHTML setRootNameSpace(String ns);
     
    @XBWrite("/html/@xml:lang")
    XHTML setRootLang(String lang);
     
    @XBWrite("/html/head/title")
    XHTML setTitle(String title);
     
    @XBWrite("/html/body")
    XHTML setBody(String body);
}

Example Code

XHTML xhtml = projector.projectEmptyDocument(XHTML.class);
 
xhtml.setRootNameSpace("http://www.w3.org/1999/xhtml").setRootLang("en");
xhtml.setTitle("This Is My Fine Title");
xhtml.setBody("Here some text...");