Java XML Transform Usage toXMLInputSource(StreamSource in)

Here you can find the source of toXMLInputSource(StreamSource in)

Description

Creates a proper XMLInputSource from a StreamSource .

License

Open Source License

Return

always return non-null valid object.

Declaration

public static final XMLInputSource toXMLInputSource(StreamSource in) 

Method Source Code


//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());
    }
}

Related

  1. readDoc(Reader in)
  2. renderElement(Element theElem)
  3. safeToXml(Element element)
  4. streamSource(File file)
  5. toNonValidatingSAXSource(InputStream in)
  6. unwrapException(Throwable t)
  7. verifySignature(Element element, PublicKey validatingKey)
  8. writeElementContent(XMLInputFactory inputFactory, XMLStreamWriter writer, Element element)
  9. writeXhtml(InputStream inputStream, Writer writer, Templates... templates)