Split xml tag writer from content writer interface object hierachy.

This commit is contained in:
Willem Cazander 2014-03-14 19:03:56 +01:00
parent 80ade0b3f4
commit 82d966b849
17 changed files with 294 additions and 212 deletions

View file

@ -58,9 +58,6 @@ import org.xml.sax.helpers.AttributesImpl;
*/
public class EldXsdWriterElement {
static public final String SCHEMA_URI = XMLConstants.XML_SCHEMA_NS_URI;
private PropertyConfig propertyConfig;
protected X4OLanguage language = null;
protected ContentWriterXsd xsdWriter = null;
@ -155,7 +152,7 @@ public class EldXsdWriterElement {
return;
}
//xsdWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
xsdWriter.comment(COMMENT_SEPERATOR);
xsdWriter.printComment(COMMENT_SEPERATOR);
String byValue = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
if (!byValue.endsWith(".")) {
@ -175,8 +172,8 @@ public class EldXsdWriterElement {
}
b.append(COMMENT_TEXT);
b.append(" ");
xsdWriter.comment(b.toString());
xsdWriter.comment(COMMENT_SEPERATOR);
xsdWriter.printComment(b.toString());
xsdWriter.printComment(COMMENT_SEPERATOR);
}
private void prologWriteProvider(ElementNamespace ns) throws SAXException {
@ -202,7 +199,7 @@ public class EldXsdWriterElement {
b.append(String.format(formatLine,"Created on:",new Date()));
b.append("\n");
xsdWriter.comment(b.toString());
xsdWriter.printComment(b.toString());
}
public void startSchema(ElementNamespace ns) throws SAXException {
@ -212,10 +209,9 @@ public class EldXsdWriterElement {
prologWriteGenerator();
prologWriteProvider(ns);
xsdWriter.startPrefixMapping("", SCHEMA_URI);
for (String uri:namespaces.keySet()) {
String prefix = namespaces.get(uri);
xsdWriter.startPrefixMapping(prefix, uri);
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
}
AttributesImpl atts = new AttributesImpl();
@ -223,7 +219,7 @@ public class EldXsdWriterElement {
atts.addAttribute ("", "elementFormDefault", "", "", "qualified");
atts.addAttribute ("", "attributeFormDefault", "", "", "unqualified");
atts.addAttribute ("", "targetNamespace", "", "", ns.getUri());
xsdWriter.startElement (SCHEMA_URI, "schema", "", atts);
xsdWriter.printTagStart(Tag.schema, atts);
for (String uri:namespaces.keySet()) {
if (ns.getUri().equals(uri)) {
@ -237,8 +233,8 @@ public class EldXsdWriterElement {
}
public void endSchema() throws SAXException {
xsdWriter.endElement (SCHEMA_URI, "schema" , "");
xsdWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
xsdWriter.printTagEnd(Tag.schema);
xsdWriter.getContentWriterWrapped().ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
xsdWriter.endDocument();
}
@ -256,13 +252,13 @@ public class EldXsdWriterElement {
AttributesImpl atts = new AttributesImpl();
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
atts.addAttribute ("", "name", "", "", ec.getId());
xsdWriter.startElement (SCHEMA_URI, "element", "", atts); // Only in the language root xsd there is an element.
xsdWriter.printTagStart(Tag.element, atts);// Only in the language root xsd there is an element.
atts = new AttributesImpl();
xsdWriter.startElement (SCHEMA_URI, "complexType", "", atts);
xsdWriter.printTagStart(Tag.complexType, atts);
} else {
atts.addAttribute ("", "name", "", "", ec.getId()+"Type");
xsdWriter.startElement (SCHEMA_URI, "complexType", "", atts);
xsdWriter.printTagStart(Tag.complexType, atts);
}
if (ec.getSchemaContentBase()!=null) {
@ -271,27 +267,27 @@ public class EldXsdWriterElement {
if (ec.getSchemaContentMixed()!=null && ec.getSchemaContentMixed()) {
atts.addAttribute ("", "mixed", "", "", "true");
}
xsdWriter.startElement (SCHEMA_URI, "complexContent", "", atts);
xsdWriter.printTagStart(Tag.complexContent, atts);
} else {
xsdWriter.startElement (SCHEMA_URI, "simpleContent", "", atts);
xsdWriter.printTagStart(Tag.simpleContent, atts);
}
atts = new AttributesImpl();
atts.addAttribute ("", "base", "", "", ec.getSchemaContentBase());
xsdWriter.startElement (SCHEMA_URI, "extension", "", atts);
xsdWriter.printTagStart(Tag.extension, atts);
}
if (ec.getSchemaContentBase()==null) {
atts = new AttributesImpl();
atts.addAttribute ("", "minOccurs", "", "", "0"); // TODO: make unordered elements
atts.addAttribute ("", "maxOccurs", "", "", "unbounded");
xsdWriter.startElement (SCHEMA_URI, "choice", "", atts);
xsdWriter.printTagStart(Tag.choise, atts);
for (X4OLanguageModule mod:language.getLanguageModules()) {
for (ElementNamespace ns:mod.getElementNamespaces()) {
writeElementClassNamespaces(ec,nsWrite,ns);
}
}
xsdWriter.endElement(SCHEMA_URI, "choice", "");
xsdWriter.printTagEnd(Tag.choise);
}
List<String> attrNames = new ArrayList<String>(30);
@ -316,7 +312,7 @@ public class EldXsdWriterElement {
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
// oke, reverse this if and rm whitespace.
xsdWriter.ignorableWhitespace(' ');
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
} else {
@ -354,27 +350,25 @@ public class EldXsdWriterElement {
} else {
atts.addAttribute ("", "type", "", "", "string");
}
xsdWriter.startElement (SCHEMA_URI, "attribute", "", atts);
xsdWriter.endElement(SCHEMA_URI, "attribute", "");
xsdWriter.printTagStartEnd(Tag.attribute, atts);
}
}
} else {
atts = new AttributesImpl();
xsdWriter.startElement (SCHEMA_URI, "anyAttribute", "", atts);
xsdWriter.endElement(SCHEMA_URI, "anyAttribute", "");
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
}
}
if (ec.getSchemaContentBase()!=null) {
xsdWriter.endElement(SCHEMA_URI, "extension", "");
xsdWriter.printTagEnd(Tag.extension);
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
xsdWriter.endElement(SCHEMA_URI, "complexContent", "");
xsdWriter.printTagEnd(Tag.complexContent);
} else {
xsdWriter.endElement(SCHEMA_URI, "simpleContent", "");
xsdWriter.printTagEnd(Tag.simpleContent);
}
}
xsdWriter.endElement(SCHEMA_URI, "complexType", "");
xsdWriter.printTagEnd(Tag.complexType);
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
xsdWriter.endElement(SCHEMA_URI, "element", "");
xsdWriter.printTagEnd(Tag.element);
}
}
@ -426,8 +420,7 @@ public class EldXsdWriterElement {
atts.addAttribute ("", "name", "", "", refElement);
atts.addAttribute ("", "type", "", "", prefix+":"+refElement+"Type");
}
xsdWriter.startElement (SCHEMA_URI, "element", "", atts);
xsdWriter.endElement (SCHEMA_URI, "element", "");
xsdWriter.printTagStartEnd(Tag.element,atts);
}
}
}
@ -440,9 +433,9 @@ public class EldXsdWriterElement {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", ec.getId());
atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type");
xsdWriter.startElement(SCHEMA_URI, "element", "", atts);
xsdWriter.printTagStart(Tag.element,atts);
writeElementMetaBase(ec);
xsdWriter.endElement(SCHEMA_URI, "element", "");
xsdWriter.printTagEnd(Tag.element);
}
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws SAXException {

View file

@ -61,7 +61,6 @@ import org.xml.sax.helpers.AttributesImpl;
*/
public class X4ODebugWriter {
static public final String DEBUG_URI = "http://language.x4o.org/xml/ns/debug-output";
protected ContentWriter contentWriter = null;
@ -74,6 +73,12 @@ public class X4ODebugWriter {
return contentWriter;
}
enum X4ODebugTag {
execute222Phase,
testTasg,
stekel
}
public X4OPhaseListener createDebugX4OPhaseListener() {
return new DebugX4OPhaseListener();
}
@ -94,7 +99,7 @@ public class X4ODebugWriter {
if (elementLanguage!=null) {
atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName());
}
contentWriter.startElement (DEBUG_URI, "executePhase", "", atts);
contentWriter.startElement (DEBUG_URI, X4ODebugTag.execute222Phase.name(), "", atts);
} catch (SAXException e) {
throw new X4OPhaseException(phase,e);
}
@ -110,7 +115,7 @@ public class X4ODebugWriter {
contentWriter.startElement (DEBUG_URI, "executePhaseDone", "", atts);
contentWriter.endElement (DEBUG_URI, "executePhaseDone" , "");
contentWriter.endElement (DEBUG_URI, "executePhase" , "");
contentWriter.endElement (DEBUG_URI, X4ODebugTag.execute222Phase.name() , "");
} catch (SAXException e) {
throw new X4OPhaseException(phase,e);
}

View file

@ -55,7 +55,6 @@ import org.xml.sax.helpers.AttributesImpl;
*/
public class AbstractContentWriterHandler implements ContentHandler {
protected final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
private final PropertyConfig propertyConfig;
private Writer out = null;
private int indent = 0;
@ -65,7 +64,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
private boolean printReturn = false;
private String lastElement = null;
private Stack<String> elements = null;
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_WRITER_XML;
public final static PropertyConfig DEFAULT_PROPERTY_CONFIG;
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX+"output/encoding";
@ -90,7 +89,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
new PropertyConfigItem(OUTPUT_ENCODING, String.class, XMLConstants.XML_DEFAULT_ENCODING),
new PropertyConfigItem(OUTPUT_CHAR_TAB, String.class, XMLConstants.CHAR_TAB+""),
new PropertyConfigItem(OUTPUT_CHAR_NEWLINE, String.class, XMLConstants.CHAR_NEWLINE+""),
new PropertyConfigItem(OUTPUT_CHAR_NULL, String.class, "null"), // TODO: or "" ?? (or skip)
new PropertyConfigItem(OUTPUT_CHAR_NULL, String.class, "NULL"),
new PropertyConfigItem(OUTPUT_COMMENT_ENABLE, Boolean.class, true),
new PropertyConfigItem(OUTPUT_COMMENT_AUTO_SPACE, Boolean.class, true),
new PropertyConfigItem(OUTPUT_LINE_BREAK_WIDTH, Integer.class, -1),

View file

@ -46,13 +46,38 @@ public interface ContentWriter extends ContentHandler,LexicalHandler {
*/
void startElementEnd(String uri, String localName, String name,Attributes atts) throws SAXException;
/**
* Writes a String as xml comment.
* @param text The text to have embedded as comment in xml.
* @throws SAXException On error.
*/
void comment(String text) throws SAXException;
/**
* Writes a whitespace String to the body.
* @param text The String of whitespace to write.
* @throws SAXException On error.
*/
void ignorableWhitespace(String text) throws SAXException;
/**
* Writes a whitespace character to the body.
* @param c The character to write.
* @throws SAXException On error;
*/
void ignorableWhitespace(char c) throws SAXException;
/**
* Writes a String in the body.
* @param text The text to write.
* @throws SAXException On error.
*/
void characters(String text) throws SAXException;
/**
* Writes a single character in the body body.
* @param c The character to write.
* @throws SAXException On error.
*/
void characters(char c) throws SAXException;
}

View file

@ -31,19 +31,27 @@ import org.xml.sax.SAXException;
* @author Willem Cazander
* @version 1.0 May 3, 2013
*/
public interface ContentWriterTag<T extends Enum<?>> extends ContentWriter {
public interface ContentWriterTag<TAG extends Enum<?>> {
String getTagNamespaceUri();
void printTagStartEnd(T tag) throws SAXException;
void startDocument() throws SAXException;
void printTagStartEnd(T tag,Attributes atts) throws SAXException;
void endDocument() throws SAXException;
void printTagStart(T tag) throws SAXException;
void printTagStartEnd(TAG tag) throws SAXException;
void printTagStart(T tag,Attributes atts) throws SAXException;
void printTagStartEnd(TAG tag,Attributes atts) throws SAXException;
void printTagEnd(T tag) throws SAXException;
void printTagStart(TAG tag) throws SAXException;
void printTagCharacters(T tag,String text) throws SAXException;
void printTagStart(TAG tag,Attributes atts) throws SAXException;
void printTagEnd(TAG tag) throws SAXException;
void printTagCharacters(TAG tag,String text) throws SAXException;
void printCharacters(String text) throws SAXException;
void printComment(String text) throws SAXException;
}

View file

@ -0,0 +1,121 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.xml.io.sax.ext;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
* ContentWriterXmlTag can write enum based xml events.
*
* @author Willem Cazander
* @version 1.0 May 3, 2013
*/
public class ContentWriterTagWrapper<TAG extends Enum<?>,TAG_WRITER extends ContentWriter> implements ContentWriterTag<TAG> {
private final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
private final TAG_WRITER contentWriter;
private final String tagNamespaceUri;
private final String tagNamespacePrefix;
public ContentWriterTagWrapper(TAG_WRITER contentWriter,String tagNamespaceUri,String tagNamespacePrefix) {
if (contentWriter==null) {
throw new NullPointerException("Can't create wrapper on null ContentWriter");
}
if (tagNamespaceUri==null) {
throw new NullPointerException("Can't create wrapper with null tagNamespaceUri");
}
if (tagNamespacePrefix==null) {
throw new NullPointerException("Can't create wrapper with null tagNamespacePrefix");
}
this.contentWriter=contentWriter;
this.tagNamespaceUri=tagNamespaceUri;
this.tagNamespacePrefix=tagNamespacePrefix;
}
public TAG_WRITER getContentWriterWrapped() {
return contentWriter;
}
public String getTagNamespaceUri() {
return tagNamespaceUri;
}
public void startDocument() throws SAXException {
contentWriter.startDocument();
contentWriter.startPrefixMapping(tagNamespacePrefix, getTagNamespaceUri());
}
public void endDocument() throws SAXException {
contentWriter.endDocument();
}
public void printTagStartEnd(TAG tag,Attributes atts) throws SAXException {
printTagStart(tag,atts);
printTagEnd(tag);
}
public void printTagStartEnd(TAG tag) throws SAXException {
printTagStart(tag);
printTagEnd(tag);
}
public void printTagStart(TAG tag) throws SAXException {
printTagStart(tag,EMPTY_ATTRIBUTES);
}
public void printTagStart(TAG tag,Attributes atts) throws SAXException {
contentWriter.startElement (getTagNamespaceUri(), toTagString(tag), "", atts);
}
public void printTagEnd(TAG tag) throws SAXException {
contentWriter.endElement (getTagNamespaceUri(),toTagString(tag) , "");
}
private String toTagString(TAG tag) {
String result = tag.name();
if (result.startsWith("_"))
{
result = result.substring(1); // remove _
}
return result;
}
public void printTagCharacters(TAG tag,String text) throws SAXException {
printTagStart(tag);
if (text==null) {
text = " ";
}
printCharacters(text);
printTagEnd(tag);
}
public void printCharacters(String text) throws SAXException {
contentWriter.characters(text);
}
public void printComment(String text) throws SAXException {
contentWriter.comment(text);
}
}

View file

@ -1,76 +0,0 @@
/*
* Copyright (c) 2004-2013, Willem Cazander
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.x4o.xml.io.sax.ext;
import java.io.Writer;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* ContentWriterXml writes SAX content handler events to XML.
*
* @author Willem Cazander
* @version 1.0 May 3, 2013
*/
public class ContentWriterXmlTag<T extends Enum<?>> extends ContentWriterXml implements ContentWriterTag<T> {
public ContentWriterXmlTag(Writer out,String encoding) {
super(out, encoding);
}
public String getTagNamespaceUri() {
return "";
}
public void printTagStartEnd(T tag,Attributes atts) throws SAXException {
printTagStart(tag,atts);
printTagEnd(tag);
}
public void printTagStartEnd(T tag) throws SAXException {
printTagStart(tag);
printTagEnd(tag);
}
public void printTagStart(T tag) throws SAXException {
printTagStart(tag,EMPTY_ATTRIBUTES);
}
public void printTagStart(T tag,Attributes atts) throws SAXException {
startElement (getTagNamespaceUri(), tag.name(), "", atts);
}
public void printTagEnd(T tag) throws SAXException {
endElement (getTagNamespaceUri(),tag.name() , "");
}
public void printTagCharacters(T tag,String text) throws SAXException {
printTagStart(tag);
if (text==null) {
text = " ";
}
characters(text);
printTagEnd(tag);
}
}

View file

@ -34,22 +34,21 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Willem Cazander
* @version 1.0 May 3, 2013
*/
public class ContentWriterXsd extends ContentWriterXmlTag<ContentWriterXsd.Tag> {
public class ContentWriterXsd extends ContentWriterTagWrapper<ContentWriterXsd.Tag,ContentWriterXml> {
public ContentWriterXsd(Writer out,String encoding) {
super(out,encoding);
super(new ContentWriterXml(out, encoding),XMLConstants.XML_SCHEMA_NS_URI, XMLConstants.NULL_NS_URI);
}
public String getTagNamespaceUri() {
return XMLConstants.XML_SCHEMA_NS_URI;
public PropertyConfig getPropertyConfig() {
return getContentWriterWrapped().getPropertyConfig();
}
public void printXsdImport(String namespace,String schemaLocation) throws SAXException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "namespace", "", "", namespace);
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
startElement (getTagNamespaceUri(), "import", "", atts);
endElement (getTagNamespaceUri(), "import", ""); // import is keyword
printTagStartEnd(Tag._import, atts);
}
public void printXsdDocumentation(String description) throws SAXException {
@ -60,8 +59,8 @@ public class ContentWriterXsd extends ContentWriterXmlTag<ContentWriterXsd.Tag>
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "xml:lang", "", "", "en");
printTagStart(Tag.documentation,atts);
characters(description);
printTagEnd(Tag.documentation);
printCharacters(description);
printTagEnd(Tag.documentation);
printTagEnd(Tag.annotation);
}
@ -70,16 +69,15 @@ public class ContentWriterXsd extends ContentWriterXmlTag<ContentWriterXsd.Tag>
atts.addAttribute ("", "name", "", "", name);
atts.addAttribute ("", "type", "", "", type);
printTagStart(Tag.attribute,atts);
printXsdDocumentation(description);
printXsdDocumentation(description);
printTagEnd(Tag.attribute);
}
public enum Tag {
all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
choise,complexContent,complexType,documentation,element,extension,
field,group,/*_import,*/include,key,keyref,list,notation,
field,group,_import,include,key,keyref,list,notation,
redefine,restriction,schema,selector,sequence,
simpleContent,simpleType,unoin,unique
}
}

View file

@ -131,14 +131,14 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
writer.printTagCharacters(Tag.dt,"All Element Parents:");
writer.printTagStart(Tag.dd);
if (parents.isEmpty()) {
writer.characters("No parent.");
writer.printCharacters("No parent.");
}
for (int i=0;i<parents.size();i++) {
TreeNode n = parents.get(i);
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
if (i<parents.size()-1) {
writer.characters(",&nbsp;");
writer.printCharacters(",&nbsp;");
}
}
writer.printTagEnd(Tag.dd);
@ -149,14 +149,14 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
writer.printTagCharacters(Tag.dt,"All Element Childeren:");
writer.printTagStart(Tag.dd);
if (childs.isEmpty()) {
writer.characters("No childeren.");
writer.printCharacters("No childeren.");
}
for (int i=0;i<childs.size();i++) {
TreeNode n = childs.get(i);
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
if (i<childs.size()-1) {
writer.characters(",&nbsp;");
writer.printCharacters(",&nbsp;");
}
}
writer.printTagEnd(Tag.dd);

View file

@ -61,8 +61,8 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
writer.printTagStart(Tag.ul);
writer.printTagStart(Tag.li,"",null,"circle");
writer.characters(node.namespace.getId());
writer.characters(":");
writer.printCharacters(node.namespace.getId());
writer.printCharacters(":");
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
writer.printTagEnd(Tag.li);

View file

@ -149,7 +149,7 @@ public abstract class AbstractApiDocWriter {
writer.docTableRowLastStart(n, null);
String c = printValue(doc,writer,value);
if (c!=null) {
writer.characters(c);
writer.printCharacters(c);
}
writer.docTableRowLastEnd();
}

View file

@ -45,12 +45,12 @@ public class ApiDocContentWriter extends ContentWriterHtml {
}
public void docCommentGenerated() throws SAXException {
comment("Generated by "+ApiDocContentWriter.class.getSimpleName()+" on "+new Date());
printComment("Generated by "+ApiDocContentWriter.class.getSimpleName()+" on "+new Date());
}
public void docHtmlStart(String title,List<String> keywords,String pathPrefix) throws SAXException {
printDocType(DocType.HTML_4_TRANSITIONAL);
comment("NewPage");
printComment("NewPage");
printHtmlStart("en");
// ====== Write head
@ -80,7 +80,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
public void docHtmlEnd(String copyright,String statsJS) throws SAXException {
printTagStart(Tag.p,ApiDocContentCss.legalCopy);
printTagStart(Tag.small);
characters(copyright);
printCharacters(copyright);
printTagEnd(Tag.small);
printTagEnd(Tag.p);
if (statsJS!=null) {
@ -97,7 +97,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
String[] lines = about.split("\n");
for (int i=0;i<lines.length;i++) {
String line = lines[i];
characters(line);
printCharacters(line);
if (i<lines.length-1) {
printTagStartEnd(Tag.br);
}
@ -114,7 +114,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
printTagEnd(Tag.div);
printTagStart(Tag.p);
characters("See:&nbsp;");
printCharacters("See:&nbsp;");
printHref("#package_description", "Description");
printTagEnd(Tag.p);
printTagEnd(Tag.div);
@ -124,15 +124,15 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printHrefNamed("package_description");
printTagCharacters(Tag.h2, title);
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
characters(description);
printCharacters(description);
}
public void docPageClassStart(String title,String subTitle,Tag titleTag) throws SAXException {
comment("======== START OF CLASS DATA ========");
printComment("======== START OF CLASS DATA ========");
printTagStart(Tag.div,ApiDocContentCss.header);
if (subTitle!=null) {
printTagStart(Tag.div,ApiDocContentCss.subTitle);
characters(subTitle);
printCharacters(subTitle);
printTagEnd(Tag.div);
}
printTagCharacters(titleTag, title, "title");
@ -140,7 +140,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
}
public void docPageClassEnd() throws SAXException {
comment("======== END OF CLASS DATA ========");
printComment("======== END OF CLASS DATA ========");
}
public void docPageContentStart() throws SAXException {
@ -153,7 +153,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
public void docPageBlockStart(String title,String namedLink,String comment) throws SAXException {
if (comment!=null) {
comment(comment);
printComment(comment);
}
docPageBlockStart();
printHrefNamed(namedLink);
@ -186,11 +186,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
if (tableDescription!=null) {
atts.addAttribute ("", "summary", "", "", tableDescription);
}
startElement("", "table", "", atts);
printTagStart(Tag.table,atts);
printTagStart(Tag.caption);
printTagStart(Tag.span);characters(tableTitle);printTagEnd(Tag.span);
printTagStart(Tag.span,ApiDocContentCss.tabEnd);characters("&nbsp;");printTagEnd(Tag.span);
printTagStart(Tag.span);printCharacters(tableTitle);printTagEnd(Tag.span);
printTagStart(Tag.span,ApiDocContentCss.tabEnd);printCharacters("&nbsp;");printTagEnd(Tag.span);
printTagEnd(Tag.caption);
}
@ -208,9 +208,9 @@ public class ApiDocContentWriter extends ContentWriterHtml {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
}
atts.addAttribute ("", "scope", "", "", "col");
startElement("", "th", "", atts);
characters(titleFirst);
endElement("", "th", "");
printTagStart(Tag.th,atts);
printCharacters(titleFirst);
printTagEnd(Tag.th);
if (titleLast==null) {
printTagEnd(Tag.tr);
return;
@ -218,8 +218,8 @@ public class ApiDocContentWriter extends ContentWriterHtml {
atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
atts.addAttribute ("", "scope", "", "", "col");
startElement("", "th", "", atts);
characters(titleLast);
printTagStart(Tag.th,atts);
printCharacters(titleLast);
printTagEnd(Tag.th);
printTagEnd(Tag.tr);
}
@ -261,7 +261,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagStart(Tag.code);
}
if (dataFirstHref==null) {
characters(dataFirst);
printCharacters(dataFirst);
} else {
printHref(dataFirstHref, dataFirst, dataFirst);
}
@ -282,12 +282,12 @@ public class ApiDocContentWriter extends ContentWriterHtml {
printTagStart(Tag.td,ApiDocContentCss.colLast);
if (dataLastCode) {
printTagStart(Tag.code);characters(dataLast);printTagEnd(Tag.code);
printTagStart(Tag.code);printCharacters(dataLast);printTagEnd(Tag.code);
} else {
printTagStart(Tag.div,ApiDocContentCss.block);characters(dataLast);printTagEnd(Tag.div);
printTagStart(Tag.div,ApiDocContentCss.block);printCharacters(dataLast);printTagEnd(Tag.div);
}
if (dataBlock!=null) {
printTagStart(Tag.div,ApiDocContentCss.block);characters(dataBlock);printTagEnd(Tag.div);
printTagStart(Tag.div,ApiDocContentCss.block);printCharacters(dataBlock);printTagEnd(Tag.div);
}
printTagEnd(Tag.td);

View file

@ -54,6 +54,7 @@ import org.x4o.xml.eld.doc.api.dom.ApiDocNodeWriter;
import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
import org.x4o.xml.io.XMLConstants;
import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.x4o.xml.lang.X4OLanguageClassLoader;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@ -179,7 +180,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
writer.docPageClassEnd();
docNavBar(writer,false,concept,node);
writer.docHtmlEnd(doc.getDocCopyright(),doc.getDocStatsJS());
writer.closeWriterSafe();
writer.getContentWriterWrapped().closeWriterSafe();
// Writer other files
writeAllFrameNavNode(node);
@ -209,7 +210,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
}
private void defaultWriteNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
event.getWriter().characters(event.getEventObject().getDescription());
event.getWriter().printCharacters(event.getEventObject().getDescription());
}
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws SAXException {
@ -418,7 +419,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
String nodeTitle = node.getId();
if (nodes.hasNext()==false) {
writer.printTagStart(Tag.li);
writer.characters(nodeTitle);
writer.printCharacters(nodeTitle);
writer.printTagEnd(Tag.li);
} else {
writer.printTagStart(Tag.li);
@ -455,8 +456,8 @@ public class ApiDocWriter extends AbstractApiDocWriter {
try {
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
ApiDocContentWriter result = new ApiDocContentWriter(out,encoding);
result.getPropertyConfig().setProperty(ApiDocContentWriter.OUTPUT_CHAR_NEWLINE, XMLConstants.CHAR_NEWLINE+"");
result.getPropertyConfig().setProperty(ApiDocContentWriter.OUTPUT_CHAR_TAB, " ");
result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_NEWLINE, XMLConstants.CHAR_NEWLINE+"");
result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_TAB, " ");
return result;
} catch (UnsupportedEncodingException e) {
throw new SAXException(e);
@ -631,13 +632,14 @@ public class ApiDocWriter extends AbstractApiDocWriter {
"\tif (targetPage != \"\" && targetPage != \"undefined\")\n"+
"\t\t { top."+ApiDocContentCss.frameContent.name()+".location = top.targetPage; }\n"+
"}\n";
public void writeIndex() throws SAXException {
File outputFile = createOutputPathFile(basePath,"index.html");
ApiDocContentWriter writer = createContentWriter(outputFile);
try {
writer.printDocType(DocType.HTML_4_FRAMESET);
writer.comment("NewPage");
writer.printComment("NewPage");
writer.printHtmlStart("en");
writeHeader(writer,"",doc.getName());
writer.printScriptInline(FRAME_JS);
@ -682,16 +684,16 @@ public class ApiDocWriter extends AbstractApiDocWriter {
writer.printScriptNoDiv();
writer.printTagCharacters(Tag.h2, "Frame Alert");
writer.printTagStart(Tag.p);
writer.characters("This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to ");
writer.printCharacters("This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to ");
writer.printHref(rootLink, "Non-frame version");
writer.characters(".");
writer.printCharacters(".");
writer.printTagEnd(Tag.p);
writer.printTagEnd(Tag.noframes);
writer.printTagEnd(Tag.frameset);
writer.printHtmlEnd();
} finally {
writer.closeWriterSafe();
writer.getContentWriterWrapped().closeWriterSafe();
}
}
@ -717,7 +719,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
String conceptParentPlural = conceptParent.getName()+"s";
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
writer.comment("NewPage");
writer.printComment("NewPage");
writer.printHtmlStart("en");
writeHeader(writer,"","All "+conceptPlural+" of "+doc.getName());
writer.printTagStart(Tag.body);
@ -748,7 +750,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
writer.printTagEnd(Tag.body);
writer.printHtmlEnd();
} finally {
writer.closeWriterSafe();
writer.getContentWriterWrapped().closeWriterSafe();
}
}
@ -790,7 +792,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
//String conceptParentPlural = conceptParent.getName()+"s";
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
writer.comment("NewPage");
writer.printComment("NewPage");
writer.printHtmlStart("en");
writeHeader(writer,pathPrefix,"All "+conceptPlural+" of "+doc.getName());
writer.printTagStart(Tag.body);
@ -859,7 +861,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
writer.printTagEnd(Tag.body);
writer.printHtmlEnd();
} finally {
writer.closeWriterSafe();
writer.getContentWriterWrapped().closeWriterSafe();
}
}
@ -887,7 +889,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
docNavBar(writer,false,null,null);
writer.docHtmlEnd(doc.getDocCopyright(),doc.getDocStatsJS());
} finally {
writer.closeWriterSafe();
writer.getContentWriterWrapped().closeWriterSafe();
}
}
@ -957,7 +959,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
}
File outputPath = new File(buf.toString());
if (outputPath.exists()==false) {
//System.out.println("Creating path: "+outputPath);
//System.out.println("Creating path: "+outputPath); // TODO add logger
outputPath.mkdirs();
}
buf.append(File.separatorChar);
@ -981,22 +983,22 @@ public class ApiDocWriter extends AbstractApiDocWriter {
barCssDiv = "bottomNav";
barId = "navbar_bottom";
}
writer.comment("========= START OF "+barComment+" NAVBAR =======");
writer.printComment("========= START OF "+barComment+" NAVBAR =======");
writer.printTagStart(Tag.div,barCssDiv);
writer.printHrefNamed(barId); // Print named link navigation
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "href", "", "", "#skip-"+barId);
atts.addAttribute ("", "title", "", "", "Skip navigation links");
writer.startElement("", "a", "", atts);
writer.comment(" ");
writer.endElement("", "a", "");
writer.printTagStart(Tag.a, atts);
writer.printComment(" ");
writer.printTagEnd(Tag.a);
writer.printHrefNamed(barId+"_firstrow");
atts = new AttributesImpl();// Print nav bar
atts.addAttribute ("", "class", "", "", "navList");
atts.addAttribute ("", "title", "", "", "Navigation");
writer.startElement("", "ul", "", atts);
writer.printTagStart(Tag.ul, atts);
for (ApiDocNavLink navLink:conf.getNavLinks()) {
String selectedCss = null;
@ -1015,7 +1017,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
docNavBarListItemHref(writer,pathPrefix+href,navTitle,navLink.getText(),selectedCss,null,null);
}
}
writer.endElement("", "ul", "");
writer.printTagEnd(Tag.ul);
writer.docNavBarAbout(doc.getDocAbout());
@ -1086,7 +1088,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
writer.printTagStart(Tag.div); // don't print empty div
}
writer.printTagStart(Tag.ul,ApiDocContentCss.subNavList);
writer.printTagStart(Tag.li);writer.characters(groupName+":&nbsp;");writer.printTagEnd(Tag.li);
writer.printTagStart(Tag.li);writer.printCharacters(groupName+":&nbsp;");writer.printTagEnd(Tag.li);
for (int l=0;l<links.size();l++) {
ApiDocNavLink link = links.get(l);
writer.printTagStart(Tag.li);
@ -1097,9 +1099,9 @@ public class ApiDocWriter extends AbstractApiDocWriter {
if (link.getHref()!=null) {
docNavBarListItemHref(writer,link.getHref(), link.getTitle(), link.getText(), null, null, tab);
} else {
writer.characters(link.getText());
writer.printCharacters(link.getText());
if (tab!=null) {
writer.characters(tab);
writer.printCharacters(tab);
}
}
writer.printTagEnd(Tag.li);
@ -1113,13 +1115,13 @@ public class ApiDocWriter extends AbstractApiDocWriter {
}
writer.printHrefNamed("skip-"+barId);
writer.printTagEnd(Tag.div);
writer.comment("========= END OF "+barComment+" NAVBAR =======");
writer.printComment("========= END OF "+barComment+" NAVBAR =======");
}
private void docNavBarListItemHref(ApiDocContentWriter writer,String href,String title,String text,String cssClass,String spanCss,String linkSpace) throws SAXException {
writer.printTagStart(Tag.li,cssClass);
writer.printHref(href,title,text,spanCss);
writer.characters(linkSpace);
writer.printCharacters(linkSpace);
writer.printTagEnd(Tag.li);
}
}

