Java XML Transform Usage getNormalizedReader(Reader reader)

Here you can find the source of getNormalizedReader(Reader reader)

Description

get Normalized Reader

License

Apache License

Declaration

private static Reader getNormalizedReader(Reader reader) throws IOException, TransformerException 

Method Source Code

//package com.java2s;
/**/*from  ww w . j a  va2 s  .  c  o  m*/
                                     * Licensed to the Apache Software Foundation (ASF) under one
                                     * or more contributor license agreements. See the NOTICE file
                                     * distributed with this work for additional information
                                     * regarding copyright ownership. The ASF licenses this file
                                     * to you under the Apache License, Version 2.0 (the
                                     * "License"); you may not use this file except in compliance
                                     * with the License. You may obtain a copy of the License at
                                     * <p>
                                     * http://www.apache.org/licenses/LICENSE-2.0
                                     * <p>
                                     * Unless required by applicable law or agreed to in writing,
                                     * software distributed under the License is distributed on an
                                     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
                                     * KIND, either express or implied. See the License for the
                                     * specific language governing permissions and limitations
                                     * under the License.
                                     */

import javax.xml.transform.TransformerException;

import java.io.*;

public class Main {
    private static Reader getNormalizedReader(Reader reader) throws IOException, TransformerException {
        return reader;
        /*
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(
        new StreamSource(new StringReader(
                "<xsl:stylesheet version=\"1.0\"" +
                        "   xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" +
                        "<xsl:output method=\"xml\" omit-xml-declaration=\"yes\"/>" +
                        "  <xsl:strip-space elements=\"*\"/>" +
                        "  <xsl:template match=\"@*|node()\">" +
                        "   <xsl:copy>" +
                        "    <xsl:apply-templates select=\"@*|node()\"/>" +
                        "   </xsl:copy>" +
                        "  </xsl:template>" +
                        "</xsl:stylesheet>"
        ))
        );
        Source source = new StreamSource(reader);
        StringWriter sw = new StringWriter();
        StreamResult result = new StreamResult(sw);
        transformer.transform(source, result);
        String res = sw.toString();
        logger.fine("string after xslt:" + res);
        return new StringReader(sw.toString());
        */
    }
}

Related

  1. getCalendarAsXsdDateTime(Calendar c)
  2. getContentText(Element element)
  3. getDate(final XMLGregorianCalendar xmlGregorianCalendar)
  4. getEmptyXmlFile(File xmlFile)
  5. getImplementationObject()
  6. getSaxSource(File newFile, SAXParserFactory spf)
  7. getSchema(InputStream... inputs)
  8. getSourceFromEndpointReference(EndpointReference epr)
  9. getStreamSources(File[] stylesheets)