javax.xml.transform

Class Transformer


  • public abstract class Transformer
    extends Object
    An instance of this abstract class can transform a source tree into a result tree.

    An instance of this class can be obtained with the TransformerFactory.newTransformer method. This instance may then be used to process XML from a variety of sources and write the transformation output to a variety of sinks.

    An object of this class may not be used in multiple threads running concurrently. Different Transformers may be used concurrently by different threads.

    A Transformer may be used multiple times. Parameters and output properties are preserved across transformations.

    • Constructor Detail

      • Transformer

        protected Transformer()
        Default constructor is protected on purpose.
    • Method Detail

      • transform

        public abstract void transform(Source xmlSource,
                     Result outputTarget)
                                throws TransformerException

        Transform the XML Source to a Result. Specific transformation behavior is determined by the settings of the TransformerFactory in effect when the Transformer was instantiated and any modifications made to the Transformer instance.

        An empty Source is represented as an empty document as constructed by DocumentBuilder.newDocument(). The result of transforming an empty Source depends on the transformation behavior; it is not always an empty Result.

        Parameters:
        xmlSource - The XML input to transform.
        outputTarget - The Result of transforming the xmlSource.
        Throws:
        TransformerException - If an unrecoverable error occurs during the course of the transformation.
      • setParameter

        public abstract void setParameter(String name,
                        Object value)
        Add a parameter for the transformation.

        Pass a qualified name as a two-part string, the namespace URI enclosed in curly braces ({}), followed by the local name. If the name has a null URL, the String only contain the local name. An application can safely check for a non-null URI by testing to see if the first character of the name is a '{' character.

        For example, if a URI and local name were obtained from an element defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that no prefix is used.

        Parameters:
        name - The name of the parameter, which may begin with a namespace URI in curly braces ({}).
        value - The value object. This can be any valid Java object. It is up to the processor to provide the proper object coersion or to simply pass the object on for use in an extension.
        Throws:
        NullPointerException - If value is null.
      • getParameter

        public abstract Object getParameter(String name)
        Get a parameter that was explicitly set with setParameter.

        This method does not return a default parameter value, which cannot be determined until the node context is evaluated during the transformation process.

        Parameters:
        name - of Object to get
        Returns:
        A parameter that has been set with setParameter.
      • clearParameters

        public abstract void clearParameters()
        Clear all parameters set with setParameter.
      • setURIResolver

        public abstract void setURIResolver(URIResolver resolver)
        Set an object that will be used to resolve URIs used in document().

        If the resolver argument is null, the URIResolver value will be cleared and the transformer will no longer have a resolver.

        Parameters:
        resolver - An object that implements the URIResolver interface, or null.
      • getURIResolver

        public abstract URIResolver getURIResolver()
        Get an object that will be used to resolve URIs used in document().
        Returns:
        An object that implements the URIResolver interface, or null.
      • setOutputProperties

        public abstract void setOutputProperties(Properties oformat)
        Set the output properties for the transformation. These properties will override properties set in the Templates with xsl:output.

        If argument to this function is null, any properties previously set are removed, and the value will revert to the value defined in the templates object.

        Pass a qualified property key name as a two-part string, the namespace URI enclosed in curly braces ({}), followed by the local name. If the name has a null URL, the String only contain the local name. An application can safely check for a non-null URI by testing to see if the first character of the name is a '{' character.

        For example, if a URI and local name were obtained from an element defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that no prefix is used.

        An IllegalArgumentException is thrown if any of the argument keys are not recognized and are not namespace qualified.
        Parameters:
        oformat - A set of output properties that will be used to override any of the same properties in affect for the transformation.
        Throws:
        IllegalArgumentException - When keys are not recognized and are not namespace qualified.
        See Also:
        OutputKeys, Properties
      • setOutputProperty

        public abstract void setOutputProperty(String name,
                             String value)
                                        throws IllegalArgumentException
        Set an output property that will be in effect for the transformation.

        Pass a qualified property name as a two-part string, the namespace URI enclosed in curly braces ({}), followed by the local name. If the name has a null URL, the String only contain the local name. An application can safely check for a non-null URI by testing to see if the first character of the name is a '{' character.

        For example, if a URI and local name were obtained from an element defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo". Note that no prefix is used.

        The Properties object that was passed to setOutputProperties(java.util.Properties) won't be effected by calling this method.

        Parameters:
        name - A non-null String that specifies an output property name, which may be namespace qualified.
        value - The non-null string value of the output property.
        Throws:
        IllegalArgumentException - If the property is not supported, and is not qualified with a namespace.
        See Also:
        OutputKeys
      • getOutputProperty

        public abstract String getOutputProperty(String name)
                                          throws IllegalArgumentException

        Get an output property that is in effect for the transformer.

        If a property has been set using setOutputProperty(java.lang.String, java.lang.String), that value will be returned. Otherwise, if a property is explicitly specified in the stylesheet, that value will be returned. If the value of the property has been defaulted, that is, if no value has been set explicitly either with setOutputProperty(java.lang.String, java.lang.String) or in the stylesheet, the result may vary depending on implementation and input stylesheet.

        Parameters:
        name - A non-null String that specifies an output property name, which may be namespace qualified.
        Returns:
        The string value of the output property, or null if no property was found.
        Throws:
        IllegalArgumentException - If the property is not supported.
        See Also:
        OutputKeys
      • getErrorListener

        public abstract ErrorListener getErrorListener()
        Get the error event handler in effect for the transformation. Implementations must provide a default error listener.
        Returns:
        The current error handler, which should never be null.

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/xml/transform/Transformer.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut