Class StyleSheetProvider


  • public class StyleSheetProvider
    extends Object
    A StyleSheetProvider assembles a XSL-stylesheet from one master XSL-file and a various number of other XSL-files to include. The insertion-point for the additional files must be set via setInsertBefore(String).
    Author:
    Matthias Müller
    • Constructor Detail

      • StyleSheetProvider

        public StyleSheetProvider()
    • Method Detail

      • setMasterSource

        public void setMasterSource​(InputStream masterXsl,
                                    String templateRoot)
        Sets the master XSL source for this StyleSheetProvider.
        Parameters:
        masterXsl - the master source
        templateRoot - the absolute path to the directory where template resides
      • addStyleSheet

        public void addStyleSheet​(InputStream styleSheet,
                                  String reference)
        Adds an additional XSL-source to be included into the master source
        Parameters:
        styleSheet - the additional source
        reference - the name of the source, used for XSL-comments and logging
      • getStyleSheet

        public byte[] getStyleSheet​(boolean deleteIncludes,
                                    OutputStream additionalOut)
        Assembles the complete XSL stylesheet by including the sources added via addStyleSheet(InputStream, String) and embedding them into the master source at the defined insertion-point.
        Parameters:
        deleteIncludes - If set to true, all <xsl:include>s eventually contained in the master source will be removed before assembling the stylesheet. If set to false, the <xsl:include>s are being kept and processed.
        additionalOut - an additional OutputStream to write the stylesheet to (optional)
        Returns:
        the complete stylesheet as an array of bytes
      • setDocumentBuilderFactory

        public void setDocumentBuilderFactory​(DocumentBuilderFactory documentBuilderFactory)
      • setTransformerFactory

        public void setTransformerFactory​(TransformerFactory transformerFactory)
      • setDocumentBuilder

        public void setDocumentBuilder​(DocumentBuilder documentBuilder)
      • setTransformer

        public void setTransformer​(Transformer transformer)
      • getInsertBefore

        public String getInsertBefore()
        Returns the actual insertion-point
        Returns:
        the actual insertion-point
      • setInsertBefore

        public void setInsertBefore​(String insertBefore)
        Sets the insertion point for the master source, at which additional stylesheets should be embedded.
        Parameters:
        insertBefore - the insertion-point to use
      • getName

        public String getName()
      • setName

        public void setName​(String name)
      • isValid

        public boolean isValid()
        Checks if this StyleSheetProvider is valid, i.e. the master source is not null.
        Returns:
        true the master source is not null, false otherwise