1 package net.sf.saxon.event; 2 3 import net.sf.saxon.trans.XPathException; 4 import net.sf.saxon.om.NamePool; 5 import net.sf.saxon.om.NamespaceConstant; 6 7 import java.util.HashSet ; 8 9 10 16 17 public class XHTMLEmitter extends XMLEmitter { 18 19 22 23 HashSet emptyTags = new HashSet (31); 24 25 private static String [] emptyTagNames = { 26 "area", "base", "basefont", "br", "col", "frame", "hr", "img", "input", "isindex", "link", "meta", "param" 27 }; 28 29 36 37 protected void openDocument() throws XPathException { 38 NamePool pool = getPipelineConfiguration().getConfiguration().getNamePool(); 39 for (int i=0; i<emptyTagNames.length; i++) { 40 emptyTags.add(new Integer ( 41 pool.allocate("", NamespaceConstant.XHTML, emptyTagNames[i]) & NamePool.FP_MASK)); 42 } 43 super.openDocument(); 44 } 45 46 49 50 protected String emptyElementTagCloser(String displayName, int nameCode) { 51 if (emptyTags.contains(new Integer (nameCode & NamePool.FP_MASK))) { 52 return " />"; 53 } else { 54 return "></" + displayName + '>'; 55 } 56 } 57 58 } 59 60 | Popular Tags |