View file

@ -50,7 +50,7 @@ public class DefaultPageWriterHelp implements ApiDocPageWriter {
writer.printTagStart(Tag.div,"header");
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
writer.printTagStart(Tag.div,"subTitle");
writer.characters("This ApiDoc document has pages corresponding to the items in the navigation bar, described as follows.");
writer.printCharacters("This ApiDoc document has pages corresponding to the items in the navigation bar, described as follows.");
writer.printTagEnd(Tag.div);
writer.printTagEnd(Tag.div);
@ -59,14 +59,14 @@ public class DefaultPageWriterHelp implements ApiDocPageWriter {
for (ApiDocConcept concept:doc.getConcepts()) {
writer.printTagCharacters(Tag.h2, concept.getName());
writer.printTagStart(Tag.p);
writer.characters(concept.getDescriptionHelp());
writer.printCharacters(concept.getDescriptionHelp());
writer.printTagEnd(Tag.p);
writer.docPageBlockNext();
}
for (ApiDocPage docPage:doc.getDocPages()) {
writer.printTagCharacters(Tag.h2, docPage.getName());
writer.printTagStart(Tag.p);
writer.characters(docPage.getDescription());
writer.printCharacters(docPage.getDescription());
writer.printTagEnd(Tag.p);
writer.docPageBlockNext();
}

View file

@ -47,12 +47,12 @@ public class DefaultPageWriterIndexAll implements ApiDocPageWriter {
writer.docPageContentStart();
for (char i='A';i<='Z';i++) {
writer.printHref("#_"+i+"_", ""+i);
writer.characters("&nbsp;");
writer.printCharacters("&nbsp;");
}
for (char i='A';i<='Z';i++) {
writer.printHrefNamed("_"+i+"_");
writer.printTagCharacters(Tag.h2, ""+i);
writer.characters("TODO");
writer.printCharacters("TODO");
}
writer.docPageContentEnd();
}

View file

@ -80,8 +80,8 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
writer.printTagStart(Tag.ul);
writer.printTagStart(Tag.li,"",null,"circle");
if (node.getParent()!=null) {
writer.characters(node.getParent().getId());
writer.characters(":");
writer.printCharacters(node.getParent().getId());
writer.printCharacters(":");
}
writer.printHref(href, node.getName(), node.getName(), "strong");
writer.printTagEnd(Tag.li);

View file

@ -25,7 +25,10 @@ package org.x4o.html;
import java.io.Writer;
import java.util.Calendar;
import org.x4o.xml.io.sax.ext.ContentWriterXmlTag;
import org.x4o.xml.io.XMLConstants;
import org.x4o.xml.io.sax.ext.ContentWriterTagWrapper;
import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.x4o.xml.io.sax.ext.PropertyConfig;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@ -35,14 +38,18 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Willem Cazander
* @version 1.0 Apr 30, 2013
*/
public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag> {
public class ContentWriterHtml extends ContentWriterTagWrapper<ContentWriterHtml.Tag,ContentWriterXml> {
public ContentWriterHtml(Writer out,String encoding) {
super(out,encoding);
super(new ContentWriterXml(out, encoding),"", XMLConstants.NULL_NS_URI);
}
public PropertyConfig getPropertyConfig() {
return getContentWriterWrapped().getPropertyConfig();
}
public void printDocType(DocType doc) throws SAXException {
startDTD(doc.getName(), doc.getPublicId(), doc.getSystemId());
getContentWriterWrapped().startDTD(doc.getName(), doc.getPublicId(), doc.getSystemId());
}
public void printHtmlStart(String language) throws SAXException {
@ -70,15 +77,15 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "http-equiv", "", "", "Content-Type");
atts.addAttribute ("", "content", "", "", "text/html");
atts.addAttribute ("", "charset", "", "", getPropertyConfig().getPropertyString(OUTPUT_ENCODING));
startElementEnd("", "meta", "", atts);
atts.addAttribute ("", "charset", "", "", getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING));
printTagStartEnd(Tag.meta, atts);
}
public void printHeadMeta(String name,String content) throws SAXException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", name);
atts.addAttribute ("", "content", "", "", content);
startElementEnd("", "meta", "", atts);
printTagStartEnd(Tag.meta, atts);
}
public void printHeadLinkCss(String cssUrl) throws SAXException {
@ -87,14 +94,14 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
atts.addAttribute ("", "type", "", "", "text/css");
atts.addAttribute ("", "title", "", "", "Style");
atts.addAttribute ("", "href", "", "", cssUrl);
startElementEnd("", "link", "", atts);
printTagStartEnd(Tag.link, atts);
}
public void printScriptInline(String script) throws SAXException {
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "type", "", "", "text/javascript");
printTagStart(Tag.script,atts);
comment(script);
printComment(script);
printTagEnd(Tag.script);
}
@ -107,7 +114,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
text = "JavaScript is disabled on your browser.";
}
printTagStart(Tag.noscript);
printTagStart(Tag.div);characters(text);printTagEnd(Tag.div);
printTagStart(Tag.div);printCharacters(text);printTagEnd(Tag.div);
printTagEnd(Tag.noscript);
}
@ -115,7 +122,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "name", "", "", name);
printTagStart(Tag.a,atts);
comment(" ");
printComment(" ");
printTagEnd(Tag.a);
}
@ -124,7 +131,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
atts.addAttribute ("", "href", "", "", href);
atts.addAttribute ("", "target", "", "", target);
printTagStart(Tag.a,atts);
characters(title);
printCharacters(title);
printTagEnd(Tag.a);
}
@ -150,7 +157,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
}
printTagStart(Tag.span,atts);
}
characters(text);
printCharacters(text);
if (spanClass!=null) {
printTagEnd(Tag.span);
}
@ -166,7 +173,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
if (text==null) {
text = " ";
}
characters(text);
printCharacters(text);
printTagEnd(tag);
}