org.appng.xml.transformation

## Class StyleSheetProvider

- java.lang.Object
- - org.appng.xml.transformation.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 Summary

    Constructors
    Constructor and Description
    `StyleSheetProvider()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addStyleSheet(InputStream styleSheet, String reference)` Adds an additional XSL-source to be included into the master source
    `void` | `cleanup()` Closes all the previously used `InputStream`s.
    `protected void` | `close(InputStream is)`
    `DocumentBuilder` | `getDocumentBuilder()`
    `DocumentBuilderFactory` | `getDocumentBuilderFactory()`
    `String` | `getId()` Returns a unique ID for this `StyleSheetProvider`, which is build from the sorted set of reference names of the additional stylesheets added via `addStyleSheet(InputStream, String)`.
    `String` | `getInsertBefore()` Returns the actual insertion-point
    `String` | `getName()`
    `byte[]` | `getStyleSheet(boolean deleteIncludes)`
    `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.
    `Transformer` | `getTransformer()`
    `TransformerFactory` | `getTransformerFactory()`
    `void` | `init()` Initializes this `StyleSheetProvider` by setting the `DocumentBuilder` and `Transformer` to use.
    `boolean` | `isValid()` Checks if this `StyleSheetProvider` is valid, i.e.
    `void` | `setDocumentBuilder(DocumentBuilder documentBuilder)`
    `void` | `setDocumentBuilderFactory(DocumentBuilderFactory documentBuilderFactory)`
    `void` | `setInsertBefore(String insertBefore)` Sets the insertion point for the master source, at which additional stylesheets should be embedded.
    `void` | `setMasterSource(InputStream masterXsl, String templateRoot)` Sets the master XSL source for this `StyleSheetProvider`.
    `void` | `setName(String name)`
    `void` | `setTransformer(Transformer transformer)`
    `void` | `setTransformerFactory(TransformerFactory transformerFactory)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StyleSheetProvider

          public StyleSheetProvider()

  - ### Method Detail

    - #### init

          public void init()

      Initializes this `StyleSheetProvider` by setting the `DocumentBuilder` and `Transformer` to use.

    - #### 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)

      See Also:
        `getStyleSheet(boolean, OutputStream)`

    - #### 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

    - #### close

          protected void close(InputStream is)

    - #### getDocumentBuilderFactory

          public DocumentBuilderFactory getDocumentBuilderFactory()

    - #### setDocumentBuilderFactory

          public void setDocumentBuilderFactory(DocumentBuilderFactory documentBuilderFactory)

    - #### getTransformerFactory

          public TransformerFactory getTransformerFactory()

    - #### setTransformerFactory

          public void setTransformerFactory(TransformerFactory transformerFactory)

    - #### getDocumentBuilder

          public DocumentBuilder getDocumentBuilder()

    - #### setDocumentBuilder

          public void setDocumentBuilder(DocumentBuilder documentBuilder)

    - #### getTransformer

          public Transformer getTransformer()

    - #### 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)

    - #### getId

          public String getId()

      Returns a unique ID for this `StyleSheetProvider`, which is build from the sorted set of reference names of the additional stylesheets added via `addStyleSheet(InputStream, String)`.
      Returns:
        the ID
      See Also:
        `addStyleSheet(InputStream, String)`

    - #### cleanup

          public void cleanup()

      Closes all the previously used `InputStream`s.
      See Also:
        `setMasterSource(InputStream, String)`, `addStyleSheet(InputStream, String)`

    - #### 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

Copyright © 2011–2023 aiticon GmbH. All rights reserved.