Here you can find the source of toXMLInputSource(StreamSource in)
public static final XMLInputSource toXMLInputSource(StreamSource in)
//package com.java2s; /*//from w w w. j a v a 2s .co m * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import javax.xml.transform.stream.StreamSource; import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; public class Main { /** * Creates a proper {@link XMLInputSource} from a {@link StreamSource}. * * @return always return non-null valid object. */ public static final XMLInputSource toXMLInputSource(StreamSource in) { if (in.getReader() != null) return new XMLInputSource(in.getPublicId(), in.getSystemId(), in.getSystemId(), in.getReader(), null); if (in.getInputStream() != null) return new XMLInputSource(in.getPublicId(), in.getSystemId(), in.getSystemId(), in.getInputStream(), null); return new XMLInputSource(in.getPublicId(), in.getSystemId(), in.getSystemId()); } }