Split xml tag writer from content writer interface object hierachy.
This commit is contained in:
parent
80ade0b3f4
commit
82d966b849
|
@ -58,9 +58,6 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
*/
|
*/
|
||||||
public class EldXsdWriterElement {
|
public class EldXsdWriterElement {
|
||||||
|
|
||||||
|
|
||||||
static public final String SCHEMA_URI = XMLConstants.XML_SCHEMA_NS_URI;
|
|
||||||
|
|
||||||
private PropertyConfig propertyConfig;
|
private PropertyConfig propertyConfig;
|
||||||
protected X4OLanguage language = null;
|
protected X4OLanguage language = null;
|
||||||
protected ContentWriterXsd xsdWriter = null;
|
protected ContentWriterXsd xsdWriter = null;
|
||||||
|
@ -155,7 +152,7 @@ public class EldXsdWriterElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//xsdWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
//xsdWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
xsdWriter.comment(COMMENT_SEPERATOR);
|
xsdWriter.printComment(COMMENT_SEPERATOR);
|
||||||
|
|
||||||
String byValue = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
String byValue = propertyConfig.getPropertyString(EldXsdWriter.PROLOG_GENERATED_BY, EldXsdWriter.class.getSimpleName());
|
||||||
if (!byValue.endsWith(".")) {
|
if (!byValue.endsWith(".")) {
|
||||||
|
@ -175,8 +172,8 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
b.append(COMMENT_TEXT);
|
b.append(COMMENT_TEXT);
|
||||||
b.append(" ");
|
b.append(" ");
|
||||||
xsdWriter.comment(b.toString());
|
xsdWriter.printComment(b.toString());
|
||||||
xsdWriter.comment(COMMENT_SEPERATOR);
|
xsdWriter.printComment(COMMENT_SEPERATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prologWriteProvider(ElementNamespace ns) throws SAXException {
|
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(String.format(formatLine,"Created on:",new Date()));
|
||||||
b.append("\n");
|
b.append("\n");
|
||||||
|
|
||||||
xsdWriter.comment(b.toString());
|
xsdWriter.printComment(b.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startSchema(ElementNamespace ns) throws SAXException {
|
public void startSchema(ElementNamespace ns) throws SAXException {
|
||||||
|
@ -212,10 +209,9 @@ public class EldXsdWriterElement {
|
||||||
prologWriteGenerator();
|
prologWriteGenerator();
|
||||||
prologWriteProvider(ns);
|
prologWriteProvider(ns);
|
||||||
|
|
||||||
xsdWriter.startPrefixMapping("", SCHEMA_URI);
|
|
||||||
for (String uri:namespaces.keySet()) {
|
for (String uri:namespaces.keySet()) {
|
||||||
String prefix = namespaces.get(uri);
|
String prefix = namespaces.get(uri);
|
||||||
xsdWriter.startPrefixMapping(prefix, uri);
|
xsdWriter.getContentWriterWrapped().startPrefixMapping(prefix, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
|
@ -223,7 +219,7 @@ public class EldXsdWriterElement {
|
||||||
atts.addAttribute ("", "elementFormDefault", "", "", "qualified");
|
atts.addAttribute ("", "elementFormDefault", "", "", "qualified");
|
||||||
atts.addAttribute ("", "attributeFormDefault", "", "", "unqualified");
|
atts.addAttribute ("", "attributeFormDefault", "", "", "unqualified");
|
||||||
atts.addAttribute ("", "targetNamespace", "", "", ns.getUri());
|
atts.addAttribute ("", "targetNamespace", "", "", ns.getUri());
|
||||||
xsdWriter.startElement (SCHEMA_URI, "schema", "", atts);
|
xsdWriter.printTagStart(Tag.schema, atts);
|
||||||
|
|
||||||
for (String uri:namespaces.keySet()) {
|
for (String uri:namespaces.keySet()) {
|
||||||
if (ns.getUri().equals(uri)) {
|
if (ns.getUri().equals(uri)) {
|
||||||
|
@ -237,8 +233,8 @@ public class EldXsdWriterElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endSchema() throws SAXException {
|
public void endSchema() throws SAXException {
|
||||||
xsdWriter.endElement (SCHEMA_URI, "schema" , "");
|
xsdWriter.printTagEnd(Tag.schema);
|
||||||
xsdWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
xsdWriter.getContentWriterWrapped().ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
|
||||||
xsdWriter.endDocument();
|
xsdWriter.endDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,13 +252,13 @@ public class EldXsdWriterElement {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) {
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
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();
|
atts = new AttributesImpl();
|
||||||
xsdWriter.startElement (SCHEMA_URI, "complexType", "", atts);
|
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId()+"Type");
|
atts.addAttribute ("", "name", "", "", ec.getId()+"Type");
|
||||||
xsdWriter.startElement (SCHEMA_URI, "complexType", "", atts);
|
xsdWriter.printTagStart(Tag.complexType, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getSchemaContentBase()!=null) {
|
if (ec.getSchemaContentBase()!=null) {
|
||||||
|
@ -271,27 +267,27 @@ public class EldXsdWriterElement {
|
||||||
if (ec.getSchemaContentMixed()!=null && ec.getSchemaContentMixed()) {
|
if (ec.getSchemaContentMixed()!=null && ec.getSchemaContentMixed()) {
|
||||||
atts.addAttribute ("", "mixed", "", "", "true");
|
atts.addAttribute ("", "mixed", "", "", "true");
|
||||||
}
|
}
|
||||||
xsdWriter.startElement (SCHEMA_URI, "complexContent", "", atts);
|
xsdWriter.printTagStart(Tag.complexContent, atts);
|
||||||
} else {
|
} else {
|
||||||
xsdWriter.startElement (SCHEMA_URI, "simpleContent", "", atts);
|
xsdWriter.printTagStart(Tag.simpleContent, atts);
|
||||||
}
|
}
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "base", "", "", ec.getSchemaContentBase());
|
atts.addAttribute ("", "base", "", "", ec.getSchemaContentBase());
|
||||||
xsdWriter.startElement (SCHEMA_URI, "extension", "", atts);
|
xsdWriter.printTagStart(Tag.extension, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ec.getSchemaContentBase()==null) {
|
if (ec.getSchemaContentBase()==null) {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
atts.addAttribute ("", "minOccurs", "", "", "0"); // TODO: make unordered elements
|
||||||
atts.addAttribute ("", "maxOccurs", "", "", "unbounded");
|
atts.addAttribute ("", "maxOccurs", "", "", "unbounded");
|
||||||
xsdWriter.startElement (SCHEMA_URI, "choice", "", atts);
|
xsdWriter.printTagStart(Tag.choise, atts);
|
||||||
|
|
||||||
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
for (X4OLanguageModule mod:language.getLanguageModules()) {
|
||||||
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
for (ElementNamespace ns:mod.getElementNamespaces()) {
|
||||||
writeElementClassNamespaces(ec,nsWrite,ns);
|
writeElementClassNamespaces(ec,nsWrite,ns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xsdWriter.endElement(SCHEMA_URI, "choice", "");
|
xsdWriter.printTagEnd(Tag.choise);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> attrNames = new ArrayList<String>(30);
|
List<String> attrNames = new ArrayList<String>(30);
|
||||||
|
@ -316,7 +312,7 @@ public class EldXsdWriterElement {
|
||||||
|
|
||||||
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
|
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
|
||||||
// oke, reverse this if and rm whitespace.
|
// oke, reverse this if and rm whitespace.
|
||||||
xsdWriter.ignorableWhitespace(' ');
|
xsdWriter.getContentWriterWrapped().ignorableWhitespace(' ');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -354,27 +350,25 @@ public class EldXsdWriterElement {
|
||||||
} else {
|
} else {
|
||||||
atts.addAttribute ("", "type", "", "", "string");
|
atts.addAttribute ("", "type", "", "", "string");
|
||||||
}
|
}
|
||||||
xsdWriter.startElement (SCHEMA_URI, "attribute", "", atts);
|
xsdWriter.printTagStartEnd(Tag.attribute, atts);
|
||||||
xsdWriter.endElement(SCHEMA_URI, "attribute", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
xsdWriter.startElement (SCHEMA_URI, "anyAttribute", "", atts);
|
xsdWriter.printTagStartEnd(Tag.anyAttribute, atts);
|
||||||
xsdWriter.endElement(SCHEMA_URI, "anyAttribute", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ec.getSchemaContentBase()!=null) {
|
if (ec.getSchemaContentBase()!=null) {
|
||||||
xsdWriter.endElement(SCHEMA_URI, "extension", "");
|
xsdWriter.printTagEnd(Tag.extension);
|
||||||
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
if (ec.getSchemaContentComplex()!=null && ec.getSchemaContentComplex()) {
|
||||||
xsdWriter.endElement(SCHEMA_URI, "complexContent", "");
|
xsdWriter.printTagEnd(Tag.complexContent);
|
||||||
} else {
|
} 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()) {
|
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 ("", "name", "", "", refElement);
|
||||||
atts.addAttribute ("", "type", "", "", prefix+":"+refElement+"Type");
|
atts.addAttribute ("", "type", "", "", prefix+":"+refElement+"Type");
|
||||||
}
|
}
|
||||||
xsdWriter.startElement (SCHEMA_URI, "element", "", atts);
|
xsdWriter.printTagStartEnd(Tag.element,atts);
|
||||||
xsdWriter.endElement (SCHEMA_URI, "element", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,9 +433,9 @@ public class EldXsdWriterElement {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", ec.getId());
|
atts.addAttribute ("", "name", "", "", ec.getId());
|
||||||
atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type");
|
atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type");
|
||||||
xsdWriter.startElement(SCHEMA_URI, "element", "", atts);
|
xsdWriter.printTagStart(Tag.element,atts);
|
||||||
writeElementMetaBase(ec);
|
writeElementMetaBase(ec);
|
||||||
xsdWriter.endElement(SCHEMA_URI, "element", "");
|
xsdWriter.printTagEnd(Tag.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws SAXException {
|
private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws SAXException {
|
||||||
|
|
|
@ -61,7 +61,6 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
*/
|
*/
|
||||||
public class X4ODebugWriter {
|
public class X4ODebugWriter {
|
||||||
|
|
||||||
|
|
||||||
static public final String DEBUG_URI = "http://language.x4o.org/xml/ns/debug-output";
|
static public final String DEBUG_URI = "http://language.x4o.org/xml/ns/debug-output";
|
||||||
|
|
||||||
protected ContentWriter contentWriter = null;
|
protected ContentWriter contentWriter = null;
|
||||||
|
@ -74,6 +73,12 @@ public class X4ODebugWriter {
|
||||||
return contentWriter;
|
return contentWriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum X4ODebugTag {
|
||||||
|
execute222Phase,
|
||||||
|
testTasg,
|
||||||
|
stekel
|
||||||
|
}
|
||||||
|
|
||||||
public X4OPhaseListener createDebugX4OPhaseListener() {
|
public X4OPhaseListener createDebugX4OPhaseListener() {
|
||||||
return new DebugX4OPhaseListener();
|
return new DebugX4OPhaseListener();
|
||||||
}
|
}
|
||||||
|
@ -94,7 +99,7 @@ public class X4ODebugWriter {
|
||||||
if (elementLanguage!=null) {
|
if (elementLanguage!=null) {
|
||||||
atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName());
|
atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName());
|
||||||
}
|
}
|
||||||
contentWriter.startElement (DEBUG_URI, "executePhase", "", atts);
|
contentWriter.startElement (DEBUG_URI, X4ODebugTag.execute222Phase.name(), "", atts);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new X4OPhaseException(phase,e);
|
throw new X4OPhaseException(phase,e);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +115,7 @@ public class X4ODebugWriter {
|
||||||
contentWriter.startElement (DEBUG_URI, "executePhaseDone", "", atts);
|
contentWriter.startElement (DEBUG_URI, "executePhaseDone", "", atts);
|
||||||
contentWriter.endElement (DEBUG_URI, "executePhaseDone" , "");
|
contentWriter.endElement (DEBUG_URI, "executePhaseDone" , "");
|
||||||
|
|
||||||
contentWriter.endElement (DEBUG_URI, "executePhase" , "");
|
contentWriter.endElement (DEBUG_URI, X4ODebugTag.execute222Phase.name() , "");
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
throw new X4OPhaseException(phase,e);
|
throw new X4OPhaseException(phase,e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
*/
|
*/
|
||||||
public class AbstractContentWriterHandler implements ContentHandler {
|
public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
|
|
||||||
protected final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
|
||||||
private final PropertyConfig propertyConfig;
|
private final PropertyConfig propertyConfig;
|
||||||
private Writer out = null;
|
private Writer out = null;
|
||||||
private int indent = 0;
|
private int indent = 0;
|
||||||
|
@ -65,7 +64,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
||||||
private boolean printReturn = false;
|
private boolean printReturn = false;
|
||||||
private String lastElement = null;
|
private String lastElement = null;
|
||||||
private Stack<String> elements = null;
|
private Stack<String> elements = null;
|
||||||
|
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_WRITER_XML;
|
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 PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
public final static String OUTPUT_ENCODING = PROPERTY_CONTEXT_PREFIX+"output/encoding";
|
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_ENCODING, String.class, XMLConstants.XML_DEFAULT_ENCODING),
|
||||||
new PropertyConfigItem(OUTPUT_CHAR_TAB, String.class, XMLConstants.CHAR_TAB+""),
|
new PropertyConfigItem(OUTPUT_CHAR_TAB, String.class, XMLConstants.CHAR_TAB+""),
|
||||||
new PropertyConfigItem(OUTPUT_CHAR_NEWLINE, String.class, XMLConstants.CHAR_NEWLINE+""),
|
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_ENABLE, Boolean.class, true),
|
||||||
new PropertyConfigItem(OUTPUT_COMMENT_AUTO_SPACE, Boolean.class, true),
|
new PropertyConfigItem(OUTPUT_COMMENT_AUTO_SPACE, Boolean.class, true),
|
||||||
new PropertyConfigItem(OUTPUT_LINE_BREAK_WIDTH, Integer.class, -1),
|
new PropertyConfigItem(OUTPUT_LINE_BREAK_WIDTH, Integer.class, -1),
|
||||||
|
|
|
@ -46,13 +46,38 @@ public interface ContentWriter extends ContentHandler,LexicalHandler {
|
||||||
*/
|
*/
|
||||||
void startElementEnd(String uri, String localName, String name,Attributes atts) throws SAXException;
|
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;
|
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;
|
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;
|
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;
|
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;
|
void characters(char c) throws SAXException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,19 +31,27 @@ import org.xml.sax.SAXException;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 May 3, 2013
|
* @version 1.0 May 3, 2013
|
||||||
*/
|
*/
|
||||||
public interface ContentWriterTag<T extends Enum<?>> extends ContentWriter {
|
public interface ContentWriterTag<TAG extends Enum<?>> {
|
||||||
|
|
||||||
String getTagNamespaceUri();
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,22 +34,21 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 May 3, 2013
|
* @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) {
|
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() {
|
public PropertyConfig getPropertyConfig() {
|
||||||
return XMLConstants.XML_SCHEMA_NS_URI;
|
return getContentWriterWrapped().getPropertyConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printXsdImport(String namespace,String schemaLocation) throws SAXException {
|
public void printXsdImport(String namespace,String schemaLocation) throws SAXException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "namespace", "", "", namespace);
|
atts.addAttribute ("", "namespace", "", "", namespace);
|
||||||
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
|
atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
|
||||||
startElement (getTagNamespaceUri(), "import", "", atts);
|
printTagStartEnd(Tag._import, atts);
|
||||||
endElement (getTagNamespaceUri(), "import", ""); // import is keyword
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printXsdDocumentation(String description) throws SAXException {
|
public void printXsdDocumentation(String description) throws SAXException {
|
||||||
|
@ -60,8 +59,8 @@ public class ContentWriterXsd extends ContentWriterXmlTag<ContentWriterXsd.Tag>
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "xml:lang", "", "", "en");
|
atts.addAttribute ("", "xml:lang", "", "", "en");
|
||||||
printTagStart(Tag.documentation,atts);
|
printTagStart(Tag.documentation,atts);
|
||||||
characters(description);
|
printCharacters(description);
|
||||||
printTagEnd(Tag.documentation);
|
printTagEnd(Tag.documentation);
|
||||||
printTagEnd(Tag.annotation);
|
printTagEnd(Tag.annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,16 +69,15 @@ public class ContentWriterXsd extends ContentWriterXmlTag<ContentWriterXsd.Tag>
|
||||||
atts.addAttribute ("", "name", "", "", name);
|
atts.addAttribute ("", "name", "", "", name);
|
||||||
atts.addAttribute ("", "type", "", "", type);
|
atts.addAttribute ("", "type", "", "", type);
|
||||||
printTagStart(Tag.attribute,atts);
|
printTagStart(Tag.attribute,atts);
|
||||||
printXsdDocumentation(description);
|
printXsdDocumentation(description);
|
||||||
printTagEnd(Tag.attribute);
|
printTagEnd(Tag.attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Tag {
|
public enum Tag {
|
||||||
all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
|
all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
|
||||||
choise,complexContent,complexType,documentation,element,extension,
|
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,
|
redefine,restriction,schema,selector,sequence,
|
||||||
simpleContent,simpleType,unoin,unique
|
simpleContent,simpleType,unoin,unique
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,14 +131,14 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
|
||||||
writer.printTagCharacters(Tag.dt,"All Element Parents:");
|
writer.printTagCharacters(Tag.dt,"All Element Parents:");
|
||||||
writer.printTagStart(Tag.dd);
|
writer.printTagStart(Tag.dd);
|
||||||
if (parents.isEmpty()) {
|
if (parents.isEmpty()) {
|
||||||
writer.characters("No parent.");
|
writer.printCharacters("No parent.");
|
||||||
}
|
}
|
||||||
for (int i=0;i<parents.size();i++) {
|
for (int i=0;i<parents.size();i++) {
|
||||||
TreeNode n = parents.get(i);
|
TreeNode n = parents.get(i);
|
||||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||||
if (i<parents.size()-1) {
|
if (i<parents.size()-1) {
|
||||||
writer.characters(", ");
|
writer.printCharacters(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.dd);
|
writer.printTagEnd(Tag.dd);
|
||||||
|
@ -149,14 +149,14 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
|
||||||
writer.printTagCharacters(Tag.dt,"All Element Childeren:");
|
writer.printTagCharacters(Tag.dt,"All Element Childeren:");
|
||||||
writer.printTagStart(Tag.dd);
|
writer.printTagStart(Tag.dd);
|
||||||
if (childs.isEmpty()) {
|
if (childs.isEmpty()) {
|
||||||
writer.characters("No childeren.");
|
writer.printCharacters("No childeren.");
|
||||||
}
|
}
|
||||||
for (int i=0;i<childs.size();i++) {
|
for (int i=0;i<childs.size();i++) {
|
||||||
TreeNode n = childs.get(i);
|
TreeNode n = childs.get(i);
|
||||||
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
String uri = toElementUri(pathPrefix, n.module, n.namespace, n.elementClass);
|
||||||
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
writer.printHref(uri, n.namespace.getId()+":"+n.elementClass.getId());
|
||||||
if (i<childs.size()-1) {
|
if (i<childs.size()-1) {
|
||||||
writer.characters(", ");
|
writer.printCharacters(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.dd);
|
writer.printTagEnd(Tag.dd);
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
|
||||||
|
|
||||||
writer.printTagStart(Tag.ul);
|
writer.printTagStart(Tag.ul);
|
||||||
writer.printTagStart(Tag.li,"",null,"circle");
|
writer.printTagStart(Tag.li,"",null,"circle");
|
||||||
writer.characters(node.namespace.getId());
|
writer.printCharacters(node.namespace.getId());
|
||||||
writer.characters(":");
|
writer.printCharacters(":");
|
||||||
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong");
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ public abstract class AbstractApiDocWriter {
|
||||||
writer.docTableRowLastStart(n, null);
|
writer.docTableRowLastStart(n, null);
|
||||||
String c = printValue(doc,writer,value);
|
String c = printValue(doc,writer,value);
|
||||||
if (c!=null) {
|
if (c!=null) {
|
||||||
writer.characters(c);
|
writer.printCharacters(c);
|
||||||
}
|
}
|
||||||
writer.docTableRowLastEnd();
|
writer.docTableRowLastEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,12 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docCommentGenerated() throws SAXException {
|
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 {
|
public void docHtmlStart(String title,List<String> keywords,String pathPrefix) throws SAXException {
|
||||||
printDocType(DocType.HTML_4_TRANSITIONAL);
|
printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||||
comment("NewPage");
|
printComment("NewPage");
|
||||||
printHtmlStart("en");
|
printHtmlStart("en");
|
||||||
|
|
||||||
// ====== Write head
|
// ====== Write head
|
||||||
|
@ -80,7 +80,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
public void docHtmlEnd(String copyright,String statsJS) throws SAXException {
|
public void docHtmlEnd(String copyright,String statsJS) throws SAXException {
|
||||||
printTagStart(Tag.p,ApiDocContentCss.legalCopy);
|
printTagStart(Tag.p,ApiDocContentCss.legalCopy);
|
||||||
printTagStart(Tag.small);
|
printTagStart(Tag.small);
|
||||||
characters(copyright);
|
printCharacters(copyright);
|
||||||
printTagEnd(Tag.small);
|
printTagEnd(Tag.small);
|
||||||
printTagEnd(Tag.p);
|
printTagEnd(Tag.p);
|
||||||
if (statsJS!=null) {
|
if (statsJS!=null) {
|
||||||
|
@ -97,7 +97,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
String[] lines = about.split("\n");
|
String[] lines = about.split("\n");
|
||||||
for (int i=0;i<lines.length;i++) {
|
for (int i=0;i<lines.length;i++) {
|
||||||
String line = lines[i];
|
String line = lines[i];
|
||||||
characters(line);
|
printCharacters(line);
|
||||||
if (i<lines.length-1) {
|
if (i<lines.length-1) {
|
||||||
printTagStartEnd(Tag.br);
|
printTagStartEnd(Tag.br);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
printTagStart(Tag.p);
|
printTagStart(Tag.p);
|
||||||
characters("See: ");
|
printCharacters("See: ");
|
||||||
printHref("#package_description", "Description");
|
printHref("#package_description", "Description");
|
||||||
printTagEnd(Tag.p);
|
printTagEnd(Tag.p);
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
|
@ -124,15 +124,15 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
printHrefNamed("package_description");
|
printHrefNamed("package_description");
|
||||||
printTagCharacters(Tag.h2, title);
|
printTagCharacters(Tag.h2, title);
|
||||||
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
printTagCharacters(Tag.div, summary,ApiDocContentCss.block.name());
|
||||||
characters(description);
|
printCharacters(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageClassStart(String title,String subTitle,Tag titleTag) throws SAXException {
|
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);
|
printTagStart(Tag.div,ApiDocContentCss.header);
|
||||||
if (subTitle!=null) {
|
if (subTitle!=null) {
|
||||||
printTagStart(Tag.div,ApiDocContentCss.subTitle);
|
printTagStart(Tag.div,ApiDocContentCss.subTitle);
|
||||||
characters(subTitle);
|
printCharacters(subTitle);
|
||||||
printTagEnd(Tag.div);
|
printTagEnd(Tag.div);
|
||||||
}
|
}
|
||||||
printTagCharacters(titleTag, title, "title");
|
printTagCharacters(titleTag, title, "title");
|
||||||
|
@ -140,7 +140,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageClassEnd() throws SAXException {
|
public void docPageClassEnd() throws SAXException {
|
||||||
comment("======== END OF CLASS DATA ========");
|
printComment("======== END OF CLASS DATA ========");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void docPageContentStart() throws SAXException {
|
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 {
|
public void docPageBlockStart(String title,String namedLink,String comment) throws SAXException {
|
||||||
if (comment!=null) {
|
if (comment!=null) {
|
||||||
comment(comment);
|
printComment(comment);
|
||||||
}
|
}
|
||||||
docPageBlockStart();
|
docPageBlockStart();
|
||||||
printHrefNamed(namedLink);
|
printHrefNamed(namedLink);
|
||||||
|
@ -186,11 +186,11 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
if (tableDescription!=null) {
|
if (tableDescription!=null) {
|
||||||
atts.addAttribute ("", "summary", "", "", tableDescription);
|
atts.addAttribute ("", "summary", "", "", tableDescription);
|
||||||
}
|
}
|
||||||
startElement("", "table", "", atts);
|
printTagStart(Tag.table,atts);
|
||||||
|
|
||||||
printTagStart(Tag.caption);
|
printTagStart(Tag.caption);
|
||||||
printTagStart(Tag.span);characters(tableTitle);printTagEnd(Tag.span);
|
printTagStart(Tag.span);printCharacters(tableTitle);printTagEnd(Tag.span);
|
||||||
printTagStart(Tag.span,ApiDocContentCss.tabEnd);characters(" ");printTagEnd(Tag.span);
|
printTagStart(Tag.span,ApiDocContentCss.tabEnd);printCharacters(" ");printTagEnd(Tag.span);
|
||||||
printTagEnd(Tag.caption);
|
printTagEnd(Tag.caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,9 +208,9 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
|
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
|
||||||
}
|
}
|
||||||
atts.addAttribute ("", "scope", "", "", "col");
|
atts.addAttribute ("", "scope", "", "", "col");
|
||||||
startElement("", "th", "", atts);
|
printTagStart(Tag.th,atts);
|
||||||
characters(titleFirst);
|
printCharacters(titleFirst);
|
||||||
endElement("", "th", "");
|
printTagEnd(Tag.th);
|
||||||
if (titleLast==null) {
|
if (titleLast==null) {
|
||||||
printTagEnd(Tag.tr);
|
printTagEnd(Tag.tr);
|
||||||
return;
|
return;
|
||||||
|
@ -218,8 +218,8 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
atts = new AttributesImpl();
|
atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
|
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
|
||||||
atts.addAttribute ("", "scope", "", "", "col");
|
atts.addAttribute ("", "scope", "", "", "col");
|
||||||
startElement("", "th", "", atts);
|
printTagStart(Tag.th,atts);
|
||||||
characters(titleLast);
|
printCharacters(titleLast);
|
||||||
printTagEnd(Tag.th);
|
printTagEnd(Tag.th);
|
||||||
printTagEnd(Tag.tr);
|
printTagEnd(Tag.tr);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
printTagStart(Tag.code);
|
printTagStart(Tag.code);
|
||||||
}
|
}
|
||||||
if (dataFirstHref==null) {
|
if (dataFirstHref==null) {
|
||||||
characters(dataFirst);
|
printCharacters(dataFirst);
|
||||||
} else {
|
} else {
|
||||||
printHref(dataFirstHref, dataFirst, dataFirst);
|
printHref(dataFirstHref, dataFirst, dataFirst);
|
||||||
}
|
}
|
||||||
|
@ -282,12 +282,12 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
||||||
|
|
||||||
printTagStart(Tag.td,ApiDocContentCss.colLast);
|
printTagStart(Tag.td,ApiDocContentCss.colLast);
|
||||||
if (dataLastCode) {
|
if (dataLastCode) {
|
||||||
printTagStart(Tag.code);characters(dataLast);printTagEnd(Tag.code);
|
printTagStart(Tag.code);printCharacters(dataLast);printTagEnd(Tag.code);
|
||||||
} else {
|
} else {
|
||||||
printTagStart(Tag.div,ApiDocContentCss.block);characters(dataLast);printTagEnd(Tag.div);
|
printTagStart(Tag.div,ApiDocContentCss.block);printCharacters(dataLast);printTagEnd(Tag.div);
|
||||||
}
|
}
|
||||||
if (dataBlock!=null) {
|
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);
|
printTagEnd(Tag.td);
|
||||||
|
|
||||||
|
|
|
@ -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.ApiDocPage;
|
||||||
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
|
||||||
import org.x4o.xml.io.XMLConstants;
|
import org.x4o.xml.io.XMLConstants;
|
||||||
|
import org.x4o.xml.io.sax.ext.ContentWriterXml;
|
||||||
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
@ -179,7 +180,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
writer.docPageClassEnd();
|
writer.docPageClassEnd();
|
||||||
docNavBar(writer,false,concept,node);
|
docNavBar(writer,false,concept,node);
|
||||||
writer.docHtmlEnd(doc.getDocCopyright(),doc.getDocStatsJS());
|
writer.docHtmlEnd(doc.getDocCopyright(),doc.getDocStatsJS());
|
||||||
writer.closeWriterSafe();
|
writer.getContentWriterWrapped().closeWriterSafe();
|
||||||
|
|
||||||
// Writer other files
|
// Writer other files
|
||||||
writeAllFrameNavNode(node);
|
writeAllFrameNavNode(node);
|
||||||
|
@ -209,7 +210,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void defaultWriteNodeDescription(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
|
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 {
|
private void writeNodeDescription(ApiDocWriteEvent<ApiDocNode> event,boolean isPageMode) throws SAXException {
|
||||||
|
@ -418,7 +419,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
String nodeTitle = node.getId();
|
String nodeTitle = node.getId();
|
||||||
if (nodes.hasNext()==false) {
|
if (nodes.hasNext()==false) {
|
||||||
writer.printTagStart(Tag.li);
|
writer.printTagStart(Tag.li);
|
||||||
writer.characters(nodeTitle);
|
writer.printCharacters(nodeTitle);
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
} else {
|
} else {
|
||||||
writer.printTagStart(Tag.li);
|
writer.printTagStart(Tag.li);
|
||||||
|
@ -455,8 +456,8 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
try {
|
try {
|
||||||
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
|
||||||
ApiDocContentWriter result = new ApiDocContentWriter(out,encoding);
|
ApiDocContentWriter result = new ApiDocContentWriter(out,encoding);
|
||||||
result.getPropertyConfig().setProperty(ApiDocContentWriter.OUTPUT_CHAR_NEWLINE, XMLConstants.CHAR_NEWLINE+"");
|
result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_NEWLINE, XMLConstants.CHAR_NEWLINE+"");
|
||||||
result.getPropertyConfig().setProperty(ApiDocContentWriter.OUTPUT_CHAR_TAB, " ");
|
result.getPropertyConfig().setProperty(ContentWriterXml.OUTPUT_CHAR_TAB, " ");
|
||||||
return result;
|
return result;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new SAXException(e);
|
throw new SAXException(e);
|
||||||
|
@ -631,13 +632,14 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
"\tif (targetPage != \"\" && targetPage != \"undefined\")\n"+
|
"\tif (targetPage != \"\" && targetPage != \"undefined\")\n"+
|
||||||
"\t\t { top."+ApiDocContentCss.frameContent.name()+".location = top.targetPage; }\n"+
|
"\t\t { top."+ApiDocContentCss.frameContent.name()+".location = top.targetPage; }\n"+
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
public void writeIndex() throws SAXException {
|
public void writeIndex() throws SAXException {
|
||||||
File outputFile = createOutputPathFile(basePath,"index.html");
|
File outputFile = createOutputPathFile(basePath,"index.html");
|
||||||
ApiDocContentWriter writer = createContentWriter(outputFile);
|
ApiDocContentWriter writer = createContentWriter(outputFile);
|
||||||
try {
|
try {
|
||||||
writer.printDocType(DocType.HTML_4_FRAMESET);
|
writer.printDocType(DocType.HTML_4_FRAMESET);
|
||||||
writer.comment("NewPage");
|
writer.printComment("NewPage");
|
||||||
writer.printHtmlStart("en");
|
writer.printHtmlStart("en");
|
||||||
writeHeader(writer,"",doc.getName());
|
writeHeader(writer,"",doc.getName());
|
||||||
writer.printScriptInline(FRAME_JS);
|
writer.printScriptInline(FRAME_JS);
|
||||||
|
@ -682,16 +684,16 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
writer.printScriptNoDiv();
|
writer.printScriptNoDiv();
|
||||||
writer.printTagCharacters(Tag.h2, "Frame Alert");
|
writer.printTagCharacters(Tag.h2, "Frame Alert");
|
||||||
writer.printTagStart(Tag.p);
|
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.printHref(rootLink, "Non-frame version");
|
||||||
writer.characters(".");
|
writer.printCharacters(".");
|
||||||
writer.printTagEnd(Tag.p);
|
writer.printTagEnd(Tag.p);
|
||||||
writer.printTagEnd(Tag.noframes);
|
writer.printTagEnd(Tag.noframes);
|
||||||
|
|
||||||
writer.printTagEnd(Tag.frameset);
|
writer.printTagEnd(Tag.frameset);
|
||||||
writer.printHtmlEnd();
|
writer.printHtmlEnd();
|
||||||
} finally {
|
} finally {
|
||||||
writer.closeWriterSafe();
|
writer.getContentWriterWrapped().closeWriterSafe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,7 +719,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
String conceptParentPlural = conceptParent.getName()+"s";
|
String conceptParentPlural = conceptParent.getName()+"s";
|
||||||
|
|
||||||
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||||
writer.comment("NewPage");
|
writer.printComment("NewPage");
|
||||||
writer.printHtmlStart("en");
|
writer.printHtmlStart("en");
|
||||||
writeHeader(writer,"","All "+conceptPlural+" of "+doc.getName());
|
writeHeader(writer,"","All "+conceptPlural+" of "+doc.getName());
|
||||||
writer.printTagStart(Tag.body);
|
writer.printTagStart(Tag.body);
|
||||||
|
@ -748,7 +750,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
writer.printTagEnd(Tag.body);
|
writer.printTagEnd(Tag.body);
|
||||||
writer.printHtmlEnd();
|
writer.printHtmlEnd();
|
||||||
} finally {
|
} finally {
|
||||||
writer.closeWriterSafe();
|
writer.getContentWriterWrapped().closeWriterSafe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,7 +792,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
//String conceptParentPlural = conceptParent.getName()+"s";
|
//String conceptParentPlural = conceptParent.getName()+"s";
|
||||||
|
|
||||||
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
writer.printDocType(DocType.HTML_4_TRANSITIONAL);
|
||||||
writer.comment("NewPage");
|
writer.printComment("NewPage");
|
||||||
writer.printHtmlStart("en");
|
writer.printHtmlStart("en");
|
||||||
writeHeader(writer,pathPrefix,"All "+conceptPlural+" of "+doc.getName());
|
writeHeader(writer,pathPrefix,"All "+conceptPlural+" of "+doc.getName());
|
||||||
writer.printTagStart(Tag.body);
|
writer.printTagStart(Tag.body);
|
||||||
|
@ -859,7 +861,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
writer.printTagEnd(Tag.body);
|
writer.printTagEnd(Tag.body);
|
||||||
writer.printHtmlEnd();
|
writer.printHtmlEnd();
|
||||||
} finally {
|
} finally {
|
||||||
writer.closeWriterSafe();
|
writer.getContentWriterWrapped().closeWriterSafe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,7 +889,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
docNavBar(writer,false,null,null);
|
docNavBar(writer,false,null,null);
|
||||||
writer.docHtmlEnd(doc.getDocCopyright(),doc.getDocStatsJS());
|
writer.docHtmlEnd(doc.getDocCopyright(),doc.getDocStatsJS());
|
||||||
} finally {
|
} finally {
|
||||||
writer.closeWriterSafe();
|
writer.getContentWriterWrapped().closeWriterSafe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,7 +959,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
}
|
}
|
||||||
File outputPath = new File(buf.toString());
|
File outputPath = new File(buf.toString());
|
||||||
if (outputPath.exists()==false) {
|
if (outputPath.exists()==false) {
|
||||||
//System.out.println("Creating path: "+outputPath);
|
//System.out.println("Creating path: "+outputPath); // TODO add logger
|
||||||
outputPath.mkdirs();
|
outputPath.mkdirs();
|
||||||
}
|
}
|
||||||
buf.append(File.separatorChar);
|
buf.append(File.separatorChar);
|
||||||
|
@ -981,22 +983,22 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
barCssDiv = "bottomNav";
|
barCssDiv = "bottomNav";
|
||||||
barId = "navbar_bottom";
|
barId = "navbar_bottom";
|
||||||
}
|
}
|
||||||
writer.comment("========= START OF "+barComment+" NAVBAR =======");
|
writer.printComment("========= START OF "+barComment+" NAVBAR =======");
|
||||||
|
|
||||||
writer.printTagStart(Tag.div,barCssDiv);
|
writer.printTagStart(Tag.div,barCssDiv);
|
||||||
writer.printHrefNamed(barId); // Print named link navigation
|
writer.printHrefNamed(barId); // Print named link navigation
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "href", "", "", "#skip-"+barId);
|
atts.addAttribute ("", "href", "", "", "#skip-"+barId);
|
||||||
atts.addAttribute ("", "title", "", "", "Skip navigation links");
|
atts.addAttribute ("", "title", "", "", "Skip navigation links");
|
||||||
writer.startElement("", "a", "", atts);
|
writer.printTagStart(Tag.a, atts);
|
||||||
writer.comment(" ");
|
writer.printComment(" ");
|
||||||
writer.endElement("", "a", "");
|
writer.printTagEnd(Tag.a);
|
||||||
writer.printHrefNamed(barId+"_firstrow");
|
writer.printHrefNamed(barId+"_firstrow");
|
||||||
|
|
||||||
atts = new AttributesImpl();// Print nav bar
|
atts = new AttributesImpl();// Print nav bar
|
||||||
atts.addAttribute ("", "class", "", "", "navList");
|
atts.addAttribute ("", "class", "", "", "navList");
|
||||||
atts.addAttribute ("", "title", "", "", "Navigation");
|
atts.addAttribute ("", "title", "", "", "Navigation");
|
||||||
writer.startElement("", "ul", "", atts);
|
writer.printTagStart(Tag.ul, atts);
|
||||||
|
|
||||||
for (ApiDocNavLink navLink:conf.getNavLinks()) {
|
for (ApiDocNavLink navLink:conf.getNavLinks()) {
|
||||||
String selectedCss = null;
|
String selectedCss = null;
|
||||||
|
@ -1015,7 +1017,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
docNavBarListItemHref(writer,pathPrefix+href,navTitle,navLink.getText(),selectedCss,null,null);
|
docNavBarListItemHref(writer,pathPrefix+href,navTitle,navLink.getText(),selectedCss,null,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.endElement("", "ul", "");
|
writer.printTagEnd(Tag.ul);
|
||||||
|
|
||||||
writer.docNavBarAbout(doc.getDocAbout());
|
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.div); // don't print empty div
|
||||||
}
|
}
|
||||||
writer.printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
writer.printTagStart(Tag.ul,ApiDocContentCss.subNavList);
|
||||||
writer.printTagStart(Tag.li);writer.characters(groupName+": ");writer.printTagEnd(Tag.li);
|
writer.printTagStart(Tag.li);writer.printCharacters(groupName+": ");writer.printTagEnd(Tag.li);
|
||||||
for (int l=0;l<links.size();l++) {
|
for (int l=0;l<links.size();l++) {
|
||||||
ApiDocNavLink link = links.get(l);
|
ApiDocNavLink link = links.get(l);
|
||||||
writer.printTagStart(Tag.li);
|
writer.printTagStart(Tag.li);
|
||||||
|
@ -1097,9 +1099,9 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
if (link.getHref()!=null) {
|
if (link.getHref()!=null) {
|
||||||
docNavBarListItemHref(writer,link.getHref(), link.getTitle(), link.getText(), null, null, tab);
|
docNavBarListItemHref(writer,link.getHref(), link.getTitle(), link.getText(), null, null, tab);
|
||||||
} else {
|
} else {
|
||||||
writer.characters(link.getText());
|
writer.printCharacters(link.getText());
|
||||||
if (tab!=null) {
|
if (tab!=null) {
|
||||||
writer.characters(tab);
|
writer.printCharacters(tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
|
@ -1113,13 +1115,13 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
||||||
}
|
}
|
||||||
writer.printHrefNamed("skip-"+barId);
|
writer.printHrefNamed("skip-"+barId);
|
||||||
writer.printTagEnd(Tag.div);
|
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 {
|
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.printTagStart(Tag.li,cssClass);
|
||||||
writer.printHref(href,title,text,spanCss);
|
writer.printHref(href,title,text,spanCss);
|
||||||
writer.characters(linkSpace);
|
writer.printCharacters(linkSpace);
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class DefaultPageWriterHelp implements ApiDocPageWriter {
|
||||||
writer.printTagStart(Tag.div,"header");
|
writer.printTagStart(Tag.div,"header");
|
||||||
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
|
writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
|
||||||
writer.printTagStart(Tag.div,"subTitle");
|
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);
|
||||||
writer.printTagEnd(Tag.div);
|
writer.printTagEnd(Tag.div);
|
||||||
|
|
||||||
|
@ -59,14 +59,14 @@ public class DefaultPageWriterHelp implements ApiDocPageWriter {
|
||||||
for (ApiDocConcept concept:doc.getConcepts()) {
|
for (ApiDocConcept concept:doc.getConcepts()) {
|
||||||
writer.printTagCharacters(Tag.h2, concept.getName());
|
writer.printTagCharacters(Tag.h2, concept.getName());
|
||||||
writer.printTagStart(Tag.p);
|
writer.printTagStart(Tag.p);
|
||||||
writer.characters(concept.getDescriptionHelp());
|
writer.printCharacters(concept.getDescriptionHelp());
|
||||||
writer.printTagEnd(Tag.p);
|
writer.printTagEnd(Tag.p);
|
||||||
writer.docPageBlockNext();
|
writer.docPageBlockNext();
|
||||||
}
|
}
|
||||||
for (ApiDocPage docPage:doc.getDocPages()) {
|
for (ApiDocPage docPage:doc.getDocPages()) {
|
||||||
writer.printTagCharacters(Tag.h2, docPage.getName());
|
writer.printTagCharacters(Tag.h2, docPage.getName());
|
||||||
writer.printTagStart(Tag.p);
|
writer.printTagStart(Tag.p);
|
||||||
writer.characters(docPage.getDescription());
|
writer.printCharacters(docPage.getDescription());
|
||||||
writer.printTagEnd(Tag.p);
|
writer.printTagEnd(Tag.p);
|
||||||
writer.docPageBlockNext();
|
writer.docPageBlockNext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,12 @@ public class DefaultPageWriterIndexAll implements ApiDocPageWriter {
|
||||||
writer.docPageContentStart();
|
writer.docPageContentStart();
|
||||||
for (char i='A';i<='Z';i++) {
|
for (char i='A';i<='Z';i++) {
|
||||||
writer.printHref("#_"+i+"_", ""+i);
|
writer.printHref("#_"+i+"_", ""+i);
|
||||||
writer.characters(" ");
|
writer.printCharacters(" ");
|
||||||
}
|
}
|
||||||
for (char i='A';i<='Z';i++) {
|
for (char i='A';i<='Z';i++) {
|
||||||
writer.printHrefNamed("_"+i+"_");
|
writer.printHrefNamed("_"+i+"_");
|
||||||
writer.printTagCharacters(Tag.h2, ""+i);
|
writer.printTagCharacters(Tag.h2, ""+i);
|
||||||
writer.characters("TODO");
|
writer.printCharacters("TODO");
|
||||||
}
|
}
|
||||||
writer.docPageContentEnd();
|
writer.docPageContentEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,8 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
|
||||||
writer.printTagStart(Tag.ul);
|
writer.printTagStart(Tag.ul);
|
||||||
writer.printTagStart(Tag.li,"",null,"circle");
|
writer.printTagStart(Tag.li,"",null,"circle");
|
||||||
if (node.getParent()!=null) {
|
if (node.getParent()!=null) {
|
||||||
writer.characters(node.getParent().getId());
|
writer.printCharacters(node.getParent().getId());
|
||||||
writer.characters(":");
|
writer.printCharacters(":");
|
||||||
}
|
}
|
||||||
writer.printHref(href, node.getName(), node.getName(), "strong");
|
writer.printHref(href, node.getName(), node.getName(), "strong");
|
||||||
writer.printTagEnd(Tag.li);
|
writer.printTagEnd(Tag.li);
|
||||||
|
|
|
@ -25,7 +25,10 @@ package org.x4o.html;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Calendar;
|
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.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
@ -35,14 +38,18 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 30, 2013
|
* @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) {
|
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 {
|
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 {
|
public void printHtmlStart(String language) throws SAXException {
|
||||||
|
@ -70,15 +77,15 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "http-equiv", "", "", "Content-Type");
|
atts.addAttribute ("", "http-equiv", "", "", "Content-Type");
|
||||||
atts.addAttribute ("", "content", "", "", "text/html");
|
atts.addAttribute ("", "content", "", "", "text/html");
|
||||||
atts.addAttribute ("", "charset", "", "", getPropertyConfig().getPropertyString(OUTPUT_ENCODING));
|
atts.addAttribute ("", "charset", "", "", getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING));
|
||||||
startElementEnd("", "meta", "", atts);
|
printTagStartEnd(Tag.meta, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHeadMeta(String name,String content) throws SAXException {
|
public void printHeadMeta(String name,String content) throws SAXException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", name);
|
atts.addAttribute ("", "name", "", "", name);
|
||||||
atts.addAttribute ("", "content", "", "", content);
|
atts.addAttribute ("", "content", "", "", content);
|
||||||
startElementEnd("", "meta", "", atts);
|
printTagStartEnd(Tag.meta, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHeadLinkCss(String cssUrl) throws SAXException {
|
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 ("", "type", "", "", "text/css");
|
||||||
atts.addAttribute ("", "title", "", "", "Style");
|
atts.addAttribute ("", "title", "", "", "Style");
|
||||||
atts.addAttribute ("", "href", "", "", cssUrl);
|
atts.addAttribute ("", "href", "", "", cssUrl);
|
||||||
startElementEnd("", "link", "", atts);
|
printTagStartEnd(Tag.link, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printScriptInline(String script) throws SAXException {
|
public void printScriptInline(String script) throws SAXException {
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "type", "", "", "text/javascript");
|
atts.addAttribute ("", "type", "", "", "text/javascript");
|
||||||
printTagStart(Tag.script,atts);
|
printTagStart(Tag.script,atts);
|
||||||
comment(script);
|
printComment(script);
|
||||||
printTagEnd(Tag.script);
|
printTagEnd(Tag.script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +114,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
|
||||||
text = "JavaScript is disabled on your browser.";
|
text = "JavaScript is disabled on your browser.";
|
||||||
}
|
}
|
||||||
printTagStart(Tag.noscript);
|
printTagStart(Tag.noscript);
|
||||||
printTagStart(Tag.div);characters(text);printTagEnd(Tag.div);
|
printTagStart(Tag.div);printCharacters(text);printTagEnd(Tag.div);
|
||||||
printTagEnd(Tag.noscript);
|
printTagEnd(Tag.noscript);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +122,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
atts.addAttribute ("", "name", "", "", name);
|
atts.addAttribute ("", "name", "", "", name);
|
||||||
printTagStart(Tag.a,atts);
|
printTagStart(Tag.a,atts);
|
||||||
comment(" ");
|
printComment(" ");
|
||||||
printTagEnd(Tag.a);
|
printTagEnd(Tag.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +131,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
|
||||||
atts.addAttribute ("", "href", "", "", href);
|
atts.addAttribute ("", "href", "", "", href);
|
||||||
atts.addAttribute ("", "target", "", "", target);
|
atts.addAttribute ("", "target", "", "", target);
|
||||||
printTagStart(Tag.a,atts);
|
printTagStart(Tag.a,atts);
|
||||||
characters(title);
|
printCharacters(title);
|
||||||
printTagEnd(Tag.a);
|
printTagEnd(Tag.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +157,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
|
||||||
}
|
}
|
||||||
printTagStart(Tag.span,atts);
|
printTagStart(Tag.span,atts);
|
||||||
}
|
}
|
||||||
characters(text);
|
printCharacters(text);
|
||||||
if (spanClass!=null) {
|
if (spanClass!=null) {
|
||||||
printTagEnd(Tag.span);
|
printTagEnd(Tag.span);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +173,7 @@ public class ContentWriterHtml extends ContentWriterXmlTag<ContentWriterHtml.Tag
|
||||||
if (text==null) {
|
if (text==null) {
|
||||||
text = " ";
|
text = " ";
|
||||||
}
|
}
|
||||||
characters(text);
|
printCharacters(text);
|
||||||
printTagEnd(tag);
|
printTagEnd(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue