Creates an xml pipe from an {@link InputStream}.
16812
public static Pipe newPipe(InputStream in) throws IOException
    {
        try
        {
            return newPipe(DEFAULT_INPUT_FACTORY.createXMLStreamReader(in, XML_ENCODING));
        }
        catch (XMLStreamException e)
        {
            throw new XmlInputException(e);
        }
    }
377369
public XMLResource xml(URI anUri, AbstractContent requestContent) throws IOException {
		return doPOSTOrPUT(anUri, requestContent, createXMLResource());
	}
95807
function XmlStream(stream, encoding) {
  events.EventEmitter.call(this);
  this._stream = stream;
  this._fa = new FiniteAutomata();
  this._lastState = 0;
  this._startState = {};
  this._finalStates = {};
  this._emitData = false;
  this._bufferLevel = 0;
  this._preserveLevel = 0;
  this._preserveWhitespace = 0;
  this._preserveAll = false;
  this._collect = false;
  this._parser = undefined;

  // Set input stream encoding and create an iconv instance,
  // if conversion is required. Default working encoding is UTF-8,
  // so iconv is used when input is anything else, but UTF-8.
  this._encoding = encoding || null;
  this._encoder = makeEncoder(this._encoding);

  var scope = this;

  // Start parsing.
  process.nextTick(function () {
    parse.call(scope);
  });
}
278708
public static InputStream documentToPrettyInputStream(Node document) throws Exception {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        Source xmlSource = new DOMSource(document);
        Result outputTarget = new StreamResult(outputStream);
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty(OutputKeys.METHOD, "xml");
        transformer.transform(xmlSource, outputTarget);

        InputStream is = new ByteArrayInputStream(outputStream.toByteArray());
        return is;
    }
1009883
def fromxml(node):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = parsexmlstring(node)
        if node.tag == 'provenance': #pylint: disable=too-many-nested-blocks
            if node.attrib['type'] == 'clam':
                serviceid = node.attrib['id']
                servicename = node.attrib['name']
                serviceurl = node.attrib['url']
                timestamp = node.attrib['timestamp']
                outputtemplate = node.attrib['outputtemplate']
                outputtemplatelabel = node.attrib['outputtemplatelabel']
                inputfiles = []
                parameters = []
                for subnode in node:
                    if subnode.tag == 'inputfile':
                        filename = node.attrib['name']
                        metadata = None
                        for subsubnode in subnode:
                            if subsubnode.tag == 'CLAMMetaData':
                                metadata = CLAMMetaData.fromxml(subsubnode)
                                break
                        inputfiles.append( (filename, metadata) )
                    elif subnode.tag == 'parameters':
                        for subsubnode in subnode:
                            if subsubnode.tag in vars(clam.common.parameters):
                                parameters.append(vars(clam.common.parameters)[subsubnode.tag].fromxml(subsubnode))
                            else:
                                raise Exception("Expected parameter class '" + subsubnode.tag + "', but not defined!")
                return CLAMProvenanceData(serviceid,servicename,serviceurl,outputtemplate, outputtemplatelabel, inputfiles, parameters, timestamp)
            else:
                raise NotImplementedError
1020844
public static InputStream fromFile(String filepath) throws FileNotFoundException {
		if(Strings.isValid(filepath)) {
			return fromFile(new File(filepath));
		}
		return null;
	}
393935
public static Document parseXmlStream(final Reader xmlStream) {

        // Build a DOM model of the provided xmlFileStream.
        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);

        try {
            return factory.newDocumentBuilder().parse(new InputSource(xmlStream));
        } catch (Exception e) {
            throw new IllegalArgumentException("Could not acquire DOM Document", e);
        }
    }
476682
public void parseStream (InputStream stream)
        throws IOException
    {
        try {
            // read the XML input stream and construct the scene object
            _chars = new StringBuilder();
            XMLUtil.parse(this, stream);

        } catch (ParserConfigurationException pce) {
            throw (IOException) new IOException().initCause(pce);

        } catch (SAXException saxe) {
            throw (IOException) new IOException().initCause(saxe);
        }
    }
