Java XML Transform write_plain_content_tag(String name, String content, AttributesImpl atts, TransformerHandler hd)

Here you can find the source of write_plain_content_tag(String name, String content, AttributesImpl atts, TransformerHandler hd)

Description

Writes a normal tag containing a text only.

License

Open Source License

Parameter

Parameter Description
name The name of the tag.
content The context of the tag.
atts An attributesImpl instance, a structure needed for performance.
hd The transformer handler.

Exception

Parameter Description
SAXException an exception

Declaration

public static void write_plain_content_tag(String name, String content, AttributesImpl atts,
        TransformerHandler hd) throws SAXException 

Method Source Code

//package com.java2s;
/*/*from  www  . j a  v a2  s . c  o m*/
 * utils-java8
 * Copyright (C) 2014 Raffaele Ragni
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.xml.transform.sax.TransformerHandler;

import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

public class Main {
    /**
     * Writes a normal tag containing a text only.
     *
     * @param name The name of the tag.
     * @param content The context of the tag.
     * @param atts An attributesImpl instance, a structure needed for
     * performance.
     * @param hd The transformer handler.
     *
     * @throws SAXException
     */
    public static void write_plain_content_tag(String name, String content, AttributesImpl atts,
            TransformerHandler hd) throws SAXException {
        if (name != null && content != null) {
            atts.clear();
            hd.startElement("", "", name, atts);
            hd.characters(content.toCharArray(), 0, content.length());
            hd.endElement("", "", name);
        }
    }
}

Related

  1. transformToString(Source xmlSource, Source xslSource)
  2. transformViaXslt(String xml, String xslFile)
  3. transformXml(final StreamSource xslSrc, final StreamSource docSrc, final Map params, final URIResolver resolver)
  4. transformXML(Reader xml, Reader xsl)
  5. transformXmlByXslt(StreamSource source, URI xslFile)
  6. writeByTransformer(Node node, Writer writer, int indent)