All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.saxon.lib.RawResult Maven / Gradle / Ivy

There is a newer version: 12.5
Show newest version
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2022 Saxonica Limited
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package net.sf.saxon.lib;

import net.sf.saxon.om.Item;
import net.sf.saxon.om.Sequence;
import net.sf.saxon.value.SequenceExtent;

import javax.xml.transform.Result;
import java.util.ArrayList;
import java.util.List;


/**
 * This class is an implementation of the JAXP Result interface. It can be used to indicate that
 * the output of a transformation (either the principal result, or a secondary result) should be
 * delivered in "raw" form, that is, without building a tree (equivalently, without performing
 * "sequence normalization"). Once output has been written to a RawResult, it is available to
 * the caller in the form of a {@link Sequence}.
 */

public class RawResult implements Result {

    private String systemId;
    private final List content = new ArrayList();

    /**
     * Set the system identifier for this Result.
     * 

If the Result is not to be written to a file, the system identifier is optional. * The application may still want to provide one, however, for use in error messages * and warnings, or to resolve relative output identifiers.

* * @param systemId The system identifier as a URI string. */ @Override public void setSystemId(String systemId) { this.systemId = systemId; } /** * Get the system identifier that was set with setSystemId. * * @return The system identifier that was set with setSystemId, * or null if setSystemId was not called. */ @Override public String getSystemId() { return systemId; } /** * Method intended for internal use to append an item to the result */ public void append(Item item) { content.add(item); } /** * On completion, get the sequence that has been written to this result object */ public Sequence getResultSequence() { return new SequenceExtent.Of<>(content); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy