Package com.jcabi.xml

Class XSLDocument

  • All Implemented Interfaces:
    XSL

    public final class XSLDocument
    extends Object
    implements XSL
    Implementation of XSL.

    Objects of this class are immutable and thread-safe.

    Since:
    0.4
    Suppressed Checkstyle violations:
    ClassDataAbstractionCouplingCheck (500 lines), AbbreviationAsWordInNameCheck (5 lines), ClassFanOutComplexityCheck (500 lines)
    • Field Detail

      • STRIP

        public static final XSL STRIP
        Strips spaces of whitespace-only text nodes.

        This will NOT remove existing indentation between Element nodes currently introduced by the constructor of XMLDocument. For example:

         
         <a>
                   <b> TXT </b>
            </a>
         
        becomes
         
         <a>
             <b> TXT </b>
         </a>
         
        Since:
        0.14
    • Constructor Detail

      • XSLDocument

        public XSLDocument​(XML src)
        Public ctor, from XML as a source.
        Parameters:
        src - XSL document body
      • XSLDocument

        public XSLDocument​(XML src,
                           String base)
        Public ctor, from XML as a source.
        Parameters:
        src - XSL document body
        base - SystemId/Base
        Since:
        0.20
      • XSLDocument

        public XSLDocument​(URL url)
                    throws IOException
        Public ctor, from URL.
        Parameters:
        url - Location of document
        Throws:
        IOException - If fails to read
        Since:
        0.7.4
      • XSLDocument

        public XSLDocument​(URL url,
                           String base)
                    throws IOException
        Public ctor, from URL with alternative SystemId.
        Parameters:
        url - Location of document
        base - SystemId/Base
        Throws:
        IOException - If fails to read
        Since:
        0.26.0
      • XSLDocument

        public XSLDocument​(File file,
                           String base)
                    throws FileNotFoundException
        Public ctor, from file with alternative SystemId.
        Parameters:
        file - Location of document
        base - SystemId/Base
        Throws:
        FileNotFoundException - If fails to read
        Since:
        0.26.0
      • XSLDocument

        public XSLDocument​(Path file,
                           String base)
                    throws FileNotFoundException
        Public ctor, from file with custom SystemId.
        Parameters:
        file - Location of document
        base - SystemId/Base
        Throws:
        FileNotFoundException - If fails to read
        Since:
        0.26.0
      • XSLDocument

        public XSLDocument​(URI uri)
                    throws IOException
        Public ctor, from URI.
        Parameters:
        uri - Location of document
        Throws:
        IOException - If fails to read
        Since:
        0.15
      • XSLDocument

        public XSLDocument​(URI uri,
                           String base)
                    throws IOException
        Public ctor, from URI.
        Parameters:
        uri - Location of document
        base - SystemId/Base
        Throws:
        IOException - If fails to read
        Since:
        0.26.0
      • XSLDocument

        public XSLDocument​(InputStream stream)
        Public ctor, from XSL as an input stream.
        Parameters:
        stream - XSL input stream
      • XSLDocument

        public XSLDocument​(InputStream stream,
                           String base)
        Public ctor, from XSL as an input stream.
        Parameters:
        stream - XSL input stream
        base - SystemId/Base
        Since:
        0.20
      • XSLDocument

        public XSLDocument​(String src)
        Public ctor, from XSL as a string.
        Parameters:
        src - XML document body
      • XSLDocument

        public XSLDocument​(String src,
                           String base)
        Public ctor, from XSL as a string.
        Parameters:
        src - XML document body
        base - SystemId/Base
        Since:
        0.20
      • XSLDocument

        public XSLDocument​(String src,
                           Sources srcs)
        Public ctor, from XSL as a string.
        Parameters:
        src - XML document body
        srcs - Sources
        Since:
        0.9
      • XSLDocument

        public XSLDocument​(String src,
                           Sources srcs,
                           String base)
        Public ctor, from XSL as a string.
        Parameters:
        src - XML document body
        srcs - Sources
        base - SystemId/Base
        Since:
        0.20
      • XSLDocument

        public XSLDocument​(String src,
                           Sources srcs,
                           Map<String,​Object> map)
        Public ctor, from XSL as a string.
        Parameters:
        src - XML document body
        srcs - Sources
        map - Map of XSL params
        Since:
        0.16
      • XSLDocument

        public XSLDocument​(String src,
                           Sources srcs,
                           Map<String,​Object> map,
                           String base)
        Public ctor, from XSL as a string.
        Parameters:
        src - XML document body
        srcs - Sources
        map - Map of XSL params
        base - SystemId/Base
        Since:
        0.20
        Suppressed Checkstyle violations:
        ParameterNumberCheck (5 lines)
    • Method Detail

      • with

        public XSL with​(Sources src)
        Description copied from interface: XSL
        With this sources.
        Specified by:
        with in interface XSL
        Parameters:
        src - Sources
        Returns:
        New XSL document
      • with

        public XSL with​(String name,
                        Object value)
        Description copied from interface: XSL
        With this parameter.
        Specified by:
        with in interface XSL
        Parameters:
        name - Name of XSL parameter
        value - Value of XSL parameter
        Returns:
        New XSL document
      • make

        public static XSL make​(InputStream stream)
        Make an instance of XSL stylesheet without I/O exceptions.

        This factory method is useful when you need to create an instance of XSL stylesheet as a static final variable. In this case you can't catch an exception but this method can help, for example:

         class Foo {
           private static final XSL STYLESHEET = XSLDocument.make(
             Foo.class.getResourceAsStream("my-stylesheet.xsl")
           );
         }
        Parameters:
        stream - Input stream
        Returns:
        XSL stylesheet
      • make

        public static XSL make​(URL url)
        Make an instance of XSL stylesheet without I/O exceptions.
        Parameters:
        url - URL with content
        Returns:
        XSL stylesheet
        Since:
        0.7.4
        See Also:
        make(InputStream)
      • transform

        public XML transform​(XML xml)
        Description copied from interface: XSL
        Transform XML to another one.
        Specified by:
        transform in interface XSL
        Parameters:
        xml - Source XML document
        Returns:
        Result document
      • applyTo

        public String applyTo​(XML xml)
        Description copied from interface: XSL
        Transform XML into text.
        Specified by:
        applyTo in interface XSL
        Parameters:
        xml - Source XML document
        Returns:
        Result text