📄 xhtmlwriter.java
字号:
/* * LingPipe v. 3.5 * Copyright (C) 2003-2008 Alias-i * * This program is licensed under the Alias-i Royalty Free License * Version 1 WITHOUT ANY WARRANTY, without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Alias-i * Royalty Free License Version 1 for more details. * * You should have received a copy of the Alias-i Royalty Free License * Version 1 along with this program; if not, visit * http://alias-i.com/lingpipe/licenses/lingpipe-license-1.txt or contact * Alias-i, Inc. at 181 North 11th Street, Suite 401, Brooklyn, NY 11211, * +1 (718) 290-9170. */package com.aliasi.xml;import java.io.OutputStream;import java.io.UnsupportedEncodingException;import org.xml.sax.Attributes;import org.xml.sax.SAXException;/** * An <code>XHtmlWriter</code> provides constants and convenience * methods for generating XHTML 1.0 output. A constant is provided * for each legal XHTML element tag and each XHTML attribute. There * are six methods for each element. The first five methods allow * from zero to four pairs of attributes and values to be supplied as * strings. The sixth method accepts an arbitrary SAX {@link * Attributes} object to supply the attributes. * * <p>The parent class <code>SAXWriter</code> is set to * use XHTML mode (see {@link SAXWriter#SAXWriter(OutputStream,String,boolean)}) * output. * * <p><b>Warning:</b> No well-formedness checks are performed * on the output. In particular, elements may not be balanced * leading to invalid XML, or elements may not provide attributes * matching the XHTML 1.0 specification. * * <ul> * <li><a href="http://www.w3.org/TR/xhtml1/">Official XHTML 1.0 Specification</a> (from W3C) * <li><a href="http://validator.w3.org/">W3C XHTML Validator</a></li> * <li><a href="http://www.w3schools.com/xhtml/default.asp">W3 Schools XHTML Tutorial</a></li> (W3 Schools is not affiliated with the W3C -- they're * a <a href="http://www.w3schools.com/about/about_refsnes.asp">small Norwegian outfit</a>)</li> * </ul> * * @author Bob Carpenter * @version 2.3.1 * @since LingPipe2.3.1 */public class XHtmlWriter extends SAXWriter { public XHtmlWriter(OutputStream out, String charsetName) throws UnsupportedEncodingException { super(out,charsetName,XHTML_MODE); setDTDString(XHTML_1_0_STRICT_DTD); } public XHtmlWriter() { super(XHTML_MODE); setDTDString(XHTML_1_0_STRICT_DTD); } /** * Constant for element <code>a</code>. */ public static final String A = "a"; /** * Start an <code>a</code> element with no attributes. * * @throws SAXException If there is an underlying SAX exception. */ public void a() throws SAXException { a(EMPTY_ATTS); } /** * Start an <code>a</code> element with the specified * attributes. * * @param atts Attributes for element. * @throws SAXException If there is an underlying SAX exception. */ public void a(Attributes atts) throws SAXException { startSimpleElement(A,atts); } /** * Start an <code>a</code> element with the specified * attribute and value. * * @param att Qualified name of attribute. * @param val Value of attribute. * @throws SAXException If there is an underlying SAX exception. */ public void a(String att, String val) throws SAXException { startSimpleElement(A,att,val); } /** * Start an <code>a</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @throws SAXException If there is an underlying SAX exception. */ public void a(String att1, String val1, String att2, String val2) throws SAXException { startSimpleElement(A,att1,val1,att2,val2); } /** * Start an <code>a</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @param att3 Qualified name of attribute three. * @param val3 Value of attribute three. * @throws SAXException If there is an underlying SAX exception. */ public void a(String att1, String val1, String att2, String val2, String att3, String val3) throws SAXException { startSimpleElement(A,att1,val1,att2,val2,att3,val3); } /** * Start an <code>a</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @param att3 Qualified name of attribute three. * @param val3 Value of attribute three. * @param att4 Qualified name of attribute four. * @param val4 Value of attribute four. * @throws SAXException If there is an underlying SAX exception. */ public void a(String att1, String val1, String att2, String val2, String att3, String val3, String att4, String val4) throws SAXException { startSimpleElement(A,att1,val1,att2,val2,att3,val3,att4,val4); } /** * Constant for element <code>abbr</code>. */ public static final String ABBR = "abbr"; /** * Start an <code>abbr</code> element with no attributes. * * @throws SAXException If there is an underlying SAX exception. */ public void abbr() throws SAXException { abbr(EMPTY_ATTS); } /** * Start an <code>abbr</code> element with the specified * attributes. * * @param atts Attributes for element. * @throws SAXException If there is an underlying SAX exception. */ public void abbr(Attributes atts) throws SAXException { startSimpleElement(ABBR,atts); } /** * Start an <code>abbr</code> element with the specified * attribute and value. * * @param att Qualified name of attribute. * @param val Value of attribute. * @throws SAXException If there is an underlying SAX exception. */ public void abbr(String att, String val) throws SAXException { startSimpleElement(ABBR,att,val); } /** * Start an <code>abbr</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @throws SAXException If there is an underlying SAX exception. */ public void abbr(String att1, String val1, String att2, String val2) throws SAXException { startSimpleElement(ABBR,att1,val1,att2,val2); } /** * Start an <code>abbr</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @param att3 Qualified name of attribute three. * @param val3 Value of attribute three. * @throws SAXException If there is an underlying SAX exception. */ public void abbr(String att1, String val1, String att2, String val2, String att3, String val3) throws SAXException { startSimpleElement(ABBR,att1,val1,att2,val2,att3,val3); } /** * Start an <code>abbr</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @param att3 Qualified name of attribute three. * @param val3 Value of attribute three. * @param att4 Qualified name of attribute four. * @param val4 Value of attribute four. * @throws SAXException If there is an underlying SAX exception. */ public void abbr(String att1, String val1, String att2, String val2, String att3, String val3, String att4, String val4) throws SAXException { startSimpleElement(ABBR,att1,val1,att2,val2,att3,val3,att4,val4); } /** * Constant for element <code>acronym</code>. */ public static final String ACRONYM = "acronym"; /** * Start an <code>acronym</code> element with no attributes. * * @throws SAXException If there is an underlying SAX exception. */ public void acronym() throws SAXException { acronym(EMPTY_ATTS); } /** * Start an <code>acronym</code> element with the specified * attributes. * * @param atts Attributes for element. * @throws SAXException If there is an underlying SAX exception. */ public void acronym(Attributes atts) throws SAXException { startSimpleElement(ACRONYM,atts); } /** * Start an <code>acronym</code> element with the specified * attribute and value. * * @param att Qualified name of attribute. * @param val Value of attribute. * @throws SAXException If there is an underlying SAX exception. */ public void acronym(String att, String val) throws SAXException { startSimpleElement(ACRONYM,att,val); } /** * Start an <code>acronym</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @throws SAXException If there is an underlying SAX exception. */ public void acronym(String att1, String val1, String att2, String val2) throws SAXException { startSimpleElement(ACRONYM,att1,val1,att2,val2); } /** * Start an <code>acronym</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @param att3 Qualified name of attribute three. * @param val3 Value of attribute three. * @throws SAXException If there is an underlying SAX exception. */ public void acronym(String att1, String val1, String att2, String val2, String att3, String val3) throws SAXException { startSimpleElement(ACRONYM,att1,val1,att2,val2,att3,val3); } /** * Start an <code>acronym</code> element with the specified * attributes and values. * * @param att1 Qualified name of attribute one. * @param val1 Value of attribute one. * @param att2 Qualified name of attribute two. * @param val2 Value of attribute two. * @param att3 Qualified name of attribute three. * @param val3 Value of attribute three. * @param att4 Qualified name of attribute four. * @param val4 Value of attribute four. * @throws SAXException If there is an underlying SAX exception. */ public void acronym(String att1, String val1, String att2, String val2, String att3, String val3, String att4, String val4) throws SAXException { startSimpleElement(ACRONYM,att1,val1,att2,val2,att3,val3,att4,val4); } /** * Constant for element <code>address</code>. */ public static final String ADDRESS = "address"; /** * Start an <code>address</code> element with no attributes. * * @throws SAXException If there is an underlying SAX exception. */ public void address() throws SAXException { address(EMPTY_ATTS); } /** * Start an <code>address</code> element with the specified * attributes. * * @param atts Attributes for element. * @throws SAXException If there is an underlying SAX exception. */ public void address(Attributes atts) throws SAXException { startSimpleElement(ADDRESS,atts); } /** * Start an <code>address</code> element with the specified * attribute and value. * * @param att Qualified name of attribute. * @param val Value of attribute. * @throws SAXException If there is an underlying SAX exception.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -