From 92644fd14811be2071c8acf3be1213193a92e86f Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Wed, 1 May 2013 23:23:31 +0200 Subject: [PATCH] Redone elddoc html writer now via new sax ContentWriter interface. And implemented jdk7 javadoc compatible html/css for elddoc. --- .../src/main/java/org/x4o/xml/X4ODriver.java | 29 +- .../java/org/x4o/xml/el/X4OELContext.java | 2 +- .../org/x4o/xml/el/X4OELFunctionMapper.java | 10 + .../x4o/xml/eld/xsd/EldXsdXmlGenerator.java | 10 +- .../org/x4o/xml/eld/xsd/EldXsdXmlWriter.java | 6 +- .../java/org/x4o/xml/io/DefaultX4OReader.java | 26 +- .../java/org/x4o/xml/io/XMLConstants.java | 138 +- .../java/org/x4o/xml/io/sax/AttributeMap.java | 2 +- .../org/x4o/xml/io/sax/ContentWriter.java | 54 + .../x4o/xml/io/sax/ContentWriterConfig.java | 38 + .../org/x4o/xml/io/sax/ContentWriterHtml.java | 297 ++++ .../{XMLWriter.java => ContentWriterXml.java} | 351 +++-- .../org/x4o/xml/io/sax/X4ODebugWriter.java | 141 +- .../org/x4o/xml/io/sax/X4OTagHandler.java | 2 +- .../org/x4o/xml/lang/X4OLanguageProperty.java | 12 +- .../xml/lang/phase/X4OPhaseLanguageRead.java | 20 +- .../xml/lang/phase/X4OPhaseLanguageWrite.java | 6 +- .../x4o/xml/io/sax/ContentWriterXmlTest.java | 295 ++++ .../test/element/InlinePropertiesElement.java | 4 +- .../org/x4o/xml/eld/doc/ContentWriterDoc.java | 449 ++++++ .../org/x4o/xml/eld/doc/EldDocGenerator.java | 36 +- .../org/x4o/xml/eld/doc/EldDocHtmlWriter.java | 1335 +++++++++++------ .../x4o/xml/eld/doc/theme/jdk7/background.png | Bin 0 -> 1333 bytes .../x4o/xml/eld/doc/theme/jdk7/stylesheet.css | 447 ++++++ .../org/x4o/xml/eld/doc/theme/jdk7/tab.png | Bin 0 -> 333 bytes .../x4o/xml/eld/doc/theme/jdk7/titlebar.png | Bin 0 -> 2435 bytes .../xml/eld/doc/theme/jdk7/titlebar_end.png | Bin 0 -> 683 bytes 27 files changed, 2959 insertions(+), 751 deletions(-) create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriter.java create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterConfig.java create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterHtml.java rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{XMLWriter.java => ContentWriterXml.java} (65%) create mode 100644 x4o-driver/src/test/java/org/x4o/xml/io/sax/ContentWriterXmlTest.java create mode 100644 x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java create mode 100644 x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png create mode 100644 x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css create mode 100644 x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png create mode 100644 x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png create mode 100644 x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png diff --git a/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java b/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java index f6c14a3..cee4da5 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java +++ b/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java @@ -37,7 +37,7 @@ import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.phase.X4OPhaseManager; /** - * This is the starting point of the XML X4O Language Driver. + * X4ODriver Is the x4o language driver to interact with xml. * * @author Willem Cazander * @version 1.0 Aug 11, 2005 @@ -83,10 +83,19 @@ public abstract class X4ODriver { // =============== SchemaWriter + /** + * Creates a schema writer for the default language version. + * @return The schema writer for this language. + */ public X4OSchemaWriter createSchemaWriter() { return createSchemaWriter(getLanguageVersionDefault()); } + /** + * Creates a schema writer for a version of the language. + * @param version The version of the language. + * @return The schema writer for this language. + */ public X4OSchemaWriter createSchemaWriter(String version) { return new DefaultX4OSchemaWriter(createLanguageContext(version)); } @@ -135,18 +144,36 @@ public abstract class X4ODriver { // =============== Language + /** + * Returns the default language which is the latest version. + * @return The default language version. + */ final public String getLanguageVersionDefault() { return X4ODriverManager.getDefaultLanguageVersion(getLanguageVersions()); } + /** + * Creates the X4OLanguage for the specified version. + * @param version The language version to create. + * @return The created X4OLanguage. + */ final public X4OLanguage createLanguage(String version) { return buildLanguage(version); } + /** + * Creates the X4OLanguageContext for the default language version. + * @return The created X4OLanguageContext. + */ final public X4OLanguageContext createLanguageContext() { return createLanguageContext(getLanguageVersionDefault()); } + /** + * Creates the X4OLanguageContext for the specified version. + * @param version The language version to create the context for. + * @return The created X4OLanguageContext. + */ final public X4OLanguageContext createLanguageContext(String version) { return createLanguage(version).createLanguageContext(this); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/el/X4OELContext.java b/x4o-driver/src/main/java/org/x4o/xml/el/X4OELContext.java index b2a9745..aca70ac 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/el/X4OELContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/el/X4OELContext.java @@ -49,7 +49,7 @@ public class X4OELContext extends ELContext { /** * Creates a X4OELContext. */ - public X4OELContext(/* X4OLanguageConfiguration x4oParserConfig */) { + public X4OELContext() { CompositeELResolver compositeELResolver = new CompositeELResolver(); compositeELResolver.add(new X4OELResolver(new HashMap(100))); diff --git a/x4o-driver/src/main/java/org/x4o/xml/el/X4OELFunctionMapper.java b/x4o-driver/src/main/java/org/x4o/xml/el/X4OELFunctionMapper.java index bb1c78d..8f43923 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/el/X4OELFunctionMapper.java +++ b/x4o-driver/src/main/java/org/x4o/xml/el/X4OELFunctionMapper.java @@ -36,6 +36,10 @@ import javax.el.FunctionMapper; * @version 1.0 Sep 14, 2010 */ public class X4OELFunctionMapper extends FunctionMapper { + + /** + * Stores the el to method function mapping. + */ private Map functionMap = null; /** @@ -45,6 +49,12 @@ public class X4OELFunctionMapper extends FunctionMapper { functionMap = new HashMap(50); } + /** + * Resolves method el functions. + * @param prefix The function prefix. + * @param localName The local name of function. + * @return The resolved function or null is not found. + */ @Override public Method resolveFunction(String prefix, String localName) { String key = prefix + ":" + localName; diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java index de573cb..c699ea0 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlGenerator.java @@ -29,13 +29,13 @@ import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementNamespaceContext; import org.x4o.xml.io.XMLConstants; -import org.x4o.xml.io.sax.XMLWriter; +import org.x4o.xml.io.sax.ContentWriter; +import org.x4o.xml.io.sax.ContentWriterXml; import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguageProperty; import org.xml.sax.SAXException; -import org.xml.sax.ext.DefaultHandler2; /** * EldSchemaGenerator Creates XML Schema for a namespace uri from a x4o language driver. @@ -84,7 +84,7 @@ public class EldXsdXmlGenerator { checkNamespace(ns); FileOutputStream fio = new FileOutputStream(new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource())); try { - XMLWriter out = new XMLWriter(fio,encoding,charNew,charTab); + ContentWriterXml out = new ContentWriterXml(fio,encoding,charNew,charTab); generateSchema(ns.getUri(), out); } finally { fio.close(); @@ -96,7 +96,7 @@ public class EldXsdXmlGenerator { checkNamespace(ns); FileOutputStream fio = new FileOutputStream(new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource())); try { - XMLWriter out = new XMLWriter(fio,encoding,charNew,charTab); + ContentWriterXml out = new ContentWriterXml(fio,encoding,charNew,charTab); generateSchema(ns.getUri(), out); } finally { fio.close(); @@ -109,7 +109,7 @@ public class EldXsdXmlGenerator { } } - public void generateSchema(String namespaceUri,DefaultHandler2 xmlWriter) throws SAXException { + public void generateSchema(String namespaceUri,ContentWriter xmlWriter) throws SAXException { ElementNamespaceContext ns = language.findElementNamespaceContext(namespaceUri); if (ns==null) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java index 3cd7682..84ed201 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/xsd/EldXsdXmlWriter.java @@ -40,10 +40,10 @@ import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementMetaBase; import org.x4o.xml.element.ElementNamespaceContext; import org.x4o.xml.io.XMLConstants; +import org.x4o.xml.io.sax.ContentWriter; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguage; import org.xml.sax.SAXException; -import org.xml.sax.ext.DefaultHandler2; import org.xml.sax.helpers.AttributesImpl; /** @@ -60,11 +60,11 @@ public class EldXsdXmlWriter { static public final String SCHEMA_URI = "http://www.w3.org/2001/XMLSchema"; protected X4OLanguage language = null; - protected DefaultHandler2 xmlWriter = null; + protected ContentWriter xmlWriter = null; protected String writeNamespace = null; protected Map namespaces = null; - public EldXsdXmlWriter(DefaultHandler2 xmlWriter,X4OLanguage language) { + public EldXsdXmlWriter(ContentWriter xmlWriter,X4OLanguage language) { this.xmlWriter=xmlWriter; this.language=language; this.namespaces=new HashMap(10); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java index 321aa1f..eefade7 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java @@ -34,8 +34,9 @@ import java.util.logging.Logger; import javax.xml.parsers.ParserConfigurationException; +import org.x4o.xml.io.sax.ContentWriter; import org.x4o.xml.io.sax.X4ODebugWriter; -import org.x4o.xml.io.sax.XMLWriter; +import org.x4o.xml.io.sax.ContentWriterXml; import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageContextLocal; import org.x4o.xml.lang.X4OLanguageProperty; @@ -43,7 +44,6 @@ import org.x4o.xml.lang.X4OLanguagePropertyKeys; import org.x4o.xml.lang.phase.X4OPhaseException; import org.x4o.xml.lang.phase.X4OPhaseType; import org.xml.sax.SAXException; -import org.xml.sax.ext.DefaultHandler2; import org.xml.sax.helpers.AttributesImpl; /** @@ -105,11 +105,11 @@ public class DefaultX4OReader extends AbstractX4OReader { Object debugOutputHandler = languageContext.getLanguageProperty(X4OLanguageProperty.DEBUG_OUTPUT_HANDLER); Object debugOutputStream = languageContext.getLanguageProperty(X4OLanguageProperty.DEBUG_OUTPUT_STREAM); if (languageContext.getX4ODebugWriter()==null) { - DefaultHandler2 xmlDebugWriter = null; - if (debugOutputHandler instanceof DefaultHandler2) { - xmlDebugWriter = (DefaultHandler2)debugOutputHandler; + ContentWriter xmlDebugWriter = null; + if (debugOutputHandler instanceof ContentWriter) { + xmlDebugWriter = (ContentWriter)debugOutputHandler; } else if (debugOutputStream instanceof OutputStream) { - xmlDebugWriter = new XMLWriter((OutputStream)debugOutputStream); + xmlDebugWriter = new ContentWriterXml((OutputStream)debugOutputStream); } if (xmlDebugWriter!=null) { xmlDebugWriter.startDocument(); @@ -126,7 +126,7 @@ public class DefaultX4OReader extends AbstractX4OReader { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "language", "", "", languageContext.getLanguage().getLanguageName()); atts.addAttribute ("", "currentTimeMillis", "", "", System.currentTimeMillis()+""); - languageContext.getX4ODebugWriter().getDebugWriter().startElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", "", atts); + languageContext.getX4ODebugWriter().getContentWriter().startElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", "", atts); } // start parsing language @@ -142,7 +142,7 @@ public class DefaultX4OReader extends AbstractX4OReader { if (e instanceof X4OPhaseException) { atts.addAttribute ("", "phase", "", "", ((X4OPhaseException)e).getX4OPhaseHandler().getId()); } - languageContext.getX4ODebugWriter().getDebugWriter().startElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", "", atts); + languageContext.getX4ODebugWriter().getContentWriter().startElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", "", atts); StringWriter writer = new StringWriter(); PrintWriter printer = new PrintWriter(writer); printer.append('\n'); @@ -152,8 +152,8 @@ public class DefaultX4OReader extends AbstractX4OReader { e.getCause().printStackTrace(printer); } char[] stack = writer.getBuffer().toString().toCharArray(); - languageContext.getX4ODebugWriter().getDebugWriter().characters(stack, 0, stack.length); - languageContext.getX4ODebugWriter().getDebugWriter().endElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", ""); + languageContext.getX4ODebugWriter().getContentWriter().characters(stack, 0, stack.length); + languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", ""); } catch (Exception ee) { logger.warning(ee.getMessage()); } @@ -176,11 +176,11 @@ public class DefaultX4OReader extends AbstractX4OReader { } } finally { if (languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().getDebugWriter().endElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", ""); + languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", ""); } if (startedDebugWriter && languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().getDebugWriter().endPrefixMapping("debug"); - languageContext.getX4ODebugWriter().getDebugWriter().endDocument(); + languageContext.getX4ODebugWriter().getContentWriter().endPrefixMapping("debug"); + languageContext.getX4ODebugWriter().getContentWriter().endDocument(); if (debugOutputStream instanceof OutputStream) { OutputStream outputStream = (OutputStream)debugOutputStream; outputStream.flush(); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/XMLConstants.java b/x4o-driver/src/main/java/org/x4o/xml/io/XMLConstants.java index 274ff02..d1fb1dc 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/XMLConstants.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/XMLConstants.java @@ -71,6 +71,11 @@ public final class XMLConstants { */ public static final String NULL_NS_URI = ""; + /** + * (Start) Definition of DTD doctype. + */ + public static final String XML_DOCTYPE = ""; + /** + * Starts a cdata section. + */ + public static final String CDATA_START = ""; + + /** + * The regex expression of a cdata start section. + */ + public static final String CDATA_START_REGEX = ""; + /** * Tab char */ @@ -119,7 +144,7 @@ public final class XMLConstants { /** * Newline char */ - public static final String CHAR_NEWLINE = "\r\n"; + public static final String CHAR_NEWLINE = "\n"; @@ -207,29 +232,59 @@ public final class XMLConstants { return true; } - static public String escapeAttributeValue(String value) { - int l = value.length(); - StringBuffer result = new StringBuffer(l); - for (int i=0;i') { + result.append(">"); + return true; + } + if (c=='&') { + result.append("&"); + return true; + } + if (c=='\"') { + result.append(""e;"); + return true; + } + if (c=='\'') { + result.append("'"); + return true; + } + return false; + } + + static public String escapeAttributeName(String value) { + // Attribute ::= Name Eq AttValue + int length = value.length(); + StringBuffer result = new StringBuffer(length); + for (int i=0;i') { - result.append(">"); - continue; - } - if (c=='&') { - result.append("&"); - continue; - } - if (c=='\"') { - result.append(""e;"); - continue; - } - if (c=='\'') { - result.append("'"); + } + return result.toString(); + } + + static public String escapeAttributeValue(String value) { + // Reference ::= EntityRef | CharRef + // AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'" + int length = value.length(); + StringBuffer result = new StringBuffer(length); + for (int i=0;i The key class. * @param The value class. */ diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriter.java new file mode 100644 index 0000000..ad45bb7 --- /dev/null +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriter.java @@ -0,0 +1,54 @@ +/* + * 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; + +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.ext.LexicalHandler; + + +/** + * ContentWriter is ContentHandler for writing sax events. + * + * @author Willem Cazander + * @version 1.0 Apr 30, 2013 + */ +public interface ContentWriter extends ContentHandler,LexicalHandler { + + /** + * Starts and ends an element in one call. + * @param uri The uri of the element. + * @param localName The localName of the element. + * @param name The name of the element. + * @param atts The attributes of the element. + * @throws SAXException When IOException is thrown. + */ + void startElementEnd(String uri, String localName, String name,Attributes atts) throws SAXException; + + void comment(String text) throws SAXException; + + void ignorableWhitespace(String text) throws SAXException; + + void characters(String text) throws SAXException; +} diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterConfig.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterConfig.java new file mode 100644 index 0000000..7620ea1 --- /dev/null +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterConfig.java @@ -0,0 +1,38 @@ +/* + * 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; + +/** + * ContentWriterConfig Defines config options for ContentWriter. + * + * @author Willem Cazander + * @version 1.0 May 1, 2013 + */ +public interface ContentWriterConfig { + + String getCharNewLine(); + String getCharTab(); + + String getReplaceCdataStart(); + String getReplaceCdataEnd(); +} diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterHtml.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterHtml.java new file mode 100644 index 0000000..23941cf --- /dev/null +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterHtml.java @@ -0,0 +1,297 @@ +/* + * 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; + +import java.io.Writer; +import java.util.Calendar; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +/** + * ContentWriterHtml writes HTML events as SAX events to XML. + * + * @author Willem Cazander + * @version 1.0 Apr 30, 2013 + */ +public class ContentWriterHtml extends ContentWriterXml { + + public ContentWriterHtml(Writer out,String encoding,String charNewLine,String charTab) { + super(out,encoding,charNewLine,charTab); + } + + public void printDocType(DocType doc) throws SAXException { + startDTD(doc.getName(), doc.getPublicId(), doc.getSystemId()); + } + + public void printHtmlStart(String language) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + if (language!=null) { + atts.addAttribute ("", "lang", "", "", language); + } + printTagStart(Tag.html,atts); + } + + public void printHtmlEnd() throws SAXException { + printTagEnd(Tag.html); + } + + public void printHeadMetaDate() throws SAXException { + Calendar cal = Calendar.getInstance(); + printHeadMeta("date",cal.get(Calendar.YEAR)+"-"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.DAY_OF_MONTH)); + } + + public void printHeadTitle(String title) throws SAXException { + printTagText("title",title); + } + + public void printHeadMetaContentType() throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "http-equiv", "", "", "Content-Type"); + atts.addAttribute ("", "content", "", "", "text/html"); + atts.addAttribute ("", "charset", "", "", this.encoding); + startElementEnd("", "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); + } + + public void printHeadLinkCss(String cssUrl) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "rel", "", "", "stylesheet"); + atts.addAttribute ("", "type", "", "", "text/css"); + atts.addAttribute ("", "title", "", "", "Style"); + atts.addAttribute ("", "href", "", "", cssUrl); + startElementEnd("", "link", "", atts); + } + + public void printScriptInline(String script) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "type", "", "", "text/javascript"); + printTagStart(Tag.script,atts); + comment(script); + printTagEnd(Tag.script); + } + + public void printScriptNoDiv() throws SAXException { + printScriptNoDiv(null); + } + + public void printScriptNoDiv(String text) throws SAXException { + if (text==null) { + text = "JavaScript is disabled on your browser."; + } + printTagStart(Tag.noscript); + printTagStart(Tag.div);characters(text);printTagEnd(Tag.div); + printTagEnd(Tag.noscript); + } + + public void printHrefNamed(String name) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "name", "", "", name); + printTagStart(Tag.a,atts); + comment(" "); + printTagEnd(Tag.a); + } + + public void printHrefTarget(String href,String title,String target) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "href", "", "", href); + atts.addAttribute ("", "target", "", "", target); + printTagStart(Tag.a,atts); + characters(title); + printTagEnd(Tag.a); + } + + public void printHref(String href,String title) throws SAXException { + printHref(href,title,title); + } + + public void printHref(String href,String title,String text) throws SAXException { + printHref(href,title,text,null); + } + + public void printHref(String href,String title,String text,String spanClass) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "href", "", "", href); + if (title!=null) { + atts.addAttribute ("", "title", "", "", title); + } + printTagStart(Tag.a,atts); + if (spanClass!=null) { + atts = new AttributesImpl(); + if (spanClass.length()>0) { + atts.addAttribute ("", "class", "", "", spanClass); + } + printTagStart(Tag.span,atts); + } + characters(text); + if (spanClass!=null) { + printTagEnd(Tag.span); + } + printTagEnd(Tag.a); + } + + + private void printTagText(String tag,String text) throws SAXException { + startElement ("", tag, "", EMPTY_ATTRIBUTES); + characters(text); + endElement ("",tag , ""); + } + + public void printTagText(Tag tag,String text) throws SAXException { + printTagText(tag,text,null); + } + + public void printTagText(Tag tag,String text,String tagClass) throws SAXException { + printTagText(tag,text,tagClass,null); + } + + public void printTagText(Tag tag,String text,String tagClass,String tagId) throws SAXException { + printTagStart(tag,tagClass,tagId); + if (text==null) { + text = " "; + } + characters(text); + printTagEnd(tag); + } + + public void printTagStartEnd(Tag tag) throws SAXException { + printTagStart(tag,null,null); + printTagEnd(tag); + } + + public void printTagStart(Tag tag) throws SAXException { + printTagStart(tag,null,null); + } + + public void printTagStart(Tag tag,String tagClass) throws SAXException { + printTagStart(tag,tagClass,null); + } + + public void printTagStart(Tag tag,String tagClass,String tagId) throws SAXException { + printTagStart(tag,tagClass,tagId,null); + } + + public void printTagStart(Tag tag,String tagClass,String tagId,String typeId) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + if (tagId!=null && tagId.length()>0) { + atts.addAttribute ("", "id", "", "", tagId); + } + if (tagClass!=null && tagClass.length()>0) { + atts.addAttribute ("", "class", "", "", tagClass); + } + if (typeId!=null && typeId.length()>0) { + atts.addAttribute ("", "type", "", "", typeId); + } + printTagStart(tag,atts); + } + + public void printTagStart(Tag tag,Attributes atts) throws SAXException { + startElement ("", tag.name(), "", atts); + } + + public void printTagEnd(Tag tag) throws SAXException { + endElement ("",tag.name() , ""); + } + + public enum Tag { + + /* Deprecated TAGS */ + frameset,frame,noframes,tt,font,dir,center,strike, + big,basefont,acronym,applet,iframe, + + /* HTML 4 TAGS */ + html,head,title,meta,link,base,body,script,style, + + h1,h2,h3,h4,h5,h6, + a,div,span,p,pre,img,hr,br, + b,em,strong,small,noscript, + + ul,li,dl,dt,dd,ol, + table,thead,tfoot,tbody,caption,th,tr,td, + + abbr,address,area,bdo,blockquote, + cite,code,col,colgroup,del,dfn,i,ins, + kbd,legend,map,menu,object,param, + optgroup,q,s,samp,sub,u,var, + + form,fieldset,input,option, + label,button,select,textarea, + + /* HTML 5 TAGS */ + canvas,audio,video,source,embed,track, + datalist,keygen,output, + article,aside,bdi,command,details,dialog,summary, + figure,figcaption,footer,header,hgroup,mark,meter, + nav,progress,ruby,rt,rp,section,time,wbr + } + + private final static String DOCTYPE_NAME = "HTML PUBLIC"; + public enum DocType { + /* Order from worst to better. */ + HTML_5("html","",""), + + HTML_4_FRAMESET(DOCTYPE_NAME,"\"-//W3C//DTD HTML 4.01 Frameset//EN\"","http://www.w3.org/TR/html4/frameset.dtd"), + HTML_4_TRANSITIONAL(DOCTYPE_NAME,"\"-//W3C//DTD HTML 4.01 Transitional//EN\"","http://www.w3.org/TR/html4/loose.dtd"), + HTML_4_STRICT(DOCTYPE_NAME,"\"-//W3C//DTD HTML 4.01//EN\"","http://www.w3.org/TR/html4/strict.dtd"), + + XHTML_1_FRAMESET(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Frameset//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"), + XHTML_1_TRANSITIONAL(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Transitional//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"), + XHTML_1_STRICT(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.0 Strict//EN\"","http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"), + + XHTML_11(DOCTYPE_NAME,"\"-//W3C//DTD XHTML 1.1//EN\"","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"); + + private final String name; + private final String publicId; + private final String systemId; + private DocType(String name, String publicId, String systemId) { + this.name=name; + this.publicId=publicId; + this.systemId=systemId; + } + /** + * @return the name + */ + public String getName() { + return name; + } + /** + * @return the publicId + */ + public String getPublicId() { + return publicId; + } + /** + * @return the systemId + */ + public String getSystemId() { + return systemId; + } + } +} diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/XMLWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterXml.java similarity index 65% rename from x4o-driver/src/main/java/org/x4o/xml/io/sax/XMLWriter.java rename to x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterXml.java index bea3c7b..884020b 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/XMLWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterXml.java @@ -32,23 +32,24 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Stack; import org.x4o.xml.io.XMLConstants; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; -import org.xml.sax.ext.DefaultHandler2; - +import org.xml.sax.helpers.AttributesImpl; /** - * Writes SAX event to XML. + * ContentWriterXml writes SAX content handler events to XML. * * @author Willem Cazander - * @version 1.0 17/04/2005 + * @version 1.0 Apr 17, 2005 */ -public class XMLWriter extends DefaultHandler2 { +public class ContentWriterXml implements ContentWriter { - private String encoding = null; + public final Attributes EMPTY_ATTRIBUTES = new AttributesImpl(); + protected String encoding = null; private String charNewline = null; private String charTab = null; private Writer out = null; @@ -56,13 +57,16 @@ public class XMLWriter extends DefaultHandler2 { private Map prefixMapping = null; private List printedMappings = null; private StringBuffer startElement = null; - private boolean printedReturn = false; + private boolean printReturn = false; + private String lastElement = null; + private boolean printCDATA = false; + private Stack elements = null; /** * Creates XmlWriter which prints to the Writer interface. * @param out The writer to print the xml to. */ - public XMLWriter(Writer out,String encoding,String charNewLine,String charTab) { + public ContentWriterXml(Writer out,String encoding,String charNewLine,String charTab) { if (out==null) { throw new NullPointerException("Can't write on null writer."); } @@ -81,13 +85,14 @@ public class XMLWriter extends DefaultHandler2 { this.charTab = charTab; prefixMapping = new HashMap(15); printedMappings = new ArrayList(15); + elements = new Stack(); } /** * Creates XmlWriter which prints to the Writer interface. * @param out The writer to print the xml to. */ - public XMLWriter(Writer out,String encoding) { + public ContentWriterXml(Writer out,String encoding) { this(out,encoding,null,null); } @@ -96,7 +101,7 @@ public class XMLWriter extends DefaultHandler2 { * @param out The OutputStream to write to. * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed. */ - public XMLWriter(OutputStream out,String encoding) throws UnsupportedEncodingException { + public ContentWriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException { this(new OutputStreamWriter(out, encoding),encoding); } @@ -104,7 +109,7 @@ public class XMLWriter extends DefaultHandler2 { * Creates XmlWriter which prints to the Writer interface. * @param out The writer to print the xml to. */ - public XMLWriter(Writer out) { + public ContentWriterXml(Writer out) { this(out,null); } @@ -113,7 +118,7 @@ public class XMLWriter extends DefaultHandler2 { * @param out The OutputStream to write to. * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed. */ - public XMLWriter(OutputStream out) throws UnsupportedEncodingException { + public ContentWriterXml(OutputStream out) throws UnsupportedEncodingException { this(new OutputStreamWriter(out, XMLConstants.XML_DEFAULT_ENCODING),XMLConstants.XML_DEFAULT_ENCODING); } @@ -125,14 +130,29 @@ public class XMLWriter extends DefaultHandler2 { * @param charTab The tab char. * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed. */ - public XMLWriter(OutputStream out,String encoding,String charNewLine,String charTab) throws UnsupportedEncodingException { + public ContentWriterXml(OutputStream out,String encoding,String charNewLine,String charTab) throws UnsupportedEncodingException { this(new OutputStreamWriter(out, encoding),encoding,charNewLine,charTab); } + // TODO: check location of this. (add to api?) + public void closeWriter() throws IOException { + if (out==null) { + return; + } + out.close(); + } + + public void closeWriterSafe() { + try { + closeWriter(); + } catch (IOException e) { + e.getMessage(); // discard exception + } + } + /** * @see org.xml.sax.ContentHandler#startDocument() */ - @Override public void startDocument() throws SAXException { indent = 0; write(XMLConstants.getDocumentDeclaration(encoding)); @@ -141,9 +161,20 @@ public class XMLWriter extends DefaultHandler2 { /** * @see org.xml.sax.ContentHandler#endDocument() */ - @Override public void endDocument() throws SAXException { writeFlush(); + if (elements.size()>0) { + throw new SAXException("Invalid xml still have "+elements.size()+" elements open."); + } + } + + /** + * Starts and end then element. + * @see org.x4o.xml.io.sax.ContentWriter#startElementEnd(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + */ + public void startElementEnd(String uri, String localName, String name,Attributes atts) throws SAXException { + startElement(uri,localName,name,atts); + endElement(uri, localName, name); } /** @@ -153,31 +184,31 @@ public class XMLWriter extends DefaultHandler2 { * @param atts The attributes of the xml tag. * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ - @Override public void startElement(String uri, String localName, String name,Attributes atts) throws SAXException { - if (startElement!=null) { - write(startElement.toString()); - startElement=null; + if (localName==null) { + localName = "null"; // mmm rm ? } + if (XMLConstants.isNameString(localName)==false) { + throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'"); + } + autoCloseStartElement(); startElement = new StringBuffer(200); - - if (printedReturn==false) { - startElement.append(charNewline); - } - printedReturn=false; - + startElement.append(charNewline); for (int i = 0; i < indent; i++) { startElement.append(charTab); } startElement.append(XMLConstants.TAG_OPEN); - if (localName==null) { - localName = "null"; - } - if (XMLConstants.isNameString(localName)==false) { - throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'"); - } - + startElementTag(uri,localName); + startElementNamespace(uri); + startElementAttributes(atts); + startElement.append(XMLConstants.TAG_CLOSE); + indent++; + lastElement = localName; + elements.push(localName); + } + + public void startElementTag(String uri,String localName) throws SAXException { if (XMLConstants.NULL_NS_URI.equals(uri) | uri==null) { startElement.append(localName); } else { @@ -191,7 +222,9 @@ public class XMLWriter extends DefaultHandler2 { } startElement.append(localName); } - + } + + public void startElementNamespace(String uri) throws SAXException { if ((uri!=null & XMLConstants.NULL_NS_URI.equals(uri)==false) && printedMappings.contains(uri)==false) { String prefix = prefixMapping.get(uri); if (prefix==null) { @@ -209,42 +242,50 @@ public class XMLWriter extends DefaultHandler2 { startElement.append(uri); startElement.append('"'); - boolean first = true; - for (String uri2:prefixMapping.keySet()) { - if (printedMappings.contains(uri2)==false) { - prefix = prefixMapping.get(uri2); - if (prefix==null) { - throw new SAXException("preFixUri: "+uri+" is not started."); - } - printedMappings.add(uri2); - - if (first) { - startElement.append(charNewline); - first = false; - } - - startElement.append(' '); - startElement.append(XMLConstants.XMLNS_ATTRIBUTE); - if ("".equals(prefix)==false) { - startElement.append(XMLConstants.XMLNS_ASSIGN); - startElement.append(prefix); - } - startElement.append("=\""); - startElement.append(uri2); - startElement.append('"'); - startElement.append(charNewline); + startElementNamespaceAll(uri); + } + } + + public void startElementNamespaceAll(String uri) throws SAXException { + String prefix = null; + boolean first = true; + for (String uri2:prefixMapping.keySet()) { + if (printedMappings.contains(uri2)==false) { + prefix = prefixMapping.get(uri2); + if (prefix==null) { + throw new SAXException("preFixUri: "+uri+" is not started."); } + printedMappings.add(uri2); + + if (first) { + startElement.append(charNewline); + first = false; + } + + startElement.append(' '); + startElement.append(XMLConstants.XMLNS_ATTRIBUTE); + if ("".equals(prefix)==false) { + startElement.append(XMLConstants.XMLNS_ASSIGN); + startElement.append(prefix); + } + startElement.append("=\""); + startElement.append(uri2); + startElement.append('"'); + startElement.append(charNewline); } } - + } + + private void startElementAttributes(Attributes atts) throws SAXException { for (int i=0;i0 && elements.peek().equals((localName))==false) { + throw new SAXException("Unexpected end tag: "+localName+" should be: "+elements.peek()); + } + elements.pop(); + if (startElement!=null) { String tag = startElement.toString(); write(tag.substring(0,tag.length()-1));// rm normal close @@ -278,13 +322,13 @@ public class XMLWriter extends DefaultHandler2 { return; } - if (printedReturn==false) { - write(charNewline); - } - printedReturn=false; indent--; - writeIndent(); - + if (printReturn || !localName.equals(lastElement)) { + write(charNewline); + writeIndent(); + } else { + printReturn = true; + } if (localName==null) { localName = "null"; } @@ -312,7 +356,6 @@ public class XMLWriter extends DefaultHandler2 { * @param uri The xml namespace uri to add the prefix for. * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String) */ - @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { prefixMapping.put(uri, prefix); } @@ -321,7 +364,6 @@ public class XMLWriter extends DefaultHandler2 { * @param prefix The xml prefix of this xml namespace uri to be ended. * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String) */ - @Override public void endPrefixMapping(String prefix) throws SAXException { Set> s = prefixMapping.entrySet(); String uri = null; @@ -348,19 +390,35 @@ public class XMLWriter extends DefaultHandler2 { * @throws SAXException When IOException has happend while printing. * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ - @Override public void characters(char[] ch, int start, int length) throws SAXException { - if (startElement!=null) { - write(startElement.toString()); - startElement=null; + characters(new String(ch,start,length)); + } + + /** + * @see org.x4o.xml.io.sax.ContentWriter#characters(java.lang.String) + */ + public void characters(String text) throws SAXException { + if (text==null) { + return; } - for (int i=start;i<(start+length);i++) { - char c = ch[i]; - write(c); - if (c=='\n') { - printedReturn=true; - } + autoCloseStartElement(); + checkPrintedReturn(text); + if (printCDATA) { + text = XMLConstants.escapeCharactersCdata(text,"",""); + } else { + text = XMLConstants.escapeCharacters(text); } + write(text); + } + + // move or remove ? + public void charactersRaw(String text) throws SAXException { + if (text==null) { + return; + } + autoCloseStartElement(); + checkPrintedReturn(text); + write(text); } /** @@ -372,13 +430,19 @@ public class XMLWriter extends DefaultHandler2 { * @throws SAXException When IOException has happend while printing. * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int) */ - @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { - if (startElement!=null) { - write(startElement.toString()); - startElement=null; + ignorableWhitespace(new String(ch,start,length)); + } + + /** + * @see org.x4o.xml.io.sax.ContentWriter#ignorableWhitespace(java.lang.String) + */ + public void ignorableWhitespace(String text) throws SAXException { + if (text==null) { + return; } - write(ch, start, length); + autoCloseStartElement(); + write(text); // TODO: check chars } /** @@ -388,7 +452,6 @@ public class XMLWriter extends DefaultHandler2 { * @param target The target. * @param data The data. */ - @Override public void processingInstruction(String target, String data) throws SAXException { writeIndent(); write(XMLConstants.PROCESS_START); @@ -406,7 +469,6 @@ public class XMLWriter extends DefaultHandler2 { * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator) * @param locator The DocumentLocator to set. */ - @Override public void setDocumentLocator(Locator locator) { } @@ -416,7 +478,6 @@ public class XMLWriter extends DefaultHandler2 { * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String) * @param name The name of the skipped entity. */ - @Override public void skippedEntity(String name) throws SAXException { // is for validating parser support, so not needed in xml writing. } @@ -430,24 +491,106 @@ public class XMLWriter extends DefaultHandler2 { * @throws SAXException When IOException has happend while printing. * @see org.xml.sax.ext.DefaultHandler2#comment(char[], int, int) */ - @Override public void comment(char[] ch, int start, int length) throws SAXException { + comment(new String(ch,start,length)); + } + + /** + * @see org.x4o.xml.io.sax.ContentWriter#comment(java.lang.String) + */ + public void comment(String text) throws SAXException { + if (text==null) { + return; + } + autoCloseStartElement(); + checkPrintedReturn(text); + write(charNewline); writeIndent(); write(XMLConstants.COMMENT_START); - - /// mmm todo improve a bit - for (int i=start;i<(start+length);i++) { - char c = ch[i]; - if (c=='\n') { - write(c); - writeIndent(); - continue; - } - write(c); - } + write(" "); + write(XMLConstants.escapeCharactersComment(text,charTab,indent)); + write(" "); write(XMLConstants.COMMENT_END); + printReturn = true; + } + + /** + * @see org.xml.sax.ext.LexicalHandler#startCDATA() + */ + public void startCDATA() throws SAXException { + autoCloseStartElement(); + write(XMLConstants.CDATA_START); + printCDATA = true; + } + + /** + * @see org.xml.sax.ext.LexicalHandler#endCDATA() + */ + public void endCDATA() throws SAXException { + write(XMLConstants.CDATA_END); + printCDATA = false; } + /** + * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String) + */ + public void startDTD(String name, String publicId, String systemId) throws SAXException { + write(XMLConstants.XML_DOCTYPE); + write(" "); + write(name); + if (publicId!=null) { + write(" "); + write(publicId); + } + if (systemId!=null) { + write(" \""); + write(systemId); + write("\""); + } + write(XMLConstants.TAG_CLOSE); + } + + /** + * @see org.xml.sax.ext.LexicalHandler#endDTD() + */ + public void endDTD() throws SAXException { + writeFlush(); + } + + /** + * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String) + */ + public void startEntity(String arg0) throws SAXException { + } + + /** + * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String) + */ + public void endEntity(String arg0) throws SAXException { + } + + + + private void checkPrintedReturn(String value) { + if (value.indexOf('\n')>0) { + printReturn = true; + } else { + printReturn = false; + } + } + + /** + * Auto close the start element if working in printing event. + * @throws IOException When prints gives exception. + */ + private void autoCloseStartElement() throws SAXException { + if (startElement==null) { + return; + } + write(startElement.toString()); + startElement=null; + } + /** * Indent the output writer with tabs by indent count. * @throws IOException When prints gives exception. @@ -474,14 +617,6 @@ public class XMLWriter extends DefaultHandler2 { } } - private void write(char[] ch, int start, int length) throws SAXException { - try { - out.write(ch,start,length); - } catch (IOException e) { - throw new SAXException(e); - } - } - private void write(char c) throws SAXException { try { out.write(c); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java index 1d4cfe7..9c09bd7 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java @@ -48,7 +48,6 @@ import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhaseException; import org.x4o.xml.lang.phase.X4OPhaseListener; import org.xml.sax.SAXException; -import org.xml.sax.ext.DefaultHandler2; import org.xml.sax.helpers.AttributesImpl; /** @@ -62,14 +61,14 @@ public class X4ODebugWriter { static public final String DEBUG_URI = "http://language.x4o.org/xml/ns/debug-output"; - protected DefaultHandler2 debugWriter = null; + protected ContentWriter contentWriter = null; - public X4ODebugWriter(DefaultHandler2 debugWriter) { - this.debugWriter=debugWriter; + public X4ODebugWriter(ContentWriter debugWriter) { + this.contentWriter=debugWriter; } - public DefaultHandler2 getDebugWriter() { - return debugWriter; + public ContentWriter getContentWriter() { + return contentWriter; } public X4OPhaseListener createDebugX4OPhaseListener() { @@ -91,7 +90,7 @@ public class X4ODebugWriter { if (elementLanguage!=null) { atts.addAttribute("", "language","","", elementLanguage.getLanguage().getLanguageName()); } - debugWriter.startElement (DEBUG_URI, "executePhase", "", atts); + contentWriter.startElement (DEBUG_URI, "executePhase", "", atts); } catch (SAXException e) { throw new X4OPhaseException(phase,e); } @@ -104,10 +103,10 @@ public class X4ODebugWriter { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "id", "", "", phase.getId()); atts.addAttribute ("", "speed", "", "", (stopTime-startTime)+" ms"); - debugWriter.startElement (DEBUG_URI, "executePhaseDone", "", atts); - debugWriter.endElement (DEBUG_URI, "executePhaseDone" , ""); + contentWriter.startElement (DEBUG_URI, "executePhaseDone", "", atts); + contentWriter.endElement (DEBUG_URI, "executePhaseDone" , ""); - debugWriter.endElement (DEBUG_URI, "executePhase" , ""); + contentWriter.endElement (DEBUG_URI, "executePhase" , ""); } catch (SAXException e) { throw new X4OPhaseException(phase,e); } @@ -117,7 +116,7 @@ public class X4ODebugWriter { public void debugLanguageProperties(X4OLanguageContext ec) throws ElementException { try { AttributesImpl atts = new AttributesImpl(); - debugWriter.startElement (DEBUG_URI, "X4OLanguageProperties", "", atts); + contentWriter.startElement (DEBUG_URI, "X4OLanguageProperties", "", atts); for (X4OLanguageProperty p:X4OLanguageProperty.values()) { Object value = ec.getLanguageProperty(p); if (value==null) { @@ -126,10 +125,10 @@ public class X4ODebugWriter { AttributesImpl atts2 = new AttributesImpl(); atts2.addAttribute ("", "uri", "", "", p.toUri()); atts2.addAttribute ("", "value", "", "", value.toString()); - debugWriter.startElement (DEBUG_URI, "X4OLanguageProperty", "", atts2); - debugWriter.endElement(DEBUG_URI, "X4OLanguageProperty", ""); + contentWriter.startElement (DEBUG_URI, "X4OLanguageProperty", "", atts2); + contentWriter.endElement(DEBUG_URI, "X4OLanguageProperty", ""); } - debugWriter.endElement(DEBUG_URI, "X4OLanguageProperties", ""); + contentWriter.endElement(DEBUG_URI, "X4OLanguageProperties", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -138,7 +137,7 @@ public class X4ODebugWriter { public void debugLanguageDefaultClasses(X4OLanguageContext ec) throws ElementException { try { AttributesImpl atts = new AttributesImpl(); - debugWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClasses", "", atts); + contentWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClasses", "", atts); X4OLanguageConfiguration conf = ec.getLanguage().getLanguageConfiguration(); debugLanguageDefaultClass("getDefaultElementNamespaceContext",conf.getDefaultElementNamespaceContext()); @@ -155,7 +154,7 @@ public class X4ODebugWriter { debugLanguageDefaultClass("getDefaultElementObjectPropertyValue",conf.getDefaultElementObjectPropertyValue()); debugLanguageDefaultClass("getDefaultElementAttributeHandlerComparator",conf.getDefaultElementAttributeHandlerComparator()); - debugWriter.endElement(DEBUG_URI, "X4OLanguageDefaultClasses", ""); + contentWriter.endElement(DEBUG_URI, "X4OLanguageDefaultClasses", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -165,20 +164,20 @@ public class X4ODebugWriter { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "name", "", "", name); atts.addAttribute ("", "className", "", "", clazz.getName()); - debugWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClass", "", atts); - debugWriter.endElement(DEBUG_URI, "X4OLanguageDefaultClass", ""); + contentWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClass", "", atts); + contentWriter.endElement(DEBUG_URI, "X4OLanguageDefaultClass", ""); } public void debugPhaseOrder(List phases) throws X4OPhaseException { X4OPhase phase = null; try { AttributesImpl atts = new AttributesImpl(); - debugWriter.startElement (DEBUG_URI, "phaseOrder", "", atts); + contentWriter.startElement (DEBUG_URI, "phaseOrder", "", atts); for (X4OPhase phase2:phases) { phase = phase2; debugPhase(phase2); } - debugWriter.endElement(DEBUG_URI, "phaseOrder", ""); + contentWriter.endElement(DEBUG_URI, "phaseOrder", ""); } catch (SAXException e) { // fall back... if (phase==null) { @@ -198,14 +197,14 @@ public class X4ODebugWriter { atts.addAttribute ("", "runOnce", "", "", phase.isRunOnce()+""); atts.addAttribute ("", "listenersSize", "", "", phase.getPhaseListeners().size()+""); - debugWriter.startElement (DEBUG_URI, "phase", "", atts); + contentWriter.startElement (DEBUG_URI, "phase", "", atts); for (X4OPhaseListener l:phase.getPhaseListeners()) { atts = new AttributesImpl(); atts.addAttribute ("", "className", "", "", l.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "X4OPhaseListener", "", atts); - debugWriter.endElement(DEBUG_URI, "X4OPhaseListener", ""); + contentWriter.startElement (DEBUG_URI, "X4OPhaseListener", "", atts); + contentWriter.endElement(DEBUG_URI, "X4OPhaseListener", ""); } - debugWriter.endElement(DEBUG_URI, "phase", ""); + contentWriter.endElement(DEBUG_URI, "phase", ""); } catch (SAXException e) { throw new X4OPhaseException(phase,e); } @@ -214,7 +213,7 @@ public class X4ODebugWriter { public void debugElementLanguageModules(X4OLanguageContext elementLanguage) throws ElementException { try { AttributesImpl attsEmpty = new AttributesImpl(); - debugWriter.startElement (DEBUG_URI, "ElementLanguageModules", "", attsEmpty); + contentWriter.startElement (DEBUG_URI, "ElementLanguageModules", "", attsEmpty); for (X4OLanguageModule module:elementLanguage.getLanguage().getLanguageModules()) { AttributesImpl atts = new AttributesImpl(); @@ -227,7 +226,7 @@ public class X4ODebugWriter { } else { atts.addAttribute ("", "elementLanguageModuleLoaderClassName", "", "", module.getLanguageModuleLoader().getClass().getName()); } - debugWriter.startElement (DEBUG_URI, "ElementLanguageModule", "", atts); + contentWriter.startElement (DEBUG_URI, "ElementLanguageModule", "", atts); //module.getElementAttributeHandlers(); //module.getElementBindingHandlers(); @@ -243,14 +242,14 @@ public class X4ODebugWriter { atts.addAttribute ("", "attributeName", "", "", p.getAttributeName()); atts.addAttribute ("", "description", "", "", p.getDescription()); atts.addAttribute ("", "className", "", "", p.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "elementAttributeHandler", "", atts); + contentWriter.startElement (DEBUG_URI, "elementAttributeHandler", "", atts); for (String para:p.getNextAttributes()) { atts = new AttributesImpl(); atts.addAttribute ("", "attributeName", "", "", para); - debugWriter.startElement (DEBUG_URI, "nextAttribute", "", atts); - debugWriter.endElement(DEBUG_URI, "nextAttribute", ""); + contentWriter.startElement (DEBUG_URI, "nextAttribute", "", atts); + contentWriter.endElement(DEBUG_URI, "nextAttribute", ""); } - debugWriter.endElement(DEBUG_URI, "elementAttributeHandler", ""); + contentWriter.endElement(DEBUG_URI, "elementAttributeHandler", ""); } for (ElementInterface elementInterface:module.getElementInterfaces()) { @@ -259,10 +258,10 @@ public class X4ODebugWriter { atts.addAttribute ("", "description", "", "", elementInterface.getDescription()); atts.addAttribute ("", "interfaceClass", "", "", elementInterface.getInterfaceClass().getName()); - debugWriter.startElement (DEBUG_URI, "elementInterface", "", atts); + contentWriter.startElement (DEBUG_URI, "elementInterface", "", atts); debugElementBindingHandler(elementInterface.getElementBindingHandlers()); debugElementClassBase(elementInterface); - debugWriter.endElement(DEBUG_URI, "elementInterface", ""); + contentWriter.endElement(DEBUG_URI, "elementInterface", ""); } for (ElementNamespaceContext enc:module.getElementNamespaceContexts()) { @@ -273,7 +272,7 @@ public class X4ODebugWriter { atts.addAttribute ("", "schemaResource", "", "", enc.getSchemaResource()); atts.addAttribute ("", "className", "", "", enc.getClass().getName()); - debugWriter.startElement (DEBUG_URI, ElementNamespaceContext.class.getSimpleName(), "", atts); + contentWriter.startElement (DEBUG_URI, ElementNamespaceContext.class.getSimpleName(), "", atts); for (ElementClass ec:enc.getElementClasses()) { debugElementClass(ec); } @@ -281,16 +280,16 @@ public class X4ODebugWriter { ElementNamespaceInstanceProvider eip = enc.getElementNamespaceInstanceProvider(); atts = new AttributesImpl(); atts.addAttribute ("", "className", "", "", eip.getClass().getName()); - debugWriter.startElement (DEBUG_URI, ElementNamespaceInstanceProvider.class.getSimpleName(), "", atts); - debugWriter.endElement(DEBUG_URI, ElementNamespaceInstanceProvider.class.getSimpleName(), ""); + contentWriter.startElement (DEBUG_URI, ElementNamespaceInstanceProvider.class.getSimpleName(), "", atts); + contentWriter.endElement(DEBUG_URI, ElementNamespaceInstanceProvider.class.getSimpleName(), ""); - debugWriter.endElement(DEBUG_URI, ElementNamespaceContext.class.getSimpleName(), ""); + contentWriter.endElement(DEBUG_URI, ElementNamespaceContext.class.getSimpleName(), ""); } - debugWriter.endElement(DEBUG_URI, "ElementLanguageModule", ""); + contentWriter.endElement(DEBUG_URI, "ElementLanguageModule", ""); } - debugWriter.endElement(DEBUG_URI, "ElementLanguageModules", ""); + contentWriter.endElement(DEBUG_URI, "ElementLanguageModules", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -343,15 +342,15 @@ public class X4ODebugWriter { atts.addAttribute ("", "exceptionWhileGetingBeanValues", "", "", e.getMessage()); } - debugWriter.startElement (DEBUG_URI, "elementObject", "", atts2); - debugWriter.endElement(DEBUG_URI, "elementObject", ""); + contentWriter.startElement (DEBUG_URI, "elementObject", "", atts2); + contentWriter.endElement(DEBUG_URI, "elementObject", ""); } StringBuffer elementPath = getElementPath(element,new StringBuffer()); atts.addAttribute ("", "elementPath", "", "", elementPath.toString()); - debugWriter.startElement (DEBUG_URI, "element", "", atts); - debugWriter.endElement(DEBUG_URI, "element", ""); + contentWriter.startElement (DEBUG_URI, "element", "", atts); + contentWriter.endElement(DEBUG_URI, "element", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -379,10 +378,10 @@ public class X4ODebugWriter { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "class", "", "", clazz.getName()+""); try { - debugWriter.startElement (DEBUG_URI, "message", "", atts); + contentWriter.startElement (DEBUG_URI, "message", "", atts); char[] msg = message.toCharArray(); - debugWriter.characters(msg,0,msg.length); - debugWriter.endElement(DEBUG_URI, "message", ""); + contentWriter.characters(msg,0,msg.length); + contentWriter.endElement(DEBUG_URI, "message", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -396,9 +395,9 @@ public class X4ODebugWriter { atts.addAttribute ("", "description", "", "", ec.getDescription()); atts.addAttribute ("", "className", "", "", ec.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "runElementConfigurator", "", atts); + contentWriter.startElement (DEBUG_URI, "runElementConfigurator", "", atts); debugElement(element); - debugWriter.endElement(DEBUG_URI, "runElementConfigurator", ""); + contentWriter.endElement(DEBUG_URI, "runElementConfigurator", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -414,9 +413,9 @@ public class X4ODebugWriter { atts.addAttribute ("", "parentClass", "", "", element.getParent().getElementObject().getClass()+""); atts.addAttribute ("", "childClass", "", "", element.getElementObject().getClass()+""); - debugWriter.startElement (DEBUG_URI, "doBind", "", atts); + contentWriter.startElement (DEBUG_URI, "doBind", "", atts); debugElement(element); - debugWriter.endElement(DEBUG_URI, "doBind", ""); + contentWriter.endElement(DEBUG_URI, "doBind", ""); } catch (SAXException e) { throw new ElementException(e); } @@ -429,8 +428,8 @@ public class X4ODebugWriter { atts.addAttribute ("", "languageVersion", "", "", elementLanguage.getLanguage().getLanguageVersion()); atts.addAttribute ("", "className", "", "", elementLanguage.getClass().getName()+""); atts.addAttribute ("", "currentX4OPhase", "", "", elementLanguage.getCurrentPhase().getId()); - debugWriter.startElement (DEBUG_URI, "printElementLanguage", "", atts); - debugWriter.endElement(DEBUG_URI, "printElementLanguage", ""); + contentWriter.startElement (DEBUG_URI, "printElementLanguage", "", atts); + contentWriter.endElement(DEBUG_URI, "printElementLanguage", ""); } private void debugElementClass(ElementClass elementClass) throws SAXException { @@ -441,26 +440,26 @@ public class X4ODebugWriter { atts.addAttribute ("", "description", "", "", elementClass.getDescription()); atts.addAttribute ("", "objectClassName", "", "", ""+elementClass.getObjectClass()); atts.addAttribute ("", "className", "", "", elementClass.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "elementClass", "", atts); + contentWriter.startElement (DEBUG_URI, "elementClass", "", atts); for (String phase:elementClass.getSkipPhases()) { atts = new AttributesImpl(); atts.addAttribute ("", "phase", "", "", ""+phase); - debugWriter.startElement(DEBUG_URI, "elementSkipPhase", "", atts); - debugWriter.endElement(DEBUG_URI, "elementSkipPhase", ""); + contentWriter.startElement(DEBUG_URI, "elementSkipPhase", "", atts); + contentWriter.endElement(DEBUG_URI, "elementSkipPhase", ""); } debugElementConfigurator(elementClass.getElementConfigurators()); debugElementClassBase(elementClass); - debugWriter.endElement(DEBUG_URI, "elementClass", ""); + contentWriter.endElement(DEBUG_URI, "elementClass", ""); } private void debugElementClassBase(ElementClassBase elementClassBase) throws SAXException { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "description", "", "", elementClassBase.getDescription()); atts.addAttribute ("", "className", "", "", elementClassBase.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "elementClassBase", "", atts); + contentWriter.startElement (DEBUG_URI, "elementClassBase", "", atts); debugElementConfigurator(elementClassBase.getElementConfigurators()); debugElementClassAttributes(elementClassBase.getElementClassAttributes()); - debugWriter.endElement(DEBUG_URI, "elementClassBase", ""); + contentWriter.endElement(DEBUG_URI, "elementClassBase", ""); } private void debugElementConfigurator(List elementConfigurators) throws SAXException { @@ -468,8 +467,8 @@ public class X4ODebugWriter { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "description", "", "", elementConfigurator.getDescription()); atts.addAttribute ("", "className", "", "", elementConfigurator.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "elementConfigurator", "", atts); - debugWriter.endElement(DEBUG_URI, "elementConfigurator", ""); + contentWriter.startElement (DEBUG_URI, "elementConfigurator", "", atts); + contentWriter.endElement(DEBUG_URI, "elementConfigurator", ""); } } @@ -478,8 +477,8 @@ public class X4ODebugWriter { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "description", "", "", elementConfigurator.getDescription()); atts.addAttribute ("", "className", "", "", elementConfigurator.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "elementConfiguratorGlobal", "", atts); - debugWriter.endElement(DEBUG_URI, "elementConfiguratorGlobal", ""); + contentWriter.startElement (DEBUG_URI, "elementConfiguratorGlobal", "", atts); + contentWriter.endElement(DEBUG_URI, "elementConfiguratorGlobal", ""); } } @@ -494,17 +493,17 @@ public class X4ODebugWriter { atts.addAttribute ("", "runConverters", "", "", ""+elementClassAttribute.getRunConverters()); //atts.addAttribute ("", "runInterfaces", "", "", ""+elementClassAttribute.getRunInterfaces()); atts.addAttribute ("", "runResolveEL", "", "", ""+elementClassAttribute.getRunResolveEL()); - debugWriter.startElement(DEBUG_URI, "elementClassAttribute", "", atts); + contentWriter.startElement(DEBUG_URI, "elementClassAttribute", "", atts); if (elementClassAttribute.getObjectConverter()!=null) { debugObjectConverter(elementClassAttribute.getObjectConverter()); } for (String alias:elementClassAttribute.getAttributeAliases()) { atts = new AttributesImpl(); atts.addAttribute ("", "name", "", "", ""+alias); - debugWriter.startElement(DEBUG_URI, "attributeAlias", "", atts); - debugWriter.endElement(DEBUG_URI, "attributeAlias", ""); + contentWriter.startElement(DEBUG_URI, "attributeAlias", "", atts); + contentWriter.endElement(DEBUG_URI, "attributeAlias", ""); } - debugWriter.endElement(DEBUG_URI, "elementClassAttribute", ""); + contentWriter.endElement(DEBUG_URI, "elementClassAttribute", ""); } } @@ -513,8 +512,8 @@ public class X4ODebugWriter { atts.addAttribute ("", "objectClassTo", "", "", objectConverter.getObjectClassTo().getName()); atts.addAttribute ("", "objectClassBack", "", "", objectConverter.getObjectClassBack().getName()); atts.addAttribute ("", "className", "", "", objectConverter.getClass().getName()); - debugWriter.startElement (DEBUG_URI, "objectConverter", "", atts); - debugWriter.endElement(DEBUG_URI, "objectConverter", ""); + contentWriter.startElement (DEBUG_URI, "objectConverter", "", atts); + contentWriter.endElement(DEBUG_URI, "objectConverter", ""); } private void debugElementBindingHandler(List elementBindingHandlers) throws SAXException { @@ -523,16 +522,16 @@ public class X4ODebugWriter { atts.addAttribute ("", "className", "", "", bind.getClass().getName()); atts.addAttribute ("", "description", "", "", bind.getDescription()); atts.addAttribute ("", "bindParentClass", "", "", bind.getBindParentClass().toString()); - debugWriter.startElement (DEBUG_URI, "elementBindingHandler", "", atts); + contentWriter.startElement (DEBUG_URI, "elementBindingHandler", "", atts); for (Class clazz:bind.getBindChildClasses()) { AttributesImpl atts2 = new AttributesImpl(); atts2.addAttribute ("", "className", "", "", clazz.getName()); - debugWriter.startElement (DEBUG_URI, "elementBindingHandlerChildClass", "", atts2); - debugWriter.endElement (DEBUG_URI, "elementBindingHandlerChildClass", ""); + contentWriter.startElement (DEBUG_URI, "elementBindingHandlerChildClass", "", atts2); + contentWriter.endElement (DEBUG_URI, "elementBindingHandlerChildClass", ""); } - debugWriter.endElement(DEBUG_URI, "elementBindingHandler", ""); + contentWriter.endElement(DEBUG_URI, "elementBindingHandler", ""); } } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java index a0cd3c9..0dfc783 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java @@ -41,7 +41,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * This class handels all the X4O tags. + * X4OTagHandler Gets all SAX content handler events and converts to x4o element tree. * * @author Willem Cazander * @version 1.0 Aug 20, 2005 diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageProperty.java b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageProperty.java index daeec0a..81411e3 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageProperty.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageProperty.java @@ -39,7 +39,7 @@ import org.xml.sax.InputSource; import org.xml.sax.ext.DefaultHandler2; /** - * X4OLanguageProperty holds the language parser properties keys + * X4OLanguageProperty holds the language connection properties keys * * @author Willem Cazander * @version 1.0 6 Aug 2012 @@ -56,7 +56,7 @@ public enum X4OLanguageProperty { - /** The input stream to parse, note is skipped when object is set. */ + /** The input stream to parse, note is skipped when source is set. */ READER_INPUT_STREAM(IO.READER,"reader/input/stream",InputStream.class), /** When set it overrides automatic encoding detection of sax parser. */ @@ -257,7 +257,7 @@ public enum X4OLanguageProperty { * Returns the uri defined by this property. * @return The uri defined by this property. */ - public String toUri() { + public final String toUri() { return uriName; } @@ -265,7 +265,7 @@ public enum X4OLanguageProperty { * Returns the default value for this property. * @return The default value for this property. */ - public Object getDefaultValue() { + public final Object getDefaultValue() { return defaultValue; } @@ -275,7 +275,7 @@ public enum X4OLanguageProperty { * @param value The object to check. * @return Returns true when Object value is allowed to be set. */ - public boolean isValueValid(Object value) { + public final boolean isValueValid(Object value) { if (LANGUAGE_NAME.equals(this) | LANGUAGE_VERSION.equals(this)) { return false; // read only are not valid to set. } @@ -297,7 +297,7 @@ public enum X4OLanguageProperty { * @return Return the property for the given uri. * @throws IllegalArgumentException when uri is not found. */ - static public X4OLanguageProperty valueByUri(String uri) { + public static final X4OLanguageProperty valueByUri(String uri) { if (uri==null) { throw new NullPointerException("Can't search null uri."); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java index 0f115da..61a478d 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java @@ -45,6 +45,7 @@ import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.io.sax.ContentWriter; import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.io.sax.X4OEntityResolver; import org.x4o.xml.io.sax.X4OErrorHandler; @@ -57,7 +58,6 @@ import org.x4o.xml.lang.X4OLanguageProperty; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; -import org.xml.sax.ext.DefaultHandler2; import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.XMLReaderFactory; @@ -852,8 +852,8 @@ public class X4OPhaseLanguageRead { try { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "elements", "", "", elementsReleased+""); - languageContext.getX4ODebugWriter().getDebugWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts); - languageContext.getX4ODebugWriter().getDebugWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , ""); + languageContext.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts); + languageContext.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , ""); } catch (SAXException e) { throw new X4OPhaseException(phase,e); } @@ -920,13 +920,13 @@ public class X4OPhaseLanguageRead { AttributesImpl atts = new AttributesImpl(); //atts.addAttribute ("", key, "", "", value); //atts.addAttribute ("", "verbose", "", "", "true"); - languageContext.getX4ODebugWriter().getDebugWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts); + languageContext.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts); startedPrefix.clear(); printXML(languageContext.getRootElement()); for (String prefix:startedPrefix) { - languageContext.getX4ODebugWriter().getDebugWriter().endPrefixMapping(prefix); + languageContext.getX4ODebugWriter().getContentWriter().endPrefixMapping(prefix); } - languageContext.getX4ODebugWriter().getDebugWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", ""); + languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", ""); languageContext.getX4ODebugWriter().debugLanguageContext(languageContext); } catch (SAXException e) { throw new X4OPhaseException(this,e); @@ -951,15 +951,13 @@ public class X4OPhaseLanguageRead { if (element==null) { throw new SAXException("Can't print debug xml of null element."); } - DefaultHandler2 handler = element.getLanguageContext().getX4ODebugWriter().getDebugWriter(); + ContentWriter handler = element.getLanguageContext().getX4ODebugWriter().getContentWriter(); if (element.getElementType().equals(Element.ElementType.comment)) { - char[] msg = ((String)element.getElementObject()).toCharArray(); - handler.comment(msg,0,msg.length); + handler.comment((String)element.getElementObject()); return; } if (element.getElementType().equals(Element.ElementType.characters)) { - char[] msg = ((String)element.getElementObject()).toCharArray(); - handler.characters(msg,0,msg.length); + handler.characters((String)element.getElementObject()); return; } if (element.getElementClass()==null) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java index 19112fa..f150666 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java @@ -42,7 +42,7 @@ import org.x4o.xml.element.ElementNamespaceContext; import org.x4o.xml.element.ElementNamespaceInstanceProviderException; import org.x4o.xml.element.ElementObjectPropertyValueException; import org.x4o.xml.io.XMLConstants; -import org.x4o.xml.io.sax.XMLWriter; +import org.x4o.xml.io.sax.ContentWriterXml; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageProperty; @@ -212,7 +212,7 @@ public class X4OPhaseLanguageWrite { } } - XMLWriter writer = new XMLWriter(out,encoding,charNew,charTab); + ContentWriterXml writer = new ContentWriterXml(out,encoding,charNew,charTab); writer.startDocument(); Map prefixes = new HashMap(); @@ -273,7 +273,7 @@ public class X4OPhaseLanguageWrite { return result; } - private void writeTree(XMLWriter writer,Element element,boolean isRoot) throws SAXException, ElementObjectPropertyValueException { + private void writeTree(ContentWriterXml writer,Element element,boolean isRoot) throws SAXException, ElementObjectPropertyValueException { AttributesImpl atts = new AttributesImpl(); if (isRoot && schemaUriPrint) { diff --git a/x4o-driver/src/test/java/org/x4o/xml/io/sax/ContentWriterXmlTest.java b/x4o-driver/src/test/java/org/x4o/xml/io/sax/ContentWriterXmlTest.java new file mode 100644 index 0000000..1ed7bc0 --- /dev/null +++ b/x4o-driver/src/test/java/org/x4o/xml/io/sax/ContentWriterXmlTest.java @@ -0,0 +1,295 @@ +/* + * 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; + +import java.io.StringWriter; + +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + + +import junit.framework.TestCase; + +/** + * ContentWriterXml test xml escaping. + * + * @author Willem Cazander + * @version 1.0 Aug 26, 2012 + */ +public class ContentWriterXmlTest extends TestCase { + + public void testCDATANone() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.characters("foobar"); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("foobar")); + } + + public void testCDATANoneTagEscape() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.characters("foobar"); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("foobar<test/>")); + } + + public void testCDATANormal() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.startCDATA(); + writer.characters("foobar"); + writer.endCDATA(); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("")); + } + + public void testCDATAEscapeTag() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.startCDATA(); + writer.characters("foobar"); + writer.endCDATA(); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("]]>")); + } + + public void testCDATAEscapeStart() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.startCDATA(); + writer.characters("0); + assertTrue(output.equals("")); + } + + public void testCDATAEscapeEnd() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.startCDATA(); + writer.characters("foobar]]>"); + writer.endCDATA(); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("")); + } + + public void testCDATAEscapeInvalid() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.startCDATA(); + writer.characters("' are ]]>"); + writer.endCDATA(); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("]]>")); + } + + public void testCDATAEscapeValid() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.startCDATA(); + writer.characters("' are ]]>"); + writer.endCDATA(); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("\' are ]]>")); + } + + public void testCharactersNormal() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.characters("test is foobar!"); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("test is foobar!")); + } + + public void testCharactersEscape() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.characters(" & 'foobar' is \"quoted\"!"); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("<test/> & 'foobar' is "e;quoted"e;!")); + } + + public void testAttributeNormal() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "attr", "", "", "foobar"); + writer.startElementEnd("", "test", "", atts); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("\n")); + } + + public void testAttributeEscape() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "attr", "", "", " & 'foobar' is \"quoted\"!"); + writer.startElementEnd("", "test", "", atts); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("\n")); + } + + + public void testCommentNormal() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.comment("foobar"); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("\n")); + } + + public void testCommentEscape() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + + writer.startDocument(); + writer.comment(""); + writer.endDocument(); + + String output = outputWriter.toString(); + assertNotNull(output); + assertTrue(output.length()>0); + assertTrue(output.equals("\n")); + } + + public void testXmlInvalid() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + AttributesImpl atts = new AttributesImpl(); + + Exception e = null; + try { + writer.startDocument(); + writer.startElement("", "test", "", atts); + writer.startElement("", "foobar", "", atts); + writer.endElement("", "test", ""); + writer.endDocument(); + } catch (Exception catchE) { + e = catchE; + } + assertNotNull(e); + assertEquals(SAXException.class, e.getClass()); + assertTrue(e.getMessage().contains("tag")); + assertTrue(e.getMessage().contains("foobar")); + } + + public void testXmlInvalidEnd() throws Exception { + StringWriter outputWriter = new StringWriter(); + ContentWriterXml writer = new ContentWriterXml(outputWriter); + AttributesImpl atts = new AttributesImpl(); + + Exception e = null; + try { + writer.startDocument(); + writer.startElement("", "test", "", atts); + writer.startElement("", "foobar", "", atts); + writer.endDocument(); + } catch (Exception catchE) { + e = catchE; + } + assertNotNull(e); + assertEquals(SAXException.class, e.getClass()); + assertTrue(e.getMessage().contains("Invalid")); + assertTrue(e.getMessage().contains("2")); + assertTrue(e.getMessage().contains("open")); + } +} diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/element/InlinePropertiesElement.java b/x4o-driver/src/test/java/org/x4o/xml/test/element/InlinePropertiesElement.java index 841283d..dcafe6e 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/test/element/InlinePropertiesElement.java +++ b/x4o-driver/src/test/java/org/x4o/xml/test/element/InlinePropertiesElement.java @@ -26,7 +26,7 @@ import java.io.StringWriter; import org.x4o.xml.element.AbstractElement; import org.x4o.xml.element.ElementException; -import org.x4o.xml.io.sax.XMLWriter; +import org.x4o.xml.io.sax.ContentWriterXml; /** * InlinePropertiesElement to test @@ -44,7 +44,7 @@ public class InlinePropertiesElement extends AbstractElement { @Override public void doElementStart() throws ElementException { StringWriter xmlString = new StringWriter(); - XMLWriter writer = new XMLWriter(xmlString); + ContentWriterXml writer = new ContentWriterXml(xmlString); setElementObject(writer); } diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java new file mode 100644 index 0000000..016908e --- /dev/null +++ b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java @@ -0,0 +1,449 @@ +/* + * 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.eld.doc; + +import java.io.Writer; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.x4o.xml.io.sax.ContentWriterHtml; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +/** + * ContentWriterHtml Writes eld/java documentation in html. + * + * @author Willem Cazander + * @version 1.0 Apr 30, 2013 + */ +public class ContentWriterDoc extends ContentWriterHtml { + + private boolean isAltRow = true; + + public ContentWriterDoc(Writer out,String encoding,String charNewLine,String charTab) { + super(out,encoding,charNewLine,charTab); + } + + public void docCommentGenerated() throws SAXException { + comment("Generated by "+ContentWriterDoc.class.getSimpleName()+" on "+new Date()); + } + + public void docHtmlStart(NavBarConfig conf,String title,List keywords) throws SAXException { + printDocType(DocType.HTML_4_TRANSITIONAL); + comment("NewPage"); + printHtmlStart("en"); + + // ====== Write head + printTagStart(Tag.head); + docCommentGenerated(); + printHeadMetaContentType(); + printHeadTitle(title); + printHeadMetaDate(); + for (String keyword:keywords) { + printHeadMeta("keywords",keyword); + } + printHeadLinkCss(conf.pathPrefix+"resources/stylesheet.css"); + printTagEnd(Tag.head); + + // ======= Write body + printTagStart(Tag.body); + + StringBuffer script = new StringBuffer(); + script.append("\n"); + script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n"); + script.append("\t\tparent.document.title=\"");script.append(title);script.append("\";\n"); + script.append("\t}\n"); + printScriptInline(script.toString()); + printScriptNoDiv(); + + docNavBar(conf,true); + } + + public void docHtmlEnd(NavBarConfig conf,String copyright) throws SAXException { + docNavBar(conf,false); + printTagStart(Tag.p,"legalCopy"); + printTagStart(Tag.small); + charactersRaw(copyright); + printTagEnd(Tag.small); + printTagEnd(Tag.p); + if (conf.statsJS!=null) { + printScriptInline(conf.statsJS); + } + printTagEnd(Tag.body); + printHtmlEnd(); + } + + class NavBarConfig { + String navSelected = null; + List navList = new ArrayList(10); + Map navLinks = new HashMap(10); + Map navNames = new HashMap(10); + String pathPrefix; + String prev; + String next; + String frame; + String aboutLanguage; + String statsJS; + boolean linkDetails = false; + boolean linkFields = false; + boolean linkConstructors = false; + boolean linkMethods = false; + String linkFieldName = "Field"; + String linkConstructorName = "Constr"; + String linkMethodName = "Method"; + String noFrameAllName; + String noFrameAllLink; + String noFrameAllTopJS = + "\nallClassesLink = document.getElementById(\"allclasses_navbar_top\");\n"+ + "if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n"; + String noFrameAllBottomJS = + "\nallClassesLink = document.getElementById(\"allclasses_navbar_bottom\");\n"+ + "if(window==top) {\n\tallClassesLink.style.display = \"block\";\n} else {\n\tallClassesLink.style.display = \"none\";\n}\n"; + + public NavBarConfig() {} + public NavBarConfig(String pathPrefix,String prev,String next,String frame,String aboutLanguage) { + this.pathPrefix=pathPrefix; + this.prev=prev; + this.next=next; + this.frame=frame; + this.aboutLanguage=aboutLanguage; + } + public void addNavItem(String id,String navLink,String navName) { + navList.add(id); + if (navLink!=null) { + navLinks.put(id, navLink); + } + navNames.put(id, navName); + } + } + + private void docNavBar(NavBarConfig conf,boolean isTop) throws SAXException { + String pathPrefix = conf.pathPrefix; + String barComment = "TOP"; + String barCssDiv = "topNav"; + String barId = "navbar_top"; + if (isTop==false) { + barComment = "BOTTOM"; + barCssDiv = "bottomNav"; + barId = "navbar_bottom"; + } + comment("========= START OF "+barComment+" NAVBAR ======="); + + printTagStart(Tag.div,barCssDiv); + printHrefNamed(barId); // Print named link navigation + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "href", "", "", "#skip-"+barId); + atts.addAttribute ("", "title", "", "", "Skip navigation links"); + startElement("", "a", "", atts); + endElement("", "a", ""); + printHrefNamed(barId+"_firstrow"); + + atts = new AttributesImpl();// Print nav bar + atts.addAttribute ("", "class", "", "", "navList"); + atts.addAttribute ("", "title", "", "", "Navigation"); + startElement("", "ul", "", atts); + + for (String navKey:conf.navList) { + String navName = conf.navNames.get(navKey); + String navLink = conf.navLinks.get(navKey); + String selectedCss = null; + if (navKey.equals(conf.navSelected)) { + selectedCss = "navBarCell1Rev"; + } + if (navLink==null) { + printTagText(Tag.li, navName, selectedCss); + } else { + docNavBarListItemHref(pathPrefix+navLink,navName,selectedCss); + } + } + endElement("", "ul", ""); + + printTagStart(Tag.div,"aboutLanguage"); // Print about language + printTagStart(Tag.em); + printTagStart(Tag.strong);charactersRaw(conf.aboutLanguage);printTagEnd(Tag.strong); + printTagEnd(Tag.em); + printTagEnd(Tag.div); + printTagEnd(Tag.div); // end barCssDiv + + printTagStart(Tag.div,"subNav"); + printTagStart(Tag.ul,"navList"); + if (conf.prev==null) { + printTagText(Tag.li, "Prev"); + } else { + docNavBarListItemHref(pathPrefix+conf.prev,"Prev",null,"strong",null); + } + if (conf.next==null) { + printTagText(Tag.li, "Next"); + } else { + docNavBarListItemHref(pathPrefix+conf.next,"Next",null,"strong",null); + } + printTagEnd(Tag.ul); + if (conf.frame!=null) { + printTagStart(Tag.ul,"navList"); + printTagStart(Tag.li); + printHrefTarget(pathPrefix+"index.html?"+conf.frame, "Frames", "_top"); + printTagEnd(Tag.li); + printTagStart(Tag.li); + printHrefTarget(pathPrefix+conf.frame, "No Frames", "_top"); + printTagEnd(Tag.li); + printTagEnd(Tag.ul); + } + if (conf.noFrameAllName!=null && conf.noFrameAllLink!=null) { + printTagStart(Tag.ul,"navList","allclasses_"+barId); + docNavBarListItemHref(pathPrefix+conf.noFrameAllLink,conf.noFrameAllName,null,null,null); + printTagEnd(Tag.ul); + printTagStart(Tag.div); + if (isTop) { + printScriptInline(conf.noFrameAllTopJS); + } else { + printScriptInline(conf.noFrameAllBottomJS); + } + printTagEnd(Tag.div); + } + String tabSpace = " | "; + boolean printLink = conf.linkConstructors || conf.linkFields || conf.linkMethods; + if (printLink) { + printTagStart(Tag.div); + printTagStart(Tag.ul,"subNavList"); + printTagStart(Tag.li);charactersRaw("Summary: ");printTagEnd(Tag.li); + //printTagText(Tag.li,"Nested | "); // TODO: Nested + if (conf.linkFields) { + docNavBarListItemHref("#field_summary",conf.linkFieldName,null,null,tabSpace); + } else { + printTagText(Tag.li,conf.linkFieldName);charactersRaw(tabSpace); + } + + if (conf.linkConstructors) { + docNavBarListItemHref("#constructor_summary",conf.linkConstructorName,null,null,tabSpace); + } else { + printTagText(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace); + } + if (conf.linkMethods) { + docNavBarListItemHref("#method_summary",conf.linkMethodName,null); + } else { + printTagText(Tag.li,conf.linkMethodName); + } + printTagEnd(Tag.ul); + if (conf.linkDetails){ + printTagStart(Tag.ul,"subNavList"); + printTagStart(Tag.li);charactersRaw("Detail: ");printTagEnd(Tag.li); + //printTagText(Tag.li,"Nested | "); + if (conf.linkFields) { + docNavBarListItemHref("#field_detail",conf.linkFieldName,null,null,tabSpace); + } else { + printTagText(Tag.li,conf.linkFieldName);charactersRaw(tabSpace); + } + if (conf.linkConstructors) { + docNavBarListItemHref("#constructor_detail",conf.linkConstructorName,null,null,tabSpace); + } else { + printTagText(Tag.li,conf.linkConstructorName);charactersRaw(tabSpace); + } + if (conf.linkMethods) { + docNavBarListItemHref("#method_detail",conf.linkMethodName,null); + } else { + printTagText(Tag.li,conf.linkMethodName); + } + printTagEnd(Tag.ul); + } + printTagEnd(Tag.div); + } + + printHrefNamed("skip-"+barId); + printTagEnd(Tag.div); + comment("========= END OF "+barComment+" NAVBAR ======="); + } + + private void docNavBarListItemHref(String href,String title,String cssClass) throws SAXException { + docNavBarListItemHref(href, title, cssClass, null, null); + } + private void docNavBarListItemHref(String href,String title,String cssClass,String spanCss,String linkSpace) throws SAXException { + printTagStart(Tag.li,cssClass); + printHref(href,title,title,spanCss); + charactersRaw(linkSpace); + printTagEnd(Tag.li); + } + + public void docPagePackageTitle(String title,String summary) throws SAXException { + printTagStart(Tag.div,"header"); + printTagText(Tag.h1, title,"title"); + printTagStart(Tag.div,"docSummary"); + printTagText(Tag.div, summary,"block"); + printTagEnd(Tag.div); + printTagStart(Tag.p); + charactersRaw("See: "); + printHref("#package_description", "Description"); + printTagEnd(Tag.p); + printTagEnd(Tag.div); + + } + + public void docPagePackageDescription(String title,String summary,String description) throws SAXException { + printHrefNamed("package_description"); + printTagText(Tag.h2, title); + printTagText(Tag.div, summary,"block"); + characters(description); + } + + public void docPageClassStart(String title,String subTitle) throws SAXException { + comment("======== START OF CLASS DATA ========"); + printTagStart(Tag.div,"header"); + if (subTitle!=null) { + printTagStart(Tag.div,"subTitle"); + characters(subTitle); + printTagEnd(Tag.div); + } + printTagText(Tag.h2, title, "title"); + printTagEnd(Tag.div); + } + + public void docPageClassEnd() throws SAXException { + comment("======== END OF CLASS DATA ========"); + } + + public void docPageContentStart() throws SAXException { + printTagStart(Tag.div,"contentContainer"); + } + + public void docPageContentEnd() throws SAXException { + printTagEnd(Tag.div); + } + + public void docPageBlockStart(String title,String namedLink,String comment) throws SAXException { + if (comment!=null) { + comment(comment); + } + docPageBlockStart(); + printHrefNamed(namedLink); + printTagText(Tag.h3, title); + } + + public void docPageBlockStart() throws SAXException { + printTagStart(Tag.ul,"blockList"); + printTagStart(Tag.li,"blockList"); + } + + public void docPageBlockEnd() throws SAXException { + printTagEnd(Tag.li); + printTagEnd(Tag.ul); + } + + public void docPageBlockNext() throws SAXException { + printTagEnd(Tag.li); + printTagStart(Tag.li,"blockList"); + } + + public void docTableStart(String tableTitle,String tableDescription) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "class", "", "", "packageSummary"); + atts.addAttribute ("", "border", "", "", "0"); + atts.addAttribute ("", "cellpadding", "", "", "3"); + atts.addAttribute ("", "cellspacing", "", "", "0"); + if (tableDescription!=null) { + atts.addAttribute ("", "summary", "", "", tableDescription); + } + startElement("", "table", "", atts); + + printTagStart(Tag.caption); + printTagStart(Tag.span);characters(tableTitle);printTagEnd(Tag.span); + printTagStart(Tag.span,"tabEnd");charactersRaw(" ");printTagEnd(Tag.span); + printTagEnd(Tag.caption); + } + + public void docTableEnd() throws SAXException { + printTagEnd(Tag.table); + isAltRow = true; + } + + public void docTableHeader(String titleFirst,String titleLast) throws SAXException { + printTagStart(Tag.tr); + AttributesImpl atts = new AttributesImpl(); + if (titleLast==null) { + atts.addAttribute ("", "class", "", "", "colOne"); + } else { + atts.addAttribute ("", "class", "", "", "colFirst"); + } + atts.addAttribute ("", "scope", "", "", "col"); + startElement("", "th", "", atts); + characters(titleFirst); + endElement("", "th", ""); + if (titleLast==null) { + printTagEnd(Tag.tr); + return; + } + atts = new AttributesImpl(); + atts.addAttribute ("", "class", "", "", "colLast"); + atts.addAttribute ("", "scope", "", "", "col"); + startElement("", "th", "", atts); + characters(titleLast); + printTagEnd(Tag.th); + printTagEnd(Tag.tr); + } + + public void docTableRow(String dataFirst,String dataLast) throws SAXException { + docTableRow(dataFirst,dataLast,null); + } + + public void docTableRow(String dataFirst,String dataLast,String dataBlock) throws SAXException { + docTableRowHref(null,dataFirst,dataLast,dataBlock); + } + + + public void docTableRowHref(String dataFirstHref,String dataFirst,String dataLast,String dataBlock) throws SAXException { + if (isAltRow) { + printTagStart(Tag.tr,"altColor"); + } else { + printTagStart(Tag.tr,"rowColor"); + } + isAltRow = !isAltRow; + if (dataLast==null) { + printTagStart(Tag.td,"colOne"); + } else { + printTagStart(Tag.td,"colFirst"); + } + printTagStart(Tag.code); + if (dataFirstHref==null) { + characters(dataFirst); + } else { + printHref(dataFirstHref, dataFirst, dataFirst); + } + printTagEnd(Tag.code); + printTagEnd(Tag.td); + + if (dataLast==null) { + printTagEnd(Tag.tr); + return; + } + + printTagStart(Tag.td,"colLast"); + printTagStart(Tag.code);characters(dataLast);printTagEnd(Tag.code); + if (dataBlock!=null) { + printTagStart(Tag.div,"block");characters(dataBlock);printTagEnd(Tag.div); + } + printTagEnd(Tag.td); + + printTagEnd(Tag.tr); + } +} diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocGenerator.java b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocGenerator.java index 16c8230..adb3ed9 100644 --- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocGenerator.java +++ b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocGenerator.java @@ -34,6 +34,7 @@ import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementNamespaceContext; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageContext; +import org.xml.sax.SAXException; /** * EldDocGenerator writes documentation. @@ -61,51 +62,60 @@ public class EldDocGenerator { public void writeDoc(File basePath) throws ElementException { EldDocHtmlWriter writer = new EldDocHtmlWriter(); try { + + writer.writeTheme(basePath); writer.writeIndex(basePath, context); - writer.writeStylesheet(basePath); - writer.writeOverviewModule(basePath, context); - writer.writeOverviewNamespace(basePath, context); + writer.writeIndexAll(basePath, context); + writer.writeDocHelp(basePath, context); + writer.writeAllElementsFrame(basePath, context, true); + writer.writeAllElementsFrame(basePath, context, false); + writer.writeOverviewFrame(basePath, context); + writer.writeOverviewLanguage(basePath, context); writer.writeOverviewTree(basePath, context); for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { - writer.writeOverviewModule(basePath, mod); + writer.writeOverviewModule(basePath, mod, context); for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { - writer.writeBindingHandler(basePath,bind,mod); + writer.writeBindingHandler(basePath,bind,mod,context); } for (ElementAttributeHandler attr:mod.getElementAttributeHandlers()) { - writer.writeAttributeHandler(basePath,attr,mod); + writer.writeAttributeHandler(basePath,attr,mod,context); } for (ElementConfigurator conf:mod.getElementConfiguratorGlobals()) { - writer.writeElementConfigurator(basePath,conf,mod); + writer.writeElementConfigurator(basePath,conf,mod,context); } for (ElementInterface iface:mod.getElementInterfaces()) { - writer.writeElementInterface(basePath,iface,mod); + writer.writeElementInterface(basePath,iface,mod,context); for (ElementBindingHandler bind:iface.getElementBindingHandlers()) { - writer.writeBindingHandler(basePath,bind,mod,iface); + writer.writeBindingHandler(basePath,bind,mod,iface,context); } //for (ElementAttributeHandler attr:iface.getElementClassAttributes()) { // writer.writeAttributeHandler(basePath,attr,mod,true); //} for (ElementConfigurator conf:iface.getElementConfigurators()) { - writer.writeElementConfigurator(basePath,conf,mod,iface); + writer.writeElementConfigurator(basePath,conf,mod,iface,context); } } for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { - writer.writeOverviewElement(basePath, ns,mod); + + writer.writeOverviewElement(basePath,ns,mod,context); + writer.writeNamespaceElementsFrame(basePath,ns,mod,context); + for (ElementClass ec:ns.getElementClasses()) { writer.writeElement(basePath, ec, ns, mod,context); for (ElementConfigurator conf:ec.getElementConfigurators()) { - writer.writeElementConfigurator(basePath,conf,mod,ns,ec); + writer.writeElementConfigurator(basePath,conf,mod,ns,ec,context); } } } } - + } catch (SAXException e) { + throw new ElementException(e); } catch (IOException e) { throw new ElementException(e); } diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java index 86d9d82..ee531ef 100644 --- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java +++ b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java @@ -24,17 +24,23 @@ package org.x4o.xml.eld.doc; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; -import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.Date; import java.util.List; +import org.x4o.xml.eld.doc.ContentWriterDoc.NavBarConfig; import org.x4o.xml.element.ElementAttributeHandler; import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementClass; @@ -43,8 +49,14 @@ import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementConfiguratorGlobal; import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementNamespaceContext; +import org.x4o.xml.io.XMLConstants; +import org.x4o.xml.io.sax.ContentWriterHtml.DocType; +import org.x4o.xml.io.sax.ContentWriterHtml.Tag; +import org.x4o.xml.lang.X4OLanguageClassLoader; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageContext; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; /** * EldDocHtmlWriter writes simple eld documentation. @@ -55,8 +67,6 @@ import org.x4o.xml.lang.X4OLanguageContext; * @version 1.0 Aug 26, 2010 */ public class EldDocHtmlWriter { - - private static final String TAB = "        "; private String toSafeUri(String uri) { StringBuilder buf = new StringBuilder(20); @@ -73,6 +83,9 @@ public class EldDocHtmlWriter { if ('-'==c) { buf.append(c); } + if ('_'==c) { + buf.append(c); + } } String prefix = buf.toString(); if (prefix.startsWith("http")) { @@ -87,7 +100,107 @@ public class EldDocHtmlWriter { return prefix; } - private PrintWriter createPrintWriter(File basePath,String...argu) throws FileNotFoundException { + private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespaceContext namespace,ElementClass ec) { + StringBuffer buf = new StringBuffer(100); + if (pathPrefix!=null) { + buf.append(pathPrefix); + } + buf.append(toSafeUri(mod.getId())); + buf.append("/"); + buf.append(toSafeUri(namespace.getId())); + buf.append("/"); + buf.append(toSafeUri(ec.getId())); + buf.append("/index.html"); + return buf.toString(); + } + + private ContentWriterDoc createContentWriterDoc(File outputFile) throws SAXException { + String encoding = XMLConstants.XML_DEFAULT_ENCODING; + try { + Writer out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding); + String charNewLine = XMLConstants.CHAR_NEWLINE; + String charTab = " "; + ContentWriterDoc result = new ContentWriterDoc(out,encoding,charNewLine,charTab); + return result; + } catch (UnsupportedEncodingException e) { + throw new SAXException(e); + } catch (SecurityException e) { + throw new SAXException(e); + } catch (FileNotFoundException e) { + throw new SAXException(e); + } + } + + protected String createLanguageAbout(X4OLanguageContext context) { + StringBuffer buf = new StringBuffer(100); + buf.append("XML X4O Language
"); + buf.append(context.getLanguage().getLanguageName().toUpperCase()); + buf.append("™ "); + buf.append(context.getLanguage().getLanguageVersion()); + return buf.toString(); + } + + protected String createLanguageCopyright(X4OLanguageContext context) { + Calendar calendar = Calendar.getInstance(); + StringBuffer buf = new StringBuffer(100); + buf.append("Copyright © "); + buf.append(calendar.get(Calendar.YEAR)); + buf.append(" "); + buf.append(context.getLanguage().getLanguageName().toUpperCase()); + buf.append(" "); + buf.append("All Rights Reserved."); + return buf.toString(); + } + + protected List createLanguageKeywords(X4OLanguageContext context) { + List keywords = new ArrayList(10); + keywords.add(context.getLanguage().getLanguageName()); + keywords.add("x4o"); + keywords.add("xml"); + keywords.add("language"); + keywords.add("documentation"); + return keywords; + } + + protected NavBarConfig createNavBarConfig(String pathPrefix,File frame,X4OLanguageContext context,ContentWriterDoc writer) throws SAXException { + return createNavBarConfig(pathPrefix, null, null, frame, context, writer); + } + + protected NavBarConfig createNavBarConfig(String pathPrefix,String prev,String next,File frame,X4OLanguageContext context,ContentWriterDoc writer) throws SAXException { + String framePath = null; + try { + String rootPath = new File(frame.getParentFile().getPath()+File.separatorChar+pathPrefix).getCanonicalPath(); + framePath = frame.getPath().substring(rootPath.length()+1); + } catch (IOException e) { + throw new SAXException(e); + } + NavBarConfig conf = writer.new NavBarConfig(pathPrefix,prev,next,framePath,createLanguageAbout(context)); + conf.noFrameAllLink="allelements-noframe.html"; + conf.noFrameAllName="All Elements"; + conf.linkConstructorName="Tag"; + conf.linkFieldName="Attributes"; + conf.linkMethodName="Config"; + + conf.addNavItem("overview","overview-language.html","Overview"); + conf.addNavItem("module",null,"Module"); + conf.addNavItem("namespace",null,"Namespace"); + conf.addNavItem("element",null,"Element"); + conf.addNavItem("tree","overview-tree.html","Tree"); + conf.addNavItem("index","index-all.html","Index"); + conf.addNavItem("help","doc-help.html","Help"); + + return conf; + } + + private void writeStart(NavBarConfig conf,ContentWriterDoc writer,X4OLanguageContext context,String title) throws SAXException { + writer.docHtmlStart(conf,title, createLanguageKeywords(context)); + } + + private void writeEnd(NavBarConfig conf,ContentWriterDoc writer,X4OLanguageContext context) throws SAXException { + writer.docHtmlEnd(conf,createLanguageCopyright(context)); + } + + private File createOutputPathFile(File basePath,String...argu) { StringBuffer buf = new StringBuffer(200); buf.append(basePath.getAbsolutePath()); buf.append(File.separatorChar); @@ -107,40 +220,242 @@ public class EldDocHtmlWriter { outputFile.delete(); } //System.out.println("Creating file: "+outputFile); - PrintWriter pw = new PrintWriter(outputFile); - return pw; + return outputFile; } - public void writeStylesheet(File basePath) throws IOException { - PrintWriter pw = createPrintWriter(basePath,"stylesheet.css"); + private void copyResourceToFile(String resource,File basePath,String...argu) throws SecurityException, IOException, InterruptedException { + ClassLoader cl = X4OLanguageClassLoader.getClassLoader(); + InputStream inputStream = cl.getResourceAsStream(resource); + OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu)); try { - pw.write("\n\n"); - pw.flush(); - pw.print("body { background-color: #FFFFFF; color:#000000 }\n"); - pw.print("h1 { font-size: 145%;text-align: center; }\n"); - pw.print(".Copyright { font-size: 70%;text-align: center; }\n"); - pw.print(".TableHeadingColor { background: #CCCCFF; color:#000000;font-weight: bold;font-size: 110%; }\n"); - pw.print(".TableSubHeadingColor { background: #EEEEFF; color:#000000 }\n"); - pw.print(".TableRowColor { background: #FFFFFF; color:#000000 }\n"); - pw.print(".NavBarCell1 { background-color:#EEEEFF; color:#000000}\n"); - pw.print(".NavBarCell1Rev { background-color:#00008B; color:#FFFFFF}\n"); - pw.print(".NavBarCell1 a { font-size: 120%;font-weight: bold;}\n"); - pw.print(".NavBarCell2 { font-size: 80%;font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}\n"); - pw.print(".NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}\n"); - pw.flush(); + byte[] buffer = new byte[4096]; + int len = inputStream.read(buffer); + while (len != -1) { + outputStream.write(buffer, 0, len); + len = inputStream.read(buffer); + if (Thread.interrupted()) { + throw new InterruptedException(); + } + } } finally { - if (pw!=null) { - pw.close(); - } + inputStream.close(); + outputStream.close(); } } - public void writeIndex(File basePath,X4OLanguageContext context) throws IOException { - PrintWriter pw = createPrintWriter(basePath,"index.html"); + public void writeTheme(File basePath) throws IOException { try { - String title = context.getLanguage().getLanguageName()+" "+context.getLanguage().getLanguageVersion()+" ELD"; - printHeader(pw,"Index ("+title+")",""); - printPageIndexTitle(pw,title,null,null); + copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css",basePath,"resources","stylesheet.css"); + copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/background.png",basePath,"resources","background.png"); + copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/tab.png",basePath,"resources","tab.png"); + copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png",basePath,"resources","titlebar_end.png"); + copyResourceToFile("org/x4o/xml/eld/doc/theme/jdk7/titlebar.png",basePath,"resources","titlebar.png"); + } catch (SecurityException e) { + throw new IOException(e.getMessage()); + } catch (InterruptedException e) { + throw new IOException(e.getMessage()); + } + } + + private void writeHeader(ContentWriterDoc writer,String pathPrefix,String title) throws SAXException { + writer.printTagStart(Tag.head); + writer.docCommentGenerated(); + writer.printHeadMetaContentType(); + writer.printHeadTitle(title); + writer.printHeadMetaDate(); + writer.printHeadLinkCss(pathPrefix+"resources/stylesheet.css"); + writer.printTagEnd(Tag.head); + } + + private static final String FRAME_JS = "\n"+ + "targetPage = \"\" + window.location.search;\n"+ + "if (targetPage != \"\" && targetPage != \"undefined\")\n"+ + "\t { targetPage = targetPage.substring(1); }\n"+ + "if (targetPage.indexOf(\":\") != -1)\n"+ + "\t { targetPage = \"undefined\"; }\n"+ + "function loadFrames() {\n"+ + "\tif (targetPage != \"\" && targetPage != \"undefined\")\n"+ + "\t\t { top.languageFrame.location = top.targetPage; }\n"+ + "}\n"; + + public void writeIndex(File basePath,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,"index.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + try { + writer.printDocType(DocType.HTML_4_FRAMESET); + writer.comment("NewPage"); + writer.printHtmlStart("en"); + writeHeader(writer,"",context.getLanguage().getLanguageName()+" API"); + writer.printScriptInline(FRAME_JS); + + AttributesImpl atts = new AttributesImpl(); + atts.addAttribute ("", "cols", "", "", "20%,80%"); + atts.addAttribute ("", "title", "", "", "Documentation frame"); + atts.addAttribute ("", "onload", "", "", "top.loadFrames()"); + writer.printTagStart(Tag.frameset, atts); + + atts = new AttributesImpl(); + atts.addAttribute ("", "rows", "", "", "30%,70%"); + atts.addAttribute ("", "title", "", "", "Left frames"); + atts.addAttribute ("", "onload", "", "", "top.loadFrames()"); + writer.printTagStart(Tag.frameset, atts); + atts = new AttributesImpl(); + atts.addAttribute ("", "src", "", "", "overview-frame.html"); + atts.addAttribute ("", "title", "", "", "All Namspaces"); + atts.addAttribute ("", "name", "", "", "namespaceListFrame"); + writer.printTagStart(Tag.frame, atts); + writer.printTagEnd(Tag.frame); + atts = new AttributesImpl(); + atts.addAttribute ("", "src", "", "", "allelements-frame.html"); + atts.addAttribute ("", "title", "", "", "All Elements"); + atts.addAttribute ("", "name", "", "", "elementListFrame"); + writer.printTagStart(Tag.frame, atts); + writer.printTagEnd(Tag.frame); + writer.printTagEnd(Tag.frameset); + + atts = new AttributesImpl(); + atts.addAttribute ("", "src", "", "", "overview-language.html"); + atts.addAttribute ("", "title", "", "", "All Language Components"); + atts.addAttribute ("", "name", "", "", "languageFrame"); + atts.addAttribute ("", "scrolling", "", "", "yes"); + writer.printTagStart(Tag.frame, atts); + writer.printTagEnd(Tag.frame); + + writer.printTagStart(Tag.noframes); + writer.printScriptNoDiv(); + writer.printTagText(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.printHref("overview-language.html", "Non-frame version"); + writer.characters("."); + writer.printTagEnd(Tag.p); + writer.printTagEnd(Tag.noframes); + + writer.printTagEnd(Tag.frameset); + writer.printHtmlEnd(); + } finally { + writer.closeWriterSafe(); + } + } + + public void writeOverviewFrame(File basePath,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,"overview-frame.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + try { + writer.printDocType(DocType.HTML_4_TRANSITIONAL); + writer.comment("NewPage"); + writer.printHtmlStart("en"); + writeHeader(writer,"","All Elements of "+context.getLanguage().getLanguageName()); + writer.printTagStart(Tag.body); + + writer.printTagStart(Tag.div,"indexHeader"); + writer.printHrefTarget("allelements-frame.html", "All Elements","elementListFrame"); + writer.printTagEnd(Tag.div); + + writer.printTagStart(Tag.div,"indexContainer"); + writer.printTagText(Tag.h2, "Namespaces"); + writer.printTagStart(Tag.ul); + for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { + for (ElementNamespaceContext enc:mod.getElementNamespaceContexts()) { + writer.printTagStart(Tag.li); + writer.printHrefTarget(toSafeUri(mod.getId())+"/"+toSafeUri(enc.getId())+"/namespace-frame.html", enc.getUri(),"elementListFrame"); + writer.printTagEnd(Tag.li); + } + } + writer.printTagEnd(Tag.ul); + writer.printTagEnd(Tag.div); + + writer.printTagEnd(Tag.body); + writer.printHtmlEnd(); + } finally { + writer.closeWriterSafe(); + } + } + + public void writeAllElementsFrame(File basePath,X4OLanguageContext context,boolean isFrame) throws SAXException { + if (isFrame) { + writeElementsFrame(basePath,"",context,isFrame,null,"allelements-frame.html"); + } else { + writeElementsFrame(basePath,"",context,isFrame,null,"allelements-noframe.html"); + } + } + + public void writeNamespaceElementsFrame(File basePath,ElementNamespaceContext ns,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + writeElementsFrame(basePath,"../../",context,true,ns.getUri(),mod.getId(),ns.getId(),"namespace-frame.html"); + } + + private void writeElementsFrame(File basePath,String pathPrefix,X4OLanguageContext context,boolean isFrame,String nsUri,String...fileName) throws SAXException { + File outputFile = createOutputPathFile(basePath,fileName); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + try { + writer.printDocType(DocType.HTML_4_TRANSITIONAL); + writer.comment("NewPage"); + writer.printHtmlStart("en"); + writeHeader(writer,pathPrefix,"All Elements of "+context.getLanguage().getLanguageName()); + writer.printTagStart(Tag.body); + if (nsUri==null) { + writer.printTagText(Tag.h1, "All Elements", "bar"); + } else { + for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { + for (ElementNamespaceContext enc:mod.getElementNamespaceContexts()) { + if (nsUri!=null && enc.getUri().equals(nsUri)==false) { + continue; + } + writer.printTagStart(Tag.h1,"bar"); + writer.printHrefTarget(pathPrefix+toSafeUri(mod.getId())+File.separatorChar+toSafeUri(enc.getId())+File.separatorChar+"index.html", nsUri,"languageFrame"); + writer.printTagEnd(Tag.h1); + break; + } + } + + } + + writer.printTagStart(Tag.div,"indexContainer"); + writer.printTagStart(Tag.ul); + + for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { + for (ElementNamespaceContext enc:mod.getElementNamespaceContexts()) { + if (nsUri!=null && enc.getUri().equals(nsUri)==false) { + continue; + } + for (ElementClass ec:enc.getElementClasses()) { + writer.printTagStart(Tag.li); + if (isFrame) { + writer.printHrefTarget(pathPrefix+toElementUri(null,mod,enc,ec), enc.getId()+":"+ec.getId(),"languageFrame"); + } else { + writer.printHref(pathPrefix+toElementUri(null,mod,enc,ec), enc.getId()+":"+ec.getId()); + } + writer.printTagEnd(Tag.li); + } + } + } + writer.printTagEnd(Tag.ul); + writer.printTagEnd(Tag.div); + + writer.printTagEnd(Tag.body); + writer.printHtmlEnd(); + } finally { + writer.closeWriterSafe(); + } + } + + public void writeOverviewLanguage(File basePath,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,"overview-language.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + String pathPrefix = ""; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + conf.navSelected="overview"; + conf.linkConstructorName="Language"; + conf.linkFieldName="Modules"; + conf.linkMethodName="Namespaces"; + conf.linkConstructors=true; + conf.linkFields=true; + conf.linkMethods=true; + try { + String title = "Language ("+context.getLanguage().getLanguageName()+" "+context.getLanguage().getLanguageVersion()+" ELD)"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, "Index"); + writer.docPageContentStart(); int attrHandlers = 0; int bindHandlers = 0; @@ -159,75 +474,166 @@ public class EldDocHtmlWriter { } } - pw.print("

Welcome to the EldDocs

"); - printTableStart(pw,"Language Stats"); - printTableRowSummary(pw,"Language:",""+context.getLanguage().getLanguageName()); - printTableRowSummary(pw,"LanguageVersion:",""+context.getLanguage().getLanguageVersion()); - printTableRowSummary(pw,"Modules:",""+context.getLanguage().getLanguageModules().size()); - printTableRowSummary(pw,"Namespaces:",""+namespaces); - printTableRowSummary(pw,"Elements:",""+elements); - printTableRowSummary(pw,"ElementInterfaces:",""+interFaces); - printTableRowSummary(pw,"ElementAttributeHandlers:",""+attrHandlers); - printTableRowSummary(pw,"ElementBindingHandlers:",""+bindHandlers); - printTableRowSummary(pw,"ElementConfigurators:",""+eleConfigs); - printTableEnd(pw); + //pw.print("

Welcome to the EldDocs

"); - printBottom(pw,""); + + writer.printTagStart(Tag.div, "summary"); + writer.docPageBlockStart(); + + writer.docPageBlockStart("Language Summary","constructor_summary","======== LANGUAGE SUMMARY ========"); + writer.docTableStart("Language", "Language Stats Overview"); + writer.docTableHeader("Name", "Value"); + writer.docTableRow("LanguageName:", ""+context.getLanguage().getLanguageName(), null); + writer.docTableRow("LanguageVersion:",""+context.getLanguage().getLanguageVersion(),null); + writer.docTableRow("Modules:",""+context.getLanguage().getLanguageModules().size(),null); + writer.docTableRow("Namespaces:",""+namespaces,null); + writer.docTableRow("Elements:",""+elements,null); + writer.docTableRow("ElementInterfaces:",""+interFaces,null); + writer.docTableRow("ElementAttributeHandlers:",""+attrHandlers,null); + writer.docTableRow("ElementBindingHandlers:",""+bindHandlers,null); + writer.docTableRow("ElementConfigurators:",""+eleConfigs,null); + writer.docTableEnd(); + writer.docPageBlockEnd(); + + writer.docPageBlockStart("Modules Summary","method_summary","======== MODULES SUMMARY ========"); + writer.docTableStart("Modules Summary", "All Language Modules Overview"); + writer.docTableHeader("URI", "Name"); + List mods = context.getLanguage().getLanguageModules(); + Collections.sort(mods,new ElementLanguageModuleComparator()); + for (X4OLanguageModule mod:mods) { + writer.docTableRowHref(toSafeUri(mod.getId())+"/index.html",mod.getId(),mod.getProviderName(),null); + } + writer.docTableEnd(); + writer.docPageBlockEnd(); + + writer.docPageBlockStart("Namespace Summary","field_summary","======== NAMESPACE SUMMARY ========"); + writer.docTableStart("Namespace Summary", "All Language Namespaces Overview"); + writer.docTableHeader("ID", "URI"); + for (X4OLanguageModule mod:mods) { + for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { + writer.docTableRowHref(pathPrefix+toSafeUri(mod.getId())+"/"+toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri(),null); + } + } + writer.docTableEnd(); + writer.docPageBlockEnd(); + + writer.docPageBlockEnd(); + writer.printTagEnd(Tag.div); // summary + + writer.docPagePackageDescription(title, "Index","Language overview."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeOverviewModule(File basePath,X4OLanguageContext context) throws IOException { - PrintWriter pw = createPrintWriter(basePath,"module-overview.html"); - try { - String title = context.getLanguage().getLanguageName()+" "+context.getLanguage().getLanguageVersion()+" ELD"; - printHeader(pw,"Overview Modules ("+title+")",""); - printPageIndexTitle(pw,title,null,null); - printTableStart(pw,"Modules"); - List mods = context.getLanguage().getLanguageModules(); - Collections.sort(mods,new ElementLanguageModuleComparator()); - for (X4OLanguageModule mod:mods) { - printTableRowOverview(pw,toSafeUri(mod.getId())+"/index.html",mod.getId(),mod.getDescription()); - } - printTableEnd(pw); - printBottom(pw,""); - } finally { - if (pw!=null) { - pw.close(); - } - } - } - - public void writeOverviewNamespace(File basePath,X4OLanguageContext context) throws IOException { - PrintWriter pw = createPrintWriter(basePath,"namespace-overview.html"); + public void writeDocHelp(File basePath,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,"doc-help.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = ""; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + conf.navSelected="help"; try { - String title = context.getLanguage().getLanguageName()+" "+context.getLanguage().getLanguageVersion()+" ELD"; - printHeader(pw,"Overview Namespace("+title+")",pathPrefix); - printPageIndexTitle(pw,title,null,null); - List mods = context.getLanguage().getLanguageModules(); - Collections.sort(mods,new ElementLanguageModuleComparator()); - for (X4OLanguageModule mod:mods) { - printNamespaces(pw,mod.getElementNamespaceContexts(),pathPrefix,mod); - } - printBottom(pw,pathPrefix); + String title = "API Help"; + writeStart(conf,writer,context,title); + writer.printTagStart(Tag.div,"header"); + writer.printTagText(Tag.h1, "How This API Document Is Organized", "title"); + writer.printTagStart(Tag.div,"subTitle"); + writer.characters("This X4O (XML4Objects) language document has pages corresponding to the items in the navigation bar, described as follows."); + writer.printTagEnd(Tag.div); + writer.printTagEnd(Tag.div); + + writer.docPageContentStart(); + writer.docPageBlockStart(); + + writer.printTagText(Tag.h2, "Overview"); + writer.printTagStart(Tag.p); + writer.charactersRaw("The Overview page is the front page of this XML X4O Language document and provides a list of all modules and namespaces with a summary for each. This page can also contain an overall description of the language size."); + writer.printTagEnd(Tag.p); + writer.docPageBlockNext(); + + writer.printTagText(Tag.h2, "Module"); + writer.printTagStart(Tag.p); + writer.charactersRaw("The language is build by the modules and provides the namespaces."); + writer.printTagEnd(Tag.p); + writer.docPageBlockNext(); + + writer.printTagText(Tag.h2, "Namespace"); + writer.printTagStart(Tag.p); + writer.charactersRaw("The language namespace holds all the xml elements."); + writer.printTagEnd(Tag.p); + writer.docPageBlockNext(); + + writer.printTagText(Tag.h2, "Element"); + writer.printTagStart(Tag.p); + writer.charactersRaw("The xml language element description."); + writer.printTagEnd(Tag.p); + writer.docPageBlockNext(); + + writer.printTagText(Tag.h2, "Tree"); + writer.printTagStart(Tag.p); + writer.charactersRaw("The xml tree as the eld has defined it."); + writer.printTagEnd(Tag.p); + writer.docPageBlockNext(); + + writer.printTagText(Tag.h2, "Index"); + writer.printTagStart(Tag.p); + writer.charactersRaw("All the keywords in the language."); + writer.printTagEnd(Tag.p); + writer.docPageBlockNext(); + + writer.printTagText(Tag.h2, "Help"); + writer.printTagStart(Tag.p); + writer.charactersRaw("This page."); + writer.printTagEnd(Tag.p); + + writer.docPageBlockEnd(); + writer.docPagePackageDescription(title, "Help","This help file applies to API documentation generated using the standard doclet."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeOverviewTree(File basePath,X4OLanguageContext context) throws IOException { - PrintWriter pw = createPrintWriter(basePath,"tree-overview.html"); + public void writeIndexAll(File basePath,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,"index-all.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = ""; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + conf.navSelected="index"; + try { + String title = "Index All"; + writeStart(conf,writer,context,title); + writer.docPageContentStart(); + for (char i='A';i<='Z';i++) { + writer.printHref("#_"+i+"_", ""+i); + writer.charactersRaw(" "); + } + for (char i='A';i<='Z';i++) { + writer.printHrefNamed("_"+i+"_"); + writer.printTagText(Tag.h2, ""+i); + writer.characters("TODO"); + } + writer.docPageContentEnd(); + writeEnd(conf,writer,context); + } finally { + writer.closeWriterSafe(); + } + } + + public void writeOverviewTree(File basePath,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,"overview-tree.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + String pathPrefix = ""; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + conf.navSelected="tree"; try { String title = context.getLanguage().getLanguageName()+" "+context.getLanguage().getLanguageVersion()+" ELD"; - printHeader(pw,"Overview Tree ("+title+")",pathPrefix); - printPageIndexTitle(pw,title,null,null); + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, "Overview Tree"); + writer.docPageContentStart(); List rootNodes = new ArrayList(3); for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { @@ -247,14 +653,14 @@ public class EldDocHtmlWriter { } Collections.sort(rootNodes,new TreeNodeComparator()); for (TreeNode rootNode:rootNodes) { - walkTree(rootNode,pw,pathPrefix); + walkTree(rootNode,writer,pathPrefix); } - printBottom(pw,pathPrefix); + writer.docPagePackageDescription(title, "Tree","All Language elements as tree."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } @@ -267,28 +673,21 @@ public class EldDocHtmlWriter { int indent = 0; } - private void walkTree(TreeNode node,PrintWriter pw,String pathPrefix) { + private void walkTree(TreeNode node,ContentWriterDoc writer,String pathPrefix) throws SAXException { + String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass); - for (int i=0;i"); - pw.print(node.namespace.getId()); - pw.print(":"); - pw.print(node.elementClass.getId()); - pw.print("
\n"); + writer.printTagStart(Tag.ul); + writer.printTagStart(Tag.li,null,null,"circle"); + writer.characters(node.namespace.getId()); + writer.characters(":"); + writer.printHref(href, node.elementClass.getId(), node.elementClass.getId(), "strong"); + writer.printTagEnd(Tag.li); List childs = findChilderen(node); for (TreeNode child:childs) { - walkTree(child,pw,pathPrefix); + walkTree(child,writer,pathPrefix); } + writer.printTagEnd(Tag.ul); } private List findChilderen(TreeNode node) { @@ -433,49 +832,71 @@ public class EldDocHtmlWriter { } - public void writeOverviewModule(File basePath,X4OLanguageModule mod) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"index.html"); + public void writeOverviewModule(File basePath,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"index.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + conf.navSelected="module"; try { - printHeader(pw,"Overview ("+mod.getId()+")",pathPrefix); - printPageTitle(pw,"Module",mod.getProviderName(),mod.getDescription()); - + String title = "Overview ("+mod.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, mod.getDescription()); + writer.docPageContentStart(); + writer.docPageBlockStart(); + String pathPrefixModule = pathPrefix+toSafeUri(mod.getId())+"/"; - printElementInterfaces(pw,mod.getElementInterfaces(),pathPrefixModule); - printAttributeHandlers(pw,mod.getElementAttributeHandlers(),pathPrefixModule); - printBindingHandlers(pw,mod.getElementBindingHandlers(),pathPrefixModule); - printConfiguratorGlobals(pw, mod.getElementConfiguratorGlobals(),pathPrefixModule); - printNamespaces(pw, mod.getElementNamespaceContexts(),pathPrefix,mod); + printElementInterfaces(writer,mod.getElementInterfaces(),pathPrefixModule); + writer.docPageBlockNext(); - printBottom(pw,pathPrefix); + printAttributeHandlers(writer,mod.getElementAttributeHandlers(),pathPrefixModule); + writer.docPageBlockNext(); + + printBindingHandlers(writer,mod.getElementBindingHandlers(),pathPrefixModule); + writer.docPageBlockNext(); + + printConfiguratorGlobals(writer, mod.getElementConfiguratorGlobals(),pathPrefixModule); + writer.docPageBlockNext(); + + printNamespaces(writer, mod.getElementNamespaceContexts(),pathPrefix,mod); + + writer.docPageBlockEnd(); + writer.docPagePackageDescription(title, "Module","All language options this modules provides."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeOverviewElement(File basePath,ElementNamespaceContext ns,X4OLanguageModule mod) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),"index.html"); + public void writeOverviewElement(File basePath,ElementNamespaceContext ns,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),ns.getId(),"index.html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + conf.navSelected="namespace"; try { - String title = ns.getUri(); - printHeader(pw,"Overview ("+title+")",pathPrefix); - printPageTitle(pw,"Namespace",ns.getUri(),ns.getDescription()); + String title = "Overview ("+ns.getUri()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, ns.getDescription()); + writer.docPageContentStart(); - printTableStart(pw,"Element Summary"); List ecs = ns.getElementClasses(); Collections.sort(ecs,new ElementClassComparator()); + + writer.docTableStart("Element Summary", "All Element Information Overview"); + writer.docTableHeader("Tag", "Name"); for (ElementClass ec:ecs) { - printTableRowOverview(pw,toSafeUri(ec.getId())+"/index.html",ec.getId(),ec.getDescription()); + writer.docTableRowHref(toSafeUri(ec.getId())+"/index.html",ec.getId(),ec.getDescription(),null); } - printTableEnd(pw); - printBottom(pw,pathPrefix); + writer.docTableEnd(); + + writer.docPagePackageDescription(title, "Module","All language options this modules provides."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } @@ -493,13 +914,69 @@ public class EldDocHtmlWriter { return buf.toString(); } + public void writeElementDescription(ContentWriterDoc writer,String pathPrefix,TreeNode node) throws SAXException { + writer.printTagStart(Tag.div, "description"); + writer.docPageBlockStart(); + + List parents = findParents(node); + writer.printTagStart(Tag.dl); + writer.printTagText(Tag.dt,"Element Parents:"); + writer.printTagStart(Tag.dd); + if (parents.isEmpty()) { + writer.characters("No parent."); + + } + for (int i=0;i childs = findChilderen(node); + writer.printTagStart(Tag.dl); + writer.printTagText(Tag.dt,"Element Childeren:"); + writer.printTagStart(Tag.dd); + if (parents.isEmpty()) { + writer.characters("No childeren."); + } + for (int i=0;i parents = findParents(node); - printTableStart(pw,"Element Parents"); - pw.print("\t\n"); - pw.print("\t\t"); - if (parents.isEmpty()) { - pw.print("No parent."); - } - for (TreeNode n:parents) { - pw.print("\t\t\t "); - pw.print(n.namespace.getId()); - pw.print(":"); - pw.print(n.elementClass.getId()); - pw.print("\n"); - } - pw.print("\n"); - pw.print("\t\n"); - printTableEnd(pw); - - List childs = findChilderen(node); - printTableStart(pw,"Element Childeren"); - pw.print("\t\n"); - pw.print("\t\t"); - if (childs.isEmpty()) { - pw.print("No childeren."); - } - for (TreeNode n:childs) { - pw.print("\t\t\t "); - pw.print(n.namespace.getId()); - pw.print(":"); - pw.print(n.elementClass.getId()); - pw.print("\n"); - } - pw.print("\n"); - pw.print("\t\n"); - printTableEnd(pw); - printTableStart(pw,"Element Properties"); - printTableRowSummary(pw,"id",""+ec.getId()); - printTableRowSummary(pw,"objectClass",""+ec.getObjectClass()); - printTableRowSummary(pw,"elementClass",""+ec.getElementClass()); - printTableRowSummary(pw,"autoAttributes",""+ec.getAutoAttributes()); - printTableRowSummary(pw,"skipPhases",printList(ec.getSkipPhases())); - printTableRowSummary(pw,"schemaContentBase",""+ec.getSchemaContentBase()); - printTableRowSummary(pw,"schemaContentComplex",""+ec.getSchemaContentComplex()); - printTableRowSummary(pw,"schemaContentMixed",""+ec.getSchemaContentMixed()); - //printTableRowSummary(pw,"description",""+ec.getDescription()); - printTableEnd(pw); - printElementAttributes(pw,ec.getElementClassAttributes()); - if (ec.getObjectClass()!=null) { - printClassProperties(pw, ec.getObjectClass()); - } + writeStart(conf,writer,context,title); + writer.docPageClassStart(title, ns.getId()+":"+ ns.getUri()); + writer.docPageContentStart(); - printConfigurators(pw,ec.getElementConfigurators(),""); - printBottom(pw,pathPrefix); + writeElementDescription(writer, pathPrefix, node); + + writer.printTagStart(Tag.div, "summary"); + writer.docPageBlockStart(); + + writer.docPageBlockStart("Tag Summary","constructor_summary","======== TAG SUMMARY ========"); + writer.docTableStart("Element Properties", "Element Property Overview"); + writer.docTableHeader("Name", "Value"); + writer.docTableRow("id",""+ec.getId()); + writer.docTableRow("objectClass",""+ec.getObjectClass()); + writer.docTableRow("elementClass",""+ec.getElementClass()); + writer.docTableRow("autoAttributes",""+ec.getAutoAttributes()); + writer.docTableRow("skipPhases",printList(ec.getSkipPhases())); + writer.docTableRow("schemaContentBase",""+ec.getSchemaContentBase()); + writer.docTableRow("schemaContentComplex",""+ec.getSchemaContentComplex()); + writer.docTableRow("schemaContentMixed",""+ec.getSchemaContentMixed()); + writer.docTableEnd(); + writer.docPageBlockEnd(); + + writer.docPageBlockStart("Attribute Summary","method_summary","======== ATTRIBUTE SUMMARY ========"); + printElementAttributes(writer,ec.getElementClassAttributes()); + //writer.docPageBlockNext(); + if (ec.getObjectClass()!=null) { + printClassProperties(writer, ec.getObjectClass()); + } + writer.docPageBlockEnd(); + + + writer.docPageBlockStart("Config Summary","field_summary","======== CONFIG SUMMARY ========"); + printConfigurators(writer,ec.getElementConfigurators(),""); + writer.docPageBlockEnd(); + + writer.docPageBlockEnd(); + writer.printTagEnd(Tag.div); // summary + + + writer.printTagStart(Tag.div, "detail"); + writer.docPageBlockStart(); + + writer.docPageBlockStart("Tag Detail","constructor_detail","======== TAG DETAIL ========"); + writer.docPageBlockEnd(); + + writer.docPageBlockStart("Attribute Detail","method_detail","======== ATTRIBUTE DETAIL ========"); + writer.docPageBlockEnd(); + + writer.docPageBlockStart("Config Detail","field_detail","======== CONFIG DETAIL ========"); + writer.docPageBlockEnd(); + + writer.docPageBlockEnd(); + writer.printTagEnd(Tag.div); // details + + writer.docPageContentEnd(); + writer.docPageClassEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeElementInterface(File basePath,ElementInterface iface,X4OLanguageModule mod) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"interface",iface.getId()+".html"); + public void writeElementInterface(File basePath,ElementInterface iface,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"interface",iface.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); String pathLocal = toSafeUri(iface.getId())+"/"; try { - printHeader(pw,"ElementInterface ("+iface.getId()+")",pathPrefix); - printPageTitle(pw,"ElementInterface",iface.getId(),iface.getDescription()); + String title = "ElementInterface ("+iface.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, mod.getDescription()); + writer.docPageContentStart(); + writer.docPageBlockStart(); - printConfigurators(pw,iface.getElementConfigurators(),pathLocal); - printBindingHandlers(pw,iface.getElementBindingHandlers(),pathLocal); + printConfigurators(writer,iface.getElementConfigurators(),pathLocal); + writer.docPageBlockNext(); - printElementAttributes(pw,iface.getElementClassAttributes()); + printBindingHandlers(writer,iface.getElementBindingHandlers(),pathLocal); + writer.docPageBlockNext(); - printBeanProperties(pw, iface); - printBottom(pw,pathPrefix); + printElementAttributes(writer,iface.getElementClassAttributes()); + writer.docPageBlockNext(); + + printBeanProperties(writer, iface); + writer.docPageBlockNext(); + + writer.docPageBlockEnd(); + writer.docPagePackageDescription(title, "ElementInterface","All language interfaces this modules provides."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeElementConfigurator(File basePath,ElementConfigurator conf,X4OLanguageModule mod) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"conf",conf.getId()+".html"); + public void writeElementConfigurator(File basePath,ElementConfigurator config,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"conf",config.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); try { - printHeader(pw,"Configurator ("+conf.getId()+")",pathPrefix); - printPageTitle(pw,"Configurator",conf.getId(),conf.getDescription()); + String title = "Configurator ("+config.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, config.getDescription()); + writer.docPageContentStart(); - printBeanProperties(pw, conf); - printBottom(pw,pathPrefix); + printBeanProperties(writer, config); + + writer.docPagePackageDescription(title, "Element","All meta information about the xml element."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeElementConfigurator(File basePath,ElementConfigurator conf,X4OLanguageModule mod,ElementInterface iface) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"interface",iface.getId(),"conf",conf.getId()+".html"); + public void writeElementConfigurator(File basePath,ElementConfigurator config,X4OLanguageModule mod,ElementInterface iface,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"interface",iface.getId(),"conf",config.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../../../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); try { - printHeader(pw,"Interface Configurator ("+conf.getId()+")",pathPrefix); - printPageTitle(pw,"Interface Configurator",conf.getId(),conf.getDescription()); + String title = "Interface Configurator ("+config.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, config.getDescription()); + writer.docPageContentStart(); - printBeanProperties(pw, conf); - printBottom(pw,pathPrefix); + printBeanProperties(writer, config); + + writer.docPagePackageDescription(title, "Element","All meta information about the xml element."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeElementConfigurator(File basePath,ElementConfigurator conf,X4OLanguageModule mod,ElementNamespaceContext ns,ElementClass ec) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getId(),"conf",conf.getId()+".html"); + public void writeElementConfigurator(File basePath,ElementConfigurator config,X4OLanguageModule mod,ElementNamespaceContext ns,ElementClass ec,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),ns.getId(),ec.getId(),"conf",config.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../../../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); try { - printHeader(pw,"Interface Configurator ("+conf.getId()+")",pathPrefix); - printPageTitle(pw,"Interface Configurator",conf.getId(),conf.getDescription()); + String title = "Interface Configurator ("+config.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, config.getDescription()); + writer.docPageContentStart(); - printBeanProperties(pw, conf); - printBottom(pw,pathPrefix); + printBeanProperties(writer, config); + + writer.docPagePackageDescription(title, "Interface Configurator","All meta information about the interface."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeBindingHandler(File basePath,ElementBindingHandler bind,X4OLanguageModule mod) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"bind",bind.getId()+".html"); + public void writeBindingHandler(File basePath,ElementBindingHandler bind,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"bind",bind.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); String pathPrefix = "../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); try { - printHeader(pw,"BindingHandler ("+bind.getId()+")",pathPrefix); - printPageTitle(pw,"BindingHandler",bind.getId(),bind.getDescription()); - + String title = "BindingHandler "+bind.getId(); + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, bind.getDescription()); + writer.docPageContentStart(); + writer.docPageBlockStart(); /* printTableStart(pw,"Child Classes"); for (Class clazz:bind.getBindChildClasses()) { @@ -667,53 +1164,71 @@ public class EldDocHtmlWriter { } printTableEnd(pw); */ - printBeanProperties(pw, bind); - printBottom(pw,pathPrefix); - } finally { - if (pw!=null) { - pw.close(); - } - } - } - - public void writeBindingHandler(File basePath,ElementBindingHandler bind,X4OLanguageModule mod,ElementInterface iface) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"interface",iface.getId(),"bind",bind.getId()+".html"); - String pathPrefix = "../../../../"; - try { - printHeader(pw,"Interface BindingHandler ("+bind.getId()+")",pathPrefix); - printPageTitle(pw,"Interface BindingHandler",bind.getId(),bind.getDescription()); + printBeanProperties(writer, bind); - printTableStart(pw,"Child Classes"); - for (Class clazz:bind.getBindChildClasses()) { - printTableRowSummary(pw,"class",""+clazz.getName()); - } - printTableEnd(pw); - printBeanProperties(pw, bind); - printBottom(pw,pathPrefix); + writer.docPageBlockEnd(); + writer.docPagePackageDescription(title, "Element","All meta information about the xml element."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); } finally { - if (pw!=null) { - pw.close(); - } + writer.closeWriterSafe(); } } - public void writeAttributeHandler(File basePath,ElementAttributeHandler attr,X4OLanguageModule mod) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),"attr",attr.getId()+".html"); - String pathPrefix = "../../"; + public void writeBindingHandler(File basePath,ElementBindingHandler bind,X4OLanguageModule mod,ElementInterface iface,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"interface",iface.getId(),"bind",bind.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + String pathPrefix = "../../../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); try { - printHeader(pw,"AttributeHandler ("+attr.getId()+")",pathPrefix); - printPageTitle(pw,"AttributeHandler",attr.getId(),attr.getDescription()); - printBeanProperties(pw, attr); - printBottom(pw,pathPrefix); - } finally { - if (pw!=null) { - pw.close(); + String title = "Interface BindingHandler ("+bind.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, bind.getDescription()); + writer.docPageContentStart(); + writer.docPageBlockStart(); + + writer.docTableStart("Child Classes", "Child classes overview."); + writer.docTableHeader("Name", "Value"); + for (Class clazz:bind.getBindChildClasses()) { + writer.docTableRow("class",""+clazz.getName()); } + writer.docTableEnd(); + writer.docPageBlockNext(); + printBeanProperties(writer, bind); + + writer.docPageBlockEnd(); + writer.docPagePackageDescription(title, "Element","All meta information about the xml element."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); + } finally { + writer.closeWriterSafe(); } } - private void printClassProperties(PrintWriter pw,Class beanClass) { - printTableStart(pw,"Class Properties"); + public void writeAttributeHandler(File basePath,ElementAttributeHandler attr,X4OLanguageModule mod,X4OLanguageContext context) throws SAXException { + File outputFile = createOutputPathFile(basePath,mod.getId(),"attr",attr.getId()+".html"); + ContentWriterDoc writer = createContentWriterDoc(outputFile); + String pathPrefix = "../../"; + NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, context, writer); + try { + String title = "AttributeHandler ("+attr.getId()+")"; + writeStart(conf,writer,context,title); + writer.docPagePackageTitle(title, attr.getDescription()); + writer.docPageContentStart(); + + printBeanProperties(writer, attr); + + writer.docPagePackageDescription(title, "Element","All meta information about the xml element."); + writer.docPageContentEnd(); + writeEnd(conf,writer,context); + } finally { + writer.closeWriterSafe(); + } + } + + private void printClassProperties(ContentWriterDoc writer,Class beanClass) throws SAXException { + writer.docTableStart("Class Properties", "Bean class properties overview."); + writer.docTableHeader("Name", "Value"); for (Method m:beanClass.getMethods()) { if (m.getName().startsWith("set")) { String n = m.getName().substring(3); @@ -725,14 +1240,15 @@ public class EldDocHtmlWriter { } n = n.substring(0,1).toLowerCase()+n.substring(1,n.length()); Class type = m.getParameterTypes()[0]; // TODO make full list for auto attribute type resolving. - printTableRowSummary(pw,n,""+type); + writer.docTableRow(n,""+type); } } - printTableEnd(pw); + writer.docTableEnd(); } - private void printBeanProperties(PrintWriter pw,Object bean) { - printTableStart(pw,"Bean Properties"); + private void printBeanProperties(ContentWriterDoc writer,Object bean) throws SAXException { + writer.docTableStart("Bean Properties", "Bean properties overview."); + writer.docTableHeader("Name", "Value"); for (Method m:bean.getClass().getMethods()) { if (m.getName().startsWith("get")) { String n = m.getName().substring(3); @@ -754,10 +1270,10 @@ public class EldDocHtmlWriter { e.printStackTrace(); } - printTableRowSummary(pw,n,printValue(value)); + writer.docTableRow(n,printValue(value)); } } - printTableEnd(pw); + writer.docTableEnd(); } private String printValue(Object value) { @@ -802,228 +1318,67 @@ public class EldDocHtmlWriter { return value.toString(); } - private void printElementAttributes(PrintWriter pw,Collection elementClassAttributes) { - printTableStart(pw,"Element Attributes"); + private void printElementAttributes(ContentWriterDoc writer,Collection elementClassAttributes) throws SAXException { + writer.docTableStart("Element Attributes", "All Element Attributes Overview"); + writer.docTableHeader("URI", "Name"); for (ElementClassAttribute attr:elementClassAttributes) { - printTableRowSummary(pw,attr.getId(),attr.getDescription()); + writer.docTableRow(attr.getId(),attr.getDescription()); } - printTableEnd(pw); + writer.docTableEnd(); } - private void printNamespaces(PrintWriter pw,List namespaces,String pathPrefix ,X4OLanguageModule mod) { - printTableStart(pw,"Namespaces"); + private void printNamespaces(ContentWriterDoc writer,List namespaces,String pathPrefix ,X4OLanguageModule mod) throws SAXException { + writer.docTableStart("Namespace Summary", "All Language Namespaces Overview"); + writer.docTableHeader("ID", "URI"); for (ElementNamespaceContext ns:namespaces) { - printTableRowOverview(pw,pathPrefix+toSafeUri(mod.getId())+"/"+toSafeUri(ns.getId())+"/index.html",ns.getId(),""+ns.getUri()+"
"+TAB+ns.getName()); + writer.docTableRowHref(pathPrefix+toSafeUri(mod.getId())+"/"+toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri(),null); } - printTableEnd(pw); + writer.docTableEnd(); } - private void printConfigurators(PrintWriter pw,List confs,String pathPrefix) { - printTableStart(pw,"Configurators"); + private void printConfigurators(ContentWriterDoc writer,List confs,String pathPrefix) throws SAXException { + writer.docTableStart("Configurators", "All module provided element configurators."); + writer.docTableHeader("ID", "Name"); for (ElementConfigurator conf:confs) { - printTableRowOverview(pw,pathPrefix+"conf/"+toSafeUri(conf.getId())+".html",conf.getId(),conf.getDescription()); + writer.docTableRowHref(pathPrefix+"conf/"+toSafeUri(conf.getId())+".html",conf.getId(),conf.getDescription(),null); } - printTableEnd(pw); + writer.docTableEnd(); } - private void printConfiguratorGlobals(PrintWriter pw,List confs,String pathPrefix) { - printTableStart(pw,"Configurators"); + private void printConfiguratorGlobals(ContentWriterDoc writer,List confs,String pathPrefix) throws SAXException { + writer.docTableStart("Configurators Global", "All module provided element configurators."); + writer.docTableHeader("ID", "Name"); for (ElementConfigurator conf:confs) { - printTableRowOverview(pw,pathPrefix+"conf/"+toSafeUri(conf.getId())+".html",conf.getId(),conf.getDescription()); + writer.docTableRowHref(pathPrefix+"conf/"+toSafeUri(conf.getId())+".html",conf.getId(),conf.getDescription(),null); } - printTableEnd(pw); + writer.docTableEnd(); } - private void printBindingHandlers(PrintWriter pw,List binds,String pathPrefix) { - printTableStart(pw,"Binding handlers"); + private void printBindingHandlers(ContentWriterDoc writer,List binds,String pathPrefix) throws SAXException { + writer.docTableStart("Binding Handlers", "All module provided binding handlers."); + writer.docTableHeader("ID", null); for (ElementBindingHandler bind:binds) { - printTableRowOverview(pw,pathPrefix+"bind/"+toSafeUri(bind.getId())+".html",bind.getId(),bind.getDescription()); + writer.docTableRowHref(pathPrefix+"bind/"+toSafeUri(bind.getId())+".html",bind.getId(),null,null); } - printTableEnd(pw); + writer.docTableEnd(); } - private void printAttributeHandlers(PrintWriter pw,List attrs,String pathPrefix) { - printTableStart(pw,"Attribute handlers"); + private void printAttributeHandlers(ContentWriterDoc writer,List attrs,String pathPrefix) throws SAXException { + writer.docTableStart("Attribute Handlers", "All module provided attribite handlers."); + writer.docTableHeader("ID", "Name"); for (ElementAttributeHandler attr:attrs) { - printTableRowOverview(pw,pathPrefix+"attr/"+toSafeUri(attr.getId())+".html",attr.getId(),attr.getDescription()); + writer.docTableRowHref(pathPrefix+"attr/"+toSafeUri(attr.getId())+".html",attr.getId(),attr.getDescription(),null); } - printTableEnd(pw); + writer.docTableEnd(); } - private void printElementInterfaces(PrintWriter pw,List ifaces,String pathPrefix) { - printTableStart(pw,"Element Interfaces"); + private void printElementInterfaces(ContentWriterDoc writer,List ifaces,String pathPrefix) throws SAXException { + writer.docTableStart("Element Interfaces", "All module provided element interfaces."); + writer.docTableHeader("ID", "Name"); for (ElementInterface iface:ifaces) { - printTableRowOverview(pw,pathPrefix+"interface/"+toSafeUri(iface.getId())+".html",""+iface.getId(),iface.getDescription()); + writer.docTableRowHref(pathPrefix+"interface/"+toSafeUri(iface.getId())+".html",""+iface.getId(),iface.getDescription(),null); } - printTableEnd(pw); - } - - private void printTableStart(PrintWriter pw,String title) { - pw.print("\n"); - pw.print("\t\n"); - pw.print("\t\t\n\t\n"); - } - - private void printTableRowSummary(PrintWriter pw,String name,String description) { - pw.print("\t\n"); - pw.print("\t\t\n"); - pw.print("\t\t\n"); - pw.print("\t\n"); - } - - private void printTableRowOverview(PrintWriter pw,String href,String hrefTitle,String description) { - pw.print("\t\n"); - pw.print("\t\t\n"); - pw.print("\t\t\n"); - pw.print("\t\n"); - } - - private void printTableEnd(PrintWriter pw) { - pw.print("
\n"); - pw.print(title); - pw.print("
"); - pw.print(name); - pw.print(""); - if (description!=null) { - pw.print(description); - } - pw.print("\t\t
"); - pw.print(hrefTitle); - pw.print(""); - if (description!=null) { - pw.print(description); - } - pw.print("\t\t
\n"); - pw.print("
"); - } - - private void printPageTitle(PrintWriter pw,String title,String titleContext,String description) { - pw.print("

"); - pw.print(title); - pw.print(" "); - if (titleContext!=null) { - pw.print(titleContext); - } - pw.print("

\n"); - if (description!=null) { - pw.print(description); - pw.print("
\n"); - pw.print("
\n"); - } - } - - private void printPageIndexTitle(PrintWriter pw,String title,String titleContext,String description) { - pw.print("

"); - pw.print(title); - pw.print(" "); - if (titleContext!=null) { - pw.print(titleContext); - } - pw.print("

\n"); - if (description!=null) { - pw.print(description); - } - } - - private void printHeader(PrintWriter pw,String title,String pathPrefix) throws IOException { - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print(""); - pw.print(title); - pw.print("\n"); - //pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - - pw.print("
\n"); - - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print(""); - pw.print("\n"); - - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - - pw.print("
\n"); - pw.print("\n"); - - pw.print("\n"); - pw.print("\t\n"); - printNavBar(pw,pathPrefix); - pw.print("\t\n"); - pw.print("
\n"); - - pw.print("
\n
\n"); - pw.print(" PREV  NEXT
\n"); - pw.print("\n"); - pw.print("
\n"); - pw.print("\n"); - pw.flush(); - } - - private void printBottom(PrintWriter pw,String pathPrefix) throws IOException { - - pw.print("
\n"); - - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print(""); - pw.print("\n"); - - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); - - pw.print("
\n"); - pw.print("\n"); - - pw.print("\n"); - pw.print("\t\n"); - printNavBar(pw,pathPrefix); - pw.print("\t\n"); - pw.print("
\n"); - - pw.print("
\n
\n"); - pw.print(" PREV  NEXT
\n"); - pw.print("\n"); - pw.print("
\n"); - pw.print("\n"); - - pw.print("
"); - pw.print("Copyright © todo. All Rights Reserved.\n"); - pw.print("
\n"); - - pw.print("\n"); - pw.print("\n"); - pw.print("\n\n"); - pw.flush(); - } - - private void printNavBar(PrintWriter pw,String pathPrefix) throws IOException { - pw.print("\t\tIndex \n"); - pw.print("\t\tModules \n"); - pw.print("\t\tNamespaces \n"); - pw.print("\t\tTree \n"); + writer.docTableEnd(); } class ElementLanguageModuleComparator implements Comparator { diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png b/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png new file mode 100644 index 0000000000000000000000000000000000000000..d700543914de74f6a69d7b7e35670d3307547dd7 GIT binary patch literal 1333 zcmV-51zcR^uxNo<2iYk@pjY)*5FJz8x~bc{)Bfk^xPyv_ zyNMc1gsAxEQ$0gZmnJXPTh5`TyYF`|^m}!|nFl{Ck0^o9y+AWBrQkU;etL)ghw+<- z`Vx9PB!#!G23G?v7oO%pyoD~3!iA`tzP^jT8~l(x#7n%O|AN!gF0A9OV?$57p89_w z)YR0~)Ya9zs;f6t&=dbRLTyEDeMLn*9<{XwQEwql!RE9%Y&NIE>99E*HmB2RquxT2 zLT6=VXJscAYICy?;uVqvpZN5jTGA&%BAKDutmcP1D+jw6>}?ZDZtO5Ak^X{yu*H5P!g9ZVp*_ ziSal|VR3eLd1VpLmBp3i#pUG{>LsG86pF=dtm5PL<94z5_=t;m3(Yc9NGvUFZYC02 zTZyg2(kAXL;w7T06xR3l_BJ-enNDw{*Y`Hk#7jg~DP-3U(g)eKwY7t6HZ4q+c!{Vg zh5c-H2lxK|P9~elpinPSsFlJ|GLt+!Jj@&=lSjsJNW4T;l|piLcXf3&mD=4+AtVur zmx!uTNWHkqSISq)SISq)SISq)SN_*4j8=iskTBXFMsvkz;TVk~qa9^5y^PkH(ZDmF z35>@Gf+0W2D9y r+%d+3j3Fdr)X5mAGRC$q9}fQk#C-8$sx{0z00000NkvXXu0mjf41HWc literal 0 HcmV?d00001 diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css b/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css new file mode 100644 index 0000000..002e17f --- /dev/null +++ b/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css @@ -0,0 +1,447 @@ +/* Javadoc JDK7 like style sheet */ +body { + background-color:#ffffff; + color:#353833; + font-family:Arial, Helvetica, sans-serif; + font-size:76%; + margin:0px; +} +a:link, a:visited { + text-decoration:none; + color:#4c6b87; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4c6b87; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-size:1.3em; +} +h1 { + font-size:1.8em; +} +h2 { + font-size:1.5em; +} +h3 { + font-size:1.4em; +} +h4 { + font-size:1.3em; +} +h5 { + font-size:1.2em; +} +h6 { + font-size:1.1em; +} +ul { + list-style-type:disc; +} +code, tt { + font-size:1.2em; +} +dt code { + font-size:1.2em; +} +table tr td dt code { + font-size:1.2em; + vertical-align:top; +} +sup { + font-size:0.6em; +} +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:0.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + background-image:url(titlebar.png); + background-position:left top; + background-repeat:no-repeat; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +.bar { + background-image:url(background.png); + background-repeat:repeat-x; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:1em; + margin:0px; +} +.topNav { + background-image:url(background.png); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0px; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.bottomNav { + margin-top:10px; + background-image:url(background.png); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0px; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.subNav { + background-color:#dee3e9; + border-bottom:1px solid #9eadc0; + float:left; + width:100%; + overflow:hidden; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; +} +ul.navList, ul.subNavList { + float:left; + margin:0px 25px 0px 0px; + padding:0px; +} +ul.navList li{ + list-style:none; + float:left; + padding:3px 6px; +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; +} +.navBarCell1Rev { + background-image:url(tab.png); + background-color:#a88834; + color:#FFFFFF; + margin: auto 5px; + border:1px solid #c9aa44; +} +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0px 0px 0px; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader h1 { + font-size:1.3em; +} +.title { + color:#2c4557; + margin:10px 0px; +} +.subTitle { + margin:5px 0px 0px 0px; +} +.header ul { + margin:0px 0px 25px 0px; + padding:0px; +} +.footer ul { + margin:20px 0px 5px 0px; +} +.header ul li, .footer ul li { + list-style:none; + font-size:1.2em; +} +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0px 0px 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0px 0px 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0px; + margin:15px 0px; +} +ul.blockList li.blockList h2 { + padding:0px 0px 20px 0px; +} +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:1.0em; +} +.indexContainer h2 { + font-size:1.1em; + padding:0px 0px 3px 0px; +} +.indexContainer ul { + margin:0px; + padding:0px; +} +.indexContainer ul li { + list-style:none; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:1.1em; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:10px 0px 10px 20px; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0px 0px 0px 1px; + font-size:1.1em; + display:inline; +} +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0px; + padding:0px; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0px 10px 0px; + padding:0px; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:25px; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #9eadc0; + background-color:#f9f9f9; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0px 0px 5px 8px; + background-color:#ffffff; + border:1px solid #9eadc0; + border-top:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0px; + padding-left:0px; + padding-bottom:15px; + border:none; + border-bottom:1px solid #9eadc0; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0px; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0px; + margin-bottom:1px; +} +.contentContainer table, .classUseContainer table, .constantValuesContainer table { + border-bottom:1px solid #9eadc0; + width:100%; +} +.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { + width:100%; +} +.contentContainer .description table, .contentContainer .details table { + border-bottom:none; +} +.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ + vertical-align:top; + padding-right:20px; +} +.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, +.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, +.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, +.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { + padding-right:3px; +} +.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#FFFFFF; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + margin:0px; +} +caption a:link, caption a:hover, caption a:active, caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(titlebar.png); + height:18px; +} +.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { + width:10px; + background-image:url(titlebar_end.png); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +ul.blockList ul.blockList li.blockList table { + margin:0px 0px 12px 0px; + width:100%; +} +.tableSubHeadingColor { + background-color: #EEEEFF; +} +.altColor { + background-color:#eeeeef; +} +.rowColor { + background-color:#ffffff; +} +.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { + text-align:left; + padding:3px 3px 3px 7px; +} +th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { + background:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + text-align:left; + padding:3px 3px 3px 7px; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +td.colFirst, th.colFirst { + border-left:1px solid #9eadc0; + white-space:nowrap; +} +td.colLast, th.colLast { + border-right:1px solid #9eadc0; +} +td.colOne, th.colOne { + border-right:1px solid #9eadc0; + border-left:1px solid #9eadc0; +} +table.overviewSummary { + padding:0px; + margin-left:0px; +} +table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, +table.overviewSummary td.colOne, table.overviewSummary th.colOne { + width:25%; + vertical-align:middle; +} +table.packageSummary td.colFirst, table.overviewSummary th.colFirst { + width:25%; + vertical-align:middle; +} +/* +Content styles +*/ +.description pre { + margin-top:0px; +} +.deprecatedContent { + margin:0px; + padding:10px 0px; +} +.docSummary { + padding:0px; +} +.sourceLineNo { + color:green; + padding:0px 30px 0px 0px; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:0.9em; +} +.block { + display:block; + margin:3px 0px 0px 0px; +} +.strong { + font-weight:bold; +} diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png b/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png new file mode 100644 index 0000000000000000000000000000000000000000..0389d904dec92a6dcc679c73368cdd61da85c2dc GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^%s?#10V4113poL#Dgt~$T!Hle|Nrk#HT|&A>iq)C zN7K#r)oAUl(b`p|xvgB|Oq<^RI_=$6T01I$T+K^e2Io8U&$Q{EY|%T>tar3g_h^&u zp$46u6(UZW2StX|ErcsA4g=?wEn)68y7F!{L9`prD6*K;hN z&$9Tu$Y%Xi)B8ZX8I!!-T^Kr8Wj%l#&H|6fVg?3oVGw3ym^DWND9B#o>FdgVmqkuU z(PZlGt))PrXipc%5RU7)#~j6)6c`*1{%=xpnPTK2XxjbYpLx#XO;>rgh8=NN5cfPc z^Xu*)uf*!yH_zw3G!aZrsXM=9io|ch=Q3y4Chp+>(XQUoV8~V)xaGRo?=3I<{(t?! Y|16O04P%6wGSC_ZPgg&ebxsLQ0R3}?WB>pF literal 0 HcmV?d00001 diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png b/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png new file mode 100644 index 0000000000000000000000000000000000000000..8aa5a06afac4cb397a9dc3a46db8c98b26c3249a GIT binary patch literal 2435 zcmbtWc{p3?9u87#qqec7mM+$y6tO-(}Xtz40d zsAWoQ)uuxoacAm-}`&t_cwV|m)kSpB6ky@>+&O1Z(p zeSKP{ddp4a<_P8Ho64kcrKWHtLZ~7Eqd0n7gO;g5yRFfCORYCi?Pa`bdyEP>3f3A4 zYmI`n+=P+Bl^ZcijbTazjM7l5`cRtsK=P^H#8ce~z{_ec6V$rmR6Ao;JL6PeM60}r zQ6YvYH-;$>rD+VLsDCVke<*;DaNbmLY;|x zI6YgNmZde4rA5uuT)`SFml-US>d%+z&lT&AzA(RFMWJT0J3R?7?z(Q`dd}cB& ztfnK(Vf6IClhvE@5svxxGOgQnMphx;;)+iuQ7>&TZ9 z>4SQv#SGbTB!g7WHM@$5o{1Jc5g|H$o}jIus-=^P9ZlPjZ0=gVTWV0@fBK)GQ7uVG_*W6`m`8&G9aA;%yjAF2Z&N6?#+eI+k>wdi#2F~z8fC|=E9sVO z`6rg9CmD*6#Uw;3{FAqk2j!3m5&8kt7VQ9$Wv@NjSwWXMOCnWRZ_>1@cq6=SNM@w7 ztr87kJR2N57fxNVjdv~0C!0Smt$QKB?c#!KTSyS`Ur@|B>=cSd2ByogpFgN07dTe> z;Ax20fP`~5VJd{vG`NC0Z|}|4O}L-Q;5AD6x73LEuTud1{fik%W3ZbZV_{(dvbFg( zF`^yo=!+lvUQ@Ta?H~%;kC``e9`RCXE^fd|v>Ntt9{)-`fWe?WIF@=|K|ND`HyEC4 ztYtJBla;v_Sr>!vf$K_<2lvgo7pd(IhY~ig_uRRi@n_CY7_LwF-TC0y{vZ*V79+#( z=)%m3^*l8e+mB4ei=bwY=P@C;eUoYBVT(^_MoGwW%J0LftO;O6RN4XKLa9?3b!Nu1 z2bK-n`+4KT2TzTMN1Ur29xmc;)!?yniMBnZ?sLP={hxk-oKXP_QgwjzkaIY9^@foM z;&}ts0>SiBD|<;7=i>fCDv~-5qFC405$lM=6`$Zweq=lE)>kDRRr6D41(iQPS=#X% zwh>#+m-yDMaug*ddSpOG&<)FDpS@ zTc651$8n{xLap_G47Kjn)z!DFb0L2IDTkcx2yL_42XQ+}vk~@r=6)Uj@aWF4_%}4A z5=3)R$v~19>2!$#Nq$yfM&;bfmcr<$!sw&Xk=&M8JMa4p%Mq0&QC5Gk39mapgLN( zh8!;?0Vo|E@5-4Ro5GL);;j;YPph#ctGxPU(Gt2QAKWovt>!UoS>mD+7_c!7|KuKYz9TzrOOE^W0002?P)t-s00030 z|NroyIqsi0-<37+p*ruNIpUW#@uEBJpE}x(Fur^$y?ZLXd@8$oDY|+owst7CcPQJB zG1`tX+K(~Jg)Yp7F35u|!+tcd zk2BScGVq`}>YO;}n>gl}H|Ci)<(N0(mNwmzHQJCg*^o5Vjx+J0JMf@8?VdX9o;vHC zIqRJ{>YO>}nmF^KJl&N)-Iqb%n@H!gcj&cx`R(BQ^6Fp{Ll*!500Cl4M??UK1szBL z000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*i75+NrM1@x-`00BEmL_t(2&&`fq zSAswgK&Ns^RtaHO6U~$aMKdw;GsMJFvG4x>pJ@h;4?TBIr#p9d?!!JTNWnRmT%uU= z?c?hRo`3Rq|N04xWwUFxW+Vn;A+2F(!X1*qA(P0MFj|fdEYpj_7xQ3|i)3Fwu32dK)|WdYTSWmQuu7*^GiplSJhPRnT|hNfMZP}9%O z^qO8nbqZaVQ1934H#lfNS(gF~qflrV4TCJuYW&T+|MZvNypxE)A@P`k%WoGfXm9G{ RKJ)+p002ovPDHLkV1jV&Ggklr literal 0 HcmV?d00001