Package org.takes.rs

Class RsXslt

  • All Implemented Interfaces:
    Body, Head, Response

    public final class RsXslt
    extends RsWrap
    Response that converts XML into HTML using attached XSL stylesheet.

    The encapsulated response must produce an XML document with an attached XSL stylesheet, for example:

    <?xml version="1.0"?>
     <?xml-stylesheet href="/xsl/home.xsl" type="text/xsl"?>
     <page/>
     

    RsXslt will try to find that /xsl/home.xsl resource in classpath. If it's not found a runtime exception will thrown.

    The best way to use this decorator is in combination with RsXembly, for example:

     new RsXSLT(
       new RsXembly(
         new XeStylesheet("/xsl/home.xsl"),
         new XeAppend(
           "page",
           new XeDate(),
           new XeLocalhost(),
           new XeSLA()
         )
       )
     )

    Note: It is highly recommended to use Saxon as a default XSL transformer. All others, including Apache Xalan, won't work correctly in most cases.

    The class is immutable and thread-safe.

    Since:
    0.1
    See Also:
    RsXembly
    • Constructor Detail

      • RsXslt

        public RsXslt​(Response rsp)
        Ctor.
        Parameters:
        rsp - Original response
      • RsXslt

        public RsXslt​(Response rsp,
                      URIResolver resolver)
        Ctor.
        Parameters:
        rsp - Original response
        resolver - URI resolver