909185
@SuppressWarnings("unchecked")
    public <T> T fromXml(String xml) {
        try {
            StringReader reader = new StringReader(xml);
            return (T) createUnmarshaller().unmarshal(reader);
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
1120803
public Document toXml(InputStream json) throws IOException, NotImplemented {
        JsonReader reader = null;
        try {
            reader = new JsonReader(new InputStreamReader(json, "utf-8"));
            return parse(reader);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException(e);
        } finally {
            if (reader != null) reader.close();
            if (json != null) json.close();
        }
    }
629383
public final void parse(InputStream stream) throws IOException {

        // all XML exceptions are wrapped by IOExceptions
        try {

            // setup a namespace aware SAXParserFactory
            SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
            saxParserFactory.setNamespaceAware(true);

            // parse the input stream
            SAXParser parser = saxParserFactory.newSAXParser();
            parser.parse(stream, this);

        } catch (ParserConfigurationException e) {
            throw new IOException(e);
        } catch (SAXException e) {
            throw new IOException(e);
        }

    }
93764
private static InputStream createInputStream(GraphicFactory graphicFactory, String relativePathPrefix, String src) throws IOException {
        InputStream inputStream;
        if (src.startsWith(PREFIX_ASSETS)) {
            src = src.substring(PREFIX_ASSETS.length());
            inputStream = inputStreamFromAssets(graphicFactory, relativePathPrefix, src);
        } else if (src.startsWith(PREFIX_FILE)) {
            src = src.substring(PREFIX_FILE.length());
            inputStream = inputStreamFromFile(relativePathPrefix, src);
        } else if (src.startsWith(PREFIX_JAR) || src.startsWith(PREFIX_JAR_V1)) {
            if (src.startsWith(PREFIX_JAR)) {
                src = src.substring(PREFIX_JAR.length());
            } else if (src.startsWith(PREFIX_JAR_V1)) {
                src = src.substring(PREFIX_JAR_V1.length());
            }
            inputStream = inputStreamFromJar(relativePathPrefix, src);
        } else {
            inputStream = inputStreamFromFile(relativePathPrefix, src);

            if (inputStream == null) {
                inputStream = inputStreamFromAssets(graphicFactory, relativePathPrefix, src);
            }

            if (inputStream == null) {
                inputStream = inputStreamFromJar(relativePathPrefix, src);
            }
        }

        // Fallback to internal resources
        if (inputStream == null) {
            inputStream = inputStreamFromJar("/assets/", src);
            if (inputStream != null) {
                LOGGER.info("internal resource: " + src);
            }
        }

        if (inputStream != null) {
            return inputStream;
        }

        LOGGER.severe("invalid resource: " + src);
        throw new FileNotFoundException("invalid resource: " + src);
    }
1020674
protected Document parseContent(final InputStream in) throws Throwable {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    DocumentBuilder builder = factory.newDocumentBuilder();

    return builder.parse(new InputSource(new InputStreamReader(in)));
  }
39873
public InputStreamReader getFileStream(File file, String encoding)
			throws NoSuchPathException, UnmarshalException{
		try {
			return new InputStreamReader(new FileInputStream(file), encoding);
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		} catch (UnsupportedEncodingException e){
			throw new UnmarshalException(e);
		}
	}
335631
public void parse(InputStream xmlInput) throws XMLStreamException {
    InputStream input = isoControlCharsAwareParser ? new ISOControlCharAwareInputStream(xmlInput) : xmlInput;
    parse(inf.rootElementCursor(input));
  }
34162
public static Layout parseStream(InputStream stream) {
        try (InputStream is = stream) {
            return parseDocument(XMLUtil.parseXMLFromStream(is));
        } catch (Exception e) {
            throw MiscUtil.toUnchecked(e);
        }
    }
1363410
public static String convertStreamToString(InputStream in) throws Exception {

        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuilder stringbuilder = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
          stringbuilder.append(line + "\n");
        }
        in.close();
        return stringbuilder.toString();
      }