Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.process
Class TransformXML<T>

    java.lang.Object
      edu.stanford.nlp.process.TransformXML<T>

Type Parameters:
  `T` - The type of the output of the Function (from String to T)

    public class TransformXML<T>

extends Object

Reads XML from an input file or stream and writes XML to an output file or stream, while transforming text appearing inside specified XML tags by applying a specified ``Function``. See TransformXMLApplications for examples. Implementation note: This is done using SAX2.

Author:
  Bill MacCartney, Anna Rafferty (refactoring, making SAXInterface easy to extend elsewhere)

Nested Class Summary
`static class` | `TransformXML.SAXInterface<T>`

Constructor Summary
`TransformXML()`

Method Summary
`void` | `transformXML(String[] tags, Function<String,T> fn, File in)` Read XML from the specified file and write XML to stdout, while transforming text appearing inside the specified XML tags by applying the specified ``Function``.
`void` | `transformXML(String[] tags, Function<String,T> fn, File in, File out)` Read XML from the specified file and write XML to specified file, while transforming text appearing inside the specified XML tags by applying the specified ``Function``.
`void` | `transformXML(String[] tags, Function<String,T> fn, InputStream in)` Read XML from input stream and write XML to stdout, while transforming text appearing inside the specified XML tags by applying the specified ``Function``.
`void` | `transformXML(String[] tags, Function<String,T> fn, InputStream in, OutputStream out)` Read XML from input stream and write XML to output stream, while transforming text appearing inside the specified XML tags by applying the specified ``Function``.
`void` | `transformXML(String[] tags, Function<String,T> fn, InputStream in, Writer w)` Read XML from input stream and write XML to output stream, while transforming text appearing inside the specified XML tags by applying the specified ``Function``.
`void` | `transformXML(String[] tags, Function<String,T> fn, InputStream in, Writer w, TransformXML.SAXInterface<T> handler)` Read XML from input stream and write XML to output stream, while transforming text appearing inside the specified XML tags by applying the specified ``Function``.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TransformXML

    public TransformXML()

Method Detail

### transformXML

    public void transformXML(String[] tags,
                             Function<String,T> fn,
                             File in)

  Read XML from the specified file and write XML to stdout, while transforming text appearing inside the specified XML tags by applying the specified ``Function``. Note that the `Function` you supply must be prepared to accept `String`s as input; if your `Function` doesn't handle `String`s, you need to write a wrapper for it that does.

  Parameters:
    `tags` - an array of `String`s, each an XML tag within which the transformation should be applied
    `fn` - the ``Function`` to apply
    `in` - the `File` to read from

### transformXML

    public void transformXML(String[] tags,
                             Function<String,T> fn,
                             File in,
                             File out)

  Read XML from the specified file and write XML to specified file, while transforming text appearing inside the specified XML tags by applying the specified ``Function``. Note that the `Function` you supply must be prepared to accept `String`s as input; if your `Function` doesn't handle `String`s, you need to write a wrapper for it that does.

  Parameters:
    `tags` - an array of `String`s, each an XML tag within which the transformation should be applied
    `fn` - the ``Function`` to apply
    `in` - the `File` to read from
    `out` - the `File` to write to

### transformXML

    public void transformXML(String[] tags,
                             Function<String,T> fn,
                             InputStream in)

  Read XML from input stream and write XML to stdout, while transforming text appearing inside the specified XML tags by applying the specified ``Function``. Note that the `Function` you supply must be prepared to accept `String`s as input; if your `Function` doesn't handle `String`s, you need to write a wrapper for it that does.

  Parameters:
    `tags` - an array of `String`s, each an XML tag within which the transformation should be applied
    `fn` - the ``Function`` to apply
    `in` - the `InputStream` to read from

### transformXML

    public void transformXML(String[] tags,
                             Function<String,T> fn,
                             InputStream in,
                             OutputStream out)

  Read XML from input stream and write XML to output stream, while transforming text appearing inside the specified XML tags by applying the specified ``Function``. Note that the `Function` you supply must be prepared to accept `String`s as input; if your `Function` doesn't handle `String`s, you need to write a wrapper for it that does.

  Parameters:
    `tags` - an array of `String`s, each an XML tag within which the transformation should be applied
    `fn` - the ``Function`` to apply
    `in` - the `InputStream` to read from
    `out` - the `OutputStream` to write to

### transformXML

    public void transformXML(String[] tags,
                             Function<String,T> fn,
                             InputStream in,
                             Writer w)

  Read XML from input stream and write XML to output stream, while transforming text appearing inside the specified XML tags by applying the specified ``Function``. Note that the `Function` you supply must be prepared to accept `String`s as input; if your `Function` doesn't handle `String`s, you need to write a wrapper for it that does.

  Implementation notes: The InputStream is assumed to already be buffered if useful, and we need a stream, so that the XML decoder can determine the correct character encoding of the XML file. The output is to a Writer, and the provided Writer should again be buffered if desirable. Internally, this Writer is wrapped as a PrintWriter.

  Parameters:
    `tags` - an array of `String`s, each an XML entity within which the transformation should be applied
    `fn` - the ``Function`` to apply
    `in` - the `InputStream` to read from
    `w` - the `Writer` to write to

### transformXML

    public void transformXML(String[] tags,
                             Function<String,T> fn,
                             InputStream in,
                             Writer w,
                             TransformXML.SAXInterface<T> handler)

  Read XML from input stream and write XML to output stream, while transforming text appearing inside the specified XML tags by applying the specified ``Function``. Note that the `Function` you supply must be prepared to accept `String`s as input; if your `Function` doesn't handle `String`s, you need to write a wrapper for it that does.

  Implementation notes: The InputStream is assumed to already be buffered if useful, and we need a stream, so that the XML decoder can determine the correct character encoding of the XML file. The output is to a Writer, and the provided Writer should again be buffered if desirable. Internally, this Writer is wrapped as a PrintWriter.

  Parameters:
    `tags` - an array of `String`s, each an XML entity within which the transformation should be applied
    `fn` - the ``Function`` to apply
    `in` - the `InputStream` to read from
    `w` - the `Writer` to write to
    `handler` - the sax handler you would like to use (default is SaxInterface, defined in this class, but you may define your own handler)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group