From 8d71b63a6f2487085b681ad63db775c563c8fb70 Mon Sep 17 00:00:00 2001
From: Willem Cazander
Date: Wed, 29 May 2013 22:25:41 +0200
Subject: [PATCH] Created sax content writers and created generic api doc model
for documentation. Improved writer support with attribute write order and
new-lining after long attribute values.
---
pom.xml | 2 +-
src/main/build/gnu-up.sh | 3 +-
src/site/apt/examples/sample-swixml.apt | 204 +--
src/site/apt/examples/start-language.apt | 96 +-
todo.txt | 25 +-
.../x4o/xml/eld/xsd/EldXsdXmlGenerator.java | 27 +-
.../org/x4o/xml/eld/xsd/EldXsdXmlWriter.java | 54 +-
.../java/org/x4o/xml/element/Element.java | 4 +-
.../java/org/x4o/xml/io/DefaultX4OReader.java | 4 +-
.../java/org/x4o/xml/io/XMLConstants.java | 14 +-
...TagHandler.java => X4OContentHandler.java} | 7 +-
.../org/x4o/xml/io/sax/X4OContentParser.java | 147 ++
.../org/x4o/xml/io/sax/X4ODebugWriter.java | 1 +
.../xml/io/sax/ext/AbstractContentWriter.java | 50 +
.../AbstractContentWriterHandler.java} | 201 +--
.../sax/ext/AbstractContentWriterLexical.java | 123 ++
.../xml/io/sax/{ => ext}/AttributeMap.java | 2 +-
.../xml/io/sax/{ => ext}/ContentWriter.java | 6 +-
.../io/sax/{ => ext}/ContentWriterConfig.java | 2 +-
.../io/sax/{ => ext}/ContentWriterHtml.java | 56 +-
.../x4o/xml/io/sax/ext/ContentWriterTag.java | 49 +
.../x4o/xml/io/sax/ext/ContentWriterXml.java | 93 ++
.../xml/io/sax/ext/ContentWriterXmlTag.java | 76 +
.../x4o/xml/io/sax/ext/ContentWriterXsd.java | 85 +
.../xml/lang/phase/X4OPhaseLanguageRead.java | 102 +-
.../xml/lang/phase/X4OPhaseLanguageWrite.java | 94 +-
.../java/org/x4o/xml/eld/EldParserTest.java | 42 +-
.../x4o/xml/io/X4OWriterAttributeTest.java | 86 +
.../java/org/x4o/xml/io/X4OWriterTest.java | 4 +-
.../x4o/xml/io/sax/ContentWriterXmlTest.java | 118 ++
.../java/org/x4o/xml/test/TagHandlerTest.java | 4 -
.../test/element/InlinePropertiesElement.java | 2 +-
.../test/models/TestAttributeOrderChild.java | 148 ++
.../TestAttributeOrderChildNatural.java | 27 +
.../org/x4o/xml/test/models/TestBean.java | 2 -
.../org/x4o/xml/test/swixml/SwiXmlDriver.java | 36 -
.../resources/META-INF/test/test-lang.eld | 27 +-
.../tests/writer/test-attribute-order.xml | 52 +
{x4o-elddoc => x4o-eld-doc}/.project | 4 +-
{x4o-elddoc => x4o-eld-doc}/pom.xml | 6 +-
.../org/x4o/xml/eld/doc/EldDocWriter.java | 271 ++++
.../xml/eld/doc/EldDocWriterElementClass.java | 189 +++
.../x4o/xml/eld/doc/EldDocWriterLanguage.java | 108 ++
.../xml/eld/doc/EldDocXTreePageWriter.java | 332 ++++
.../eld/doc/X4OWriteLanguageDocExecutor.java | 6 +-
.../x4o/xml/eld/doc/api/ApiDocContentCss.java | 74 +
.../xml/eld/doc/api/ApiDocContentWriter.java | 151 +-
.../xml/eld/doc/api/ApiDocNodeWriterBean.java | 198 +++
.../eld/doc/api/ApiDocNodeWriterMethod.java | 51 +
.../org/x4o/xml/eld/doc/api/ApiDocWriter.java | 810 ++++++++++
.../eld/doc/api/DefaultPageWriterHelp.java | 76 +
.../doc/api/DefaultPageWriterIndexAll.java | 59 +
.../eld/doc/api/DefaultPageWriterTree.java | 89 ++
.../org/x4o/xml/eld/doc/api/dom/ApiDoc.java | 350 ++++
.../xml/eld/doc/api/dom/ApiDocConcept.java | 167 ++
.../x4o/xml/eld/doc/api/dom/ApiDocNode.java | 164 ++
.../xml/eld/doc/api/dom/ApiDocNodeBody.java | 38 +
.../xml/eld/doc/api/dom/ApiDocNodeWriter.java | 41 +
.../x4o/xml/eld/doc/api/dom/ApiDocPage.java | 117 ++
.../xml/eld/doc/api/dom/ApiDocPageWriter.java | 36 +
.../xml/eld/doc/api/dom/ApiDocWriteEvent.java | 71 +
.../x4o/xml/eld/doc/api/dom/package-info.java | 30 +
.../org/x4o/xml/eld/doc/api/package-info.java | 30 +
.../org/x4o/xml/eld/doc/package-info.java | 4 +-
.../x4o/xml/eld/doc/theme/base/api-color.css | 127 ++
.../x4o/xml/eld/doc/theme/base/api-font.css | 92 ++
.../x4o/xml/eld/doc/theme/base/api-html.css | 53 +
.../x4o/xml/eld/doc/theme/base/api-inset.css | 183 +++
.../x4o/xml/eld/doc/theme/base/api-layout.css | 131 ++
.../x4o/xml/eld/doc/theme/jdk6/stylesheet.css | 106 ++
.../x4o/xml/eld/doc/theme/jdk7/background.png | Bin
.../x4o/xml/eld/doc/theme/jdk7/stylesheet.css | 22 +
.../org/x4o/xml/eld/doc/theme/jdk7/tab.png | Bin
.../x4o/xml/eld/doc/theme/jdk7/titlebar.png | Bin
.../xml/eld/doc/theme/jdk7/titlebar_end.png | Bin
.../doc/X4OWriteLanguageDocExecutorTest.java | 17 +-
.../src/test/resources/.empty | 0
.../org/x4o/xml/eld/doc/EldDocGenerator.java | 123 --
.../org/x4o/xml/eld/doc/EldDocHtmlWriter.java | 1401 -----------------
.../x4o/xml/eld/doc/theme/jdk7/stylesheet.css | 447 ------
x4o-plugin/x4o-plugin-ant/pom.xml | 4 +-
x4o-plugin/x4o-plugin-maven/pom.xml | 4 +-
82 files changed, 5637 insertions(+), 2620 deletions(-)
rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{X4OTagHandler.java => X4OContentHandler.java} (97%)
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriter.java
rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{ContentWriterXml.java => ext/AbstractContentWriterHandler.java} (75%)
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterLexical.java
rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{ => ext}/AttributeMap.java (99%)
rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{ => ext}/ContentWriter.java (94%)
rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{ => ext}/ContentWriterConfig.java (98%)
rename x4o-driver/src/main/java/org/x4o/xml/io/sax/{ => ext}/ContentWriterHtml.java (87%)
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterTag.java
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXml.java
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXmlTag.java
create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXsd.java
create mode 100644 x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterAttributeTest.java
create mode 100644 x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChild.java
create mode 100644 x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChildNatural.java
create mode 100644 x4o-driver/src/test/resources/tests/writer/test-attribute-order.xml
rename {x4o-elddoc => x4o-eld-doc}/.project (89%)
rename {x4o-elddoc => x4o-eld-doc}/pom.xml (94%)
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterLanguage.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java
rename {x4o-elddoc => x4o-eld-doc}/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java (97%)
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentCss.java
rename x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java => x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentWriter.java (76%)
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterBean.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterHelp.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterIndexAll.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterTree.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDoc.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocConcept.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNode.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeBody.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPage.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPageWriter.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocWriteEvent.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java
create mode 100644 x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java
rename {x4o-elddoc => x4o-eld-doc}/src/main/java/org/x4o/xml/eld/doc/package-info.java (96%)
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css
rename {x4o-elddoc => x4o-eld-doc}/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png (100%)
create mode 100644 x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
rename {x4o-elddoc => x4o-eld-doc}/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png (100%)
rename {x4o-elddoc => x4o-eld-doc}/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png (100%)
rename {x4o-elddoc => x4o-eld-doc}/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png (100%)
rename {x4o-elddoc => x4o-eld-doc}/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java (83%)
rename {x4o-elddoc => x4o-eld-doc}/src/test/resources/.empty (100%)
delete mode 100644 x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocGenerator.java
delete mode 100644 x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java
delete mode 100644 x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
diff --git a/pom.xml b/pom.xml
index c2d1c72..6b68f17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,7 @@
x4o-driver
- x4o-elddoc
+ x4o-eld-doc
x4o-meta
x4o-plugin
diff --git a/src/main/build/gnu-up.sh b/src/main/build/gnu-up.sh
index 09d5fa6..05eebe9 100755
--- a/src/main/build/gnu-up.sh
+++ b/src/main/build/gnu-up.sh
@@ -37,9 +37,10 @@ cd `dirname $0`/../../..;
# Copy to one new dir.
mkdir -p target/gnu-up/$2;
cp x4o-driver/target/x4o-driver-*.jar target/gnu-up/$2;
-cp x4o-elddoc/target/x4o-elddoc-*.jar target/gnu-up/$2;
+cp x4o-eld-doc/target/x4o-eld-doc-*.jar target/gnu-up/$2;
cp x4o-meta/target/x4o-meta-*.jar target/gnu-up/$2;
cp x4o-plugin/x4o-plugin-ant/target/x4o-plugin-ant-*.jar target/gnu-up/$2;
+cp x4o-plugin/x4o-plugin-maven/target/x4o-plugin-maven-*.jar target/gnu-up/$2;
# Sign per file we want to upload.
for FILE in `ls target/gnu-up/$2/*`; do
diff --git a/src/site/apt/examples/sample-swixml.apt b/src/site/apt/examples/sample-swixml.apt
index 1ed30a5..5fb457c 100644
--- a/src/site/apt/examples/sample-swixml.apt
+++ b/src/site/apt/examples/sample-swixml.apt
@@ -23,61 +23,43 @@
Sample SwiXml
- Lets create an xml example from swixml language.
+ Lets create an xml example from the swixml language.
-* Create parser
+* Create language driver
+--
-public class SwiXmlParser extends X4OParser {
+public class SwiXmlDriver extends X4ODriver {
- public static final String LANGUAGE = "swixml";
- public static final String VERSION_2_NS_URI = "http://swixml.x4o.org/xml/ns/swixml-lang";
- public static final String SWING_ENGINE_EL_NAME = "swingEngine";
+ public static final String LANGUAGE_NAME = "swixml";
+ public static final String LANGUAGE_VERSION_2 = "2.0";
+ public static final String LANGUAGE_VERSION_2_NSURI = "http://swixml.x4o.org/xml/ns/swixml-lang"; // todo
+ public static final String LANGUAGE_VERSION_3 = "3.0";
+ public static final String[] LANGUAGE_VERSIONS = new String[]{LANGUAGE_VERSION_2,LANGUAGE_VERSION_3};
+ public static final String LANGUAGE_EL_SWING_ENGINE = "swingEngine";
/**
- * Protected constructor for language support
+ * Helper for while parsing to get the SwingEngine.
+ * @param elementLanguage The elementLanguage to get the swingEngine out.
+ * @return Returns the SwingEngine for this elementLanguage.
*/
- protected SwiXmlParser() {
- super(LANGUAGE);
- }
-
- public SwiXmlParser(SwingEngine engine) {
-
- // Create language by version
- super(LANGUAGE);
-
- // Check engine
- if (engine==null) {
- throw new NullPointerException("Can't parse with null SwingEngine.");
- }
-
- // Add engine for callback
- addELBeanInstance(SWING_ENGINE_EL_NAME,engine);
-
- // Set empty ns for v2 documents
- setProperty(X4OLanguagePropertyKeys.INPUT_EMPTY_NAMESPACE_URI, VERSION_2_NS_URI);
- }
-
- public Component getRootComponent() {
- return (Component)getDriver().getElementLanguage().getRootElement().getElementObject();
- }
-
- static public SwingEngine getSwingEngine(ElementLanguage elementLanguage) {
- ValueExpression ee = elementLanguage.getExpressionFactory().createValueExpression(elementLanguage.getELContext(),"${"+SwiXmlParser.SWING_ENGINE_EL_NAME+"}",Object.class);
- SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getELContext());
+ static public SwingEngine getSwingEngine(X4OLanguageContext elementLanguage) {
+ ValueExpression ee = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),"${"+SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE+"}",Object.class);
+ SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getExpressionLanguageContext());
return se;
}
-}
-+--
-
-* Create parser support
-
-+--
-public class SwiXmlParserSupport2 implements X4OParserSupport {
-
- public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException {
- SwiXmlParser parser = new SwiXmlParser();
- return parser.loadElementLanguageSupport();
+
+ static public SwiXmlDriver getInstance() {
+ return (SwiXmlDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
+ }
+
+ @Override
+ public String getLanguageName() {
+ return LANGUAGE_NAME;
+ }
+
+ @Override
+ public String[] getLanguageVersions() {
+ return LANGUAGE_VERSIONS;
}
}
+--
@@ -103,27 +85,30 @@ public class SwiXmlParserSupport2 implements X4OParserSupport {
* Define the element language
+--
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
@@ -131,76 +116,75 @@ public class SwiXmlParserSupport2 implements X4OParserSupport {
-
+
-
+
-
+
-
+
+
-
+
-
+
+
+
+
-
-
-
+
+
+ Single element in language root to create nice tree, for imports in xsd namespace aware generated files.
+
-
+
-
+
-
+
+
-
+
+
+
+
+
+
-
+
@@ -208,33 +192,57 @@ public class SwiXmlParserSupport2 implements X4OParserSupport {
-
-
-
-
-
+
+
+
+
+
+--
-* JMenuBarBindingHandler
+* Example of hard coded binding handlers
+--
-public class JMenuBarBindingHandler extends AbstractElementBindingHandler {
+public class JPanelBindingHandler extends AbstractElementBindingHandler {
public Class> getBindParentClass() {
- return JFrame.class;
+ return JPanel.class;
}
-
+
public Class>[] getBindChildClasses() {
- return new Class[] {JMenuBar.class};
+ return new Class[] {JComponent.class};
}
-
- public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
- JMenuBar child = (JMenuBar)childObject;
- JFrame frame = (JFrame)parentObject;
- frame.getRootPane().setJMenuBar(child);
+
+ public void bindChild(Element childElement, JPanel parent, Object childObject) throws ElementBindingHandlerException {
+ JComponent child = (JComponent)childObject;
+
+ String c = childElement.getAttributes().get("constraints");
+ Object con = null;
+ if ("BorderLayout.CENTER".equals(c)) {
+ con = BorderLayout.CENTER;
+ } else if ("BorderLayout.NORTH".equals(c)) {
+ con = BorderLayout.NORTH;
+ } else if ("BorderLayout.CENTER".equals(c)) {
+ con = BorderLayout.CENTER;
+ } else if ("BorderLayout.SOUTH".equals(c)) {
+ con = BorderLayout.SOUTH;
+ }
+ if (con==null) {
+ parent.add(child);
+ } else {
+ parent.add(child,con);
+ }
+ }
+
+ @Override
+ public void createChilderen(Element parentElement,JPanel parent) throws ElementBindingHandlerException {
+ for (Component c:parent.getComponents()) {
+ if (c instanceof JComponent) {
+ createChild(parentElement, c);
+ }
+ }
}
}
+--
diff --git a/src/site/apt/examples/start-language.apt b/src/site/apt/examples/start-language.apt
index f893d56..0a9176c 100644
--- a/src/site/apt/examples/start-language.apt
+++ b/src/site/apt/examples/start-language.apt
@@ -26,47 +26,57 @@ Start Language
To integrate x4o as parser for your language there needs to be a few minimal steps
be te taken, to have a working language.
- * Create parser and support classes.
+ * Create driver class.
+
+ * Create driver config file.
* Create language modules files.
- * Create eld files.
+ * Create element language definition files.
* Create your parser
+--
-public class FooBarParser extends X4OParser {
-
- static public String FOOBAR_LANGUAGE = "foobar";
+public class TestFooBarDriver extends X4ODriver {
- public FooBarParser() throws Exception {
- super(FOOBAR_LANGUAGE);
+ static final public String LANGUAGE_NAME = "test-foo-bar";
+ static final public String[] LANGUAGE_VERSIONS = new String[]{X4ODriver.DEFAULT_LANGUAGE_VERSION};
+
+ @Override
+ public String getLanguageName() {
+ return LANGUAGE_NAME;
+ }
+
+ @Override
+ public String[] getLanguageVersions() {
+ return LANGUAGE_VERSIONS;
+ }
+
+ static public TestFooBarDriver getInstance() {
+ return (TestFooBarDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
}
}
+--
-* Create parser support
+* Create driver config
+
+ In the file "META-INF/x4o-drivers.xml"
+--
-public class FooBarParserSupport implements X4OParserSupport {
+
+
+
- public ElementLanguage loadElementLanguageSupport() throws X4OParserSupportException {
- FooBarParser parser = new FooBarParser();
- return parser.loadElementLanguageSupport();
- }
-
- public TestBeanRoot getRoot() {
- // Simple way to return single root object.
- // note; element tree is cleared after parsing only root element is there.
- return (TestBeanRoot)getDriver().getElementLanguage().getRootElement().getElementObject();
- }
-}
+--
* Create modules
- Create the file "META-INF/foobar/foobar-modules.xml" with:
+ Create the file "META-INF/test-foo-bar/test-foo-bar-modules.xml" with:
+--
@@ -83,7 +93,7 @@ public class FooBarParserSupport implements X4OParserSupport {
* Create ELD file
- Create the file "META-INF/foobar/foobar-lang.eld" with:
+ Create the file "META-INF/test-foo-bar/foobar-lang.eld" with:
+--
@@ -93,8 +103,6 @@ public class FooBarParserSupport implements X4OParserSupport {
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
- providerName="foobar.test.x4o.org"
- name="FooBar Language"
id="foobar"
>
@@ -112,8 +120,9 @@ public class FooBarParserSupport implements X4OParserSupport {
schemaPrefix="root"
name="FooBar Root Namespace"
languageRoot="true"
+ id="root"
>
-
+
The root element.
@@ -124,6 +133,7 @@ public class FooBarParserSupport implements X4OParserSupport {
schemaResource="foobar-lang-1.0.xsd"
schemaPrefix="lang"
name="FooBar Language Namespace"
+ id="lang"
>
@@ -138,19 +148,39 @@ public class FooBarParserSupport implements X4OParserSupport {
+--
-
-
-
+
+
+--
* Parse the xml
+--
-FooBarParser p = new FooBarParser();
-p.parseFile("foobar/example.xml");
-TestBeanRoot root = p.getRoot();
+TestFooBarDriver driver = TestFooBarDriver.getInstance();
+
+X4OReader reader = driver.createReader();
+TestFooBar result = reader.readResource("junit/test-foo-bar/test-bean.xml");
+
+result.addTestBean(new TestBean("test-bean"));
+result.addTestBean(new TestBean("test-bean-extra"));
+
+X4OWriter writer = driver.createReader();
+writer.writeFile(result, new File("/tmp/test-bean.xml");
+--
+ And writer gives output like;
+
++--
+
+
+
+
+
+
++--
diff --git a/todo.txt b/todo.txt
index d67bb23..fad194b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,17 +1,31 @@
-- x4o TODO list --
+-- RM function methods from Element interface.
+-- Change global attr to namespace attributes.
+- finish eld doc-output content.
+- Make generic/safe? config bean.
+ - Make language config done by driver xml parser.
+ - Add langauge task api + reg via driver conf or service
+ - Convert ant/mvn plugin to single task executor.
+- change x4o language to "x4o-" prefix so; x4o-cel,x4o-eld,x4o-meta
+- Add language locking, and lock eld/cel and add -eld wrap language for eld extentions per language.
+
+- Add doc version upgrade handler;
+ - per version step xslt doc upgrade (check dyna sax piplining hooking)
+ - per version eld + support code + backing objects
+ - per version eld for dyna tree convert to new backing objects.
+- Add *Local layer for X4OLanguage* classes.
+- Add default define (EL) layer
+- Bring back xml read+write streaming language support.
- static field constant converter
+- add default list and map converter/handler
- full Xinclude test
-- compleet eld doc html/css.
- move loading back into sax phase so version can readout on root tag.
-- meta add more ns and jndi ref/etc'
-- redo eld/default converters config
- tag aliases
-- lang-el-beans.xml loading
+- -el-beans.xml loading
- Add XML schema tags to ELD
- Auto generate schemas from eld
-- Basic write support
- Basic editor support
- Make converter config/loading better
- Single xsd output
@@ -22,6 +36,7 @@
-- IDEAS --
+- add mini xslt parse on top of streaming api.
- add support javax.xml.xpath for xpath support
- add java.script support
- event listeners on all DOM tree element operations
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 c699ea0..1a77ed0 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
@@ -24,13 +24,14 @@ package org.x4o.xml.eld.xsd;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
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.ContentWriter;
-import org.x4o.xml.io.sax.ContentWriterXml;
+import org.x4o.xml.io.sax.ext.ContentWriterXsd;
import org.x4o.xml.lang.X4OLanguageContext;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguage;
@@ -70,9 +71,9 @@ public class EldXsdXmlGenerator {
if (basePath==null) {
throw new ElementException("Can't write schema to null output path.");
}
- if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
- if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE; }
- if (charTab==null) { charTab = XMLConstants.CHAR_TAB; }
+ if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
+ if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE+""; }
+ if (charTab==null) { charTab = XMLConstants.CHAR_TAB+""; }
try {
@@ -82,24 +83,26 @@ public class EldXsdXmlGenerator {
throw new NullPointerException("Could not find namespace: "+namespace);
}
checkNamespace(ns);
- FileOutputStream fio = new FileOutputStream(new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource()));
+ File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
+ Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
try {
- ContentWriterXml out = new ContentWriterXml(fio,encoding,charNew,charTab);
+ ContentWriterXsd out = new ContentWriterXsd(wr,encoding,charNew,charTab);
generateSchema(ns.getUri(), out);
} finally {
- fio.close();
+ wr.close();
}
return;
}
for (X4OLanguageModule mod:language.getLanguageModules()) {
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
checkNamespace(ns);
- FileOutputStream fio = new FileOutputStream(new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource()));
+ File outputFile = new File(basePath.getAbsolutePath()+File.separatorChar+ns.getSchemaResource());
+ Writer wr = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
try {
- ContentWriterXml out = new ContentWriterXml(fio,encoding,charNew,charTab);
+ ContentWriterXsd out = new ContentWriterXsd(wr,encoding,charNew,charTab);
generateSchema(ns.getUri(), out);
} finally {
- fio.close();
+ wr.close();
}
}
}
@@ -109,7 +112,7 @@ public class EldXsdXmlGenerator {
}
}
- public void generateSchema(String namespaceUri,ContentWriter xmlWriter) throws SAXException {
+ public void generateSchema(String namespaceUri,ContentWriterXsd 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 84ed201..469f35a 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,7 +40,7 @@ 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.io.sax.ext.ContentWriterXsd;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguage;
import org.xml.sax.SAXException;
@@ -57,14 +57,14 @@ import org.xml.sax.helpers.AttributesImpl;
public class EldXsdXmlWriter {
- static public final String SCHEMA_URI = "http://www.w3.org/2001/XMLSchema";
+ static public final String SCHEMA_URI = XMLConstants.XML_SCHEMA_NS_URI;
protected X4OLanguage language = null;
- protected ContentWriter xmlWriter = null;
+ protected ContentWriterXsd xmlWriter = null;
protected String writeNamespace = null;
protected Map namespaces = null;
- public EldXsdXmlWriter(ContentWriter xmlWriter,X4OLanguage language) {
+ public EldXsdXmlWriter(ContentWriterXsd xmlWriter,X4OLanguage language) {
this.xmlWriter=xmlWriter;
this.language=language;
this.namespaces=new HashMap(10);
@@ -150,9 +150,9 @@ public class EldXsdXmlWriter {
public void startSchema(ElementNamespaceContext ns) throws SAXException {
xmlWriter.startDocument();
- writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
- writeComment(COMMENT_SEPERATOR);
- writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
+ xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
+ xmlWriter.comment(COMMENT_SEPERATOR);
+ xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
// this is a mess;
String desc = "Automatic generated schema for language: "+language.getLanguageName();
@@ -167,10 +167,10 @@ public class EldXsdXmlWriter {
}
b.append(COMMENT_TEXT);
b.append(" ");
- writeComment(b.toString());
- writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
- writeComment(COMMENT_SEPERATOR);
- writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
+ xmlWriter.comment(b.toString());
+ xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
+ xmlWriter.comment(COMMENT_SEPERATOR);
+ xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
X4OLanguageModule module = null;
for (X4OLanguageModule elm:language.getLanguageModules()) {
@@ -190,7 +190,7 @@ public class EldXsdXmlWriter {
b.append("\n\tUri schema:\t"); b.append(ns.getSchemaUri());
b.append("\n\tCreated on:\t\t"); b.append(new Date());
b.append("\n");
- writeComment(b.toString());
+ xmlWriter.comment(b.toString());
xmlWriter.startPrefixMapping("", SCHEMA_URI);
@@ -222,7 +222,7 @@ public class EldXsdXmlWriter {
public void endSchema() throws SAXException {
xmlWriter.endElement (SCHEMA_URI, "schema" , "");
- writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE);
+ xmlWriter.ignorableWhitespace(XMLConstants.CHAR_NEWLINE);
xmlWriter.endDocument();
}
@@ -301,7 +301,7 @@ public class EldXsdXmlWriter {
if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) {
// oke, reverse this if and rm whitespace.
- writeIgnorableWhitespace(" ");
+ xmlWriter.ignorableWhitespace(' ');
} else {
@@ -447,32 +447,8 @@ public class EldXsdXmlWriter {
atts = new AttributesImpl();
atts.addAttribute ("", "xml:lang", "", "", "en");
xmlWriter.startElement(SCHEMA_URI, "documentation", "", atts);
- writeCharacters(base.getDescription());
+ xmlWriter.characters(base.getDescription());
xmlWriter.endElement(SCHEMA_URI, "documentation", "");
xmlWriter.endElement(SCHEMA_URI, "annotation", "");
}
-
- private void writeCharacters(String text) throws SAXException {
- if (text==null) {
- return;
- }
- char[] msg = text.toCharArray();
- xmlWriter.characters(msg,0,msg.length);
- }
-
- private void writeComment(String text) throws SAXException {
- if (text==null) {
- return;
- }
- char[] msg = text.toCharArray();
- xmlWriter.comment(msg,0,msg.length);
- }
-
- private void writeIgnorableWhitespace(String text) throws SAXException {
- if (text==null) {
- return;
- }
- char[] msg = text.toCharArray();
- xmlWriter.ignorableWhitespace(msg,0,msg.length);
- }
}
diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/Element.java b/x4o-driver/src/main/java/org/x4o/xml/element/Element.java
index b331c68..964c10f 100644
--- a/x4o-driver/src/main/java/org/x4o/xml/element/Element.java
+++ b/x4o-driver/src/main/java/org/x4o/xml/element/Element.java
@@ -36,7 +36,7 @@ import org.x4o.xml.lang.X4OLanguageContext;
* from the attibutes or parent (object)element.
*
* @author Willem Cazander
- * @version 1.0 01/02/2005
+ * @version 1.0 Feb 01, 2005
*/
public interface Element {
@@ -89,7 +89,7 @@ public interface Element {
* @throws ElementException Can be thrown when structure is not correct.
*/
void doElementStart() throws ElementException;
-
+
/**
* This method is fired only once in the run phase.
* @throws ElementException Can be thrown when structure is not correct.
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 eefade7..ff30e50 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,9 +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.ContentWriterXml;
+import org.x4o.xml.io.sax.ext.ContentWriter;
+import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.x4o.xml.lang.X4OLanguageContext;
import org.x4o.xml.lang.X4OLanguageContextLocal;
import org.x4o.xml.lang.X4OLanguageProperty;
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 d1fb1dc..4336713 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
@@ -139,12 +139,12 @@ public final class XMLConstants {
/**
* Tab char
*/
- public static final String CHAR_TAB = "\t";
+ public static final char CHAR_TAB = '\t';
/**
* Newline char
*/
- public static final String CHAR_NEWLINE = "\n";
+ public static final char CHAR_NEWLINE = '\n';
@@ -220,6 +220,16 @@ public final class XMLConstants {
return false;
}
+ static public boolean isCharString(String value) {
+ for (int i=0;i();
this.elementLanguage = elementLanguage;
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java
new file mode 100644
index 0000000..3da28cf
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java
@@ -0,0 +1,147 @@
+/*
+ * 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.x4o.xml.element.ElementException;
+import org.x4o.xml.lang.X4OLanguageContext;
+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.helpers.XMLReaderFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * X4OContentParser Runs the SAX parser with the X4OContentHandler.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Aug 20, 2005
+ */
+public class X4OContentParser {
+
+ public void parse(X4OLanguageContext languageContext) throws SAXException, IOException {
+
+ // If xsd caching is needed this should be the way
+ //XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
+ //config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
+ //SAXParser parser = new SAXParser(config);
+
+ // Create Sax parser with x4o tag handler
+ X4OContentHandler xth = new X4OContentHandler(languageContext);
+ XMLReader saxParser = XMLReaderFactory.createXMLReader();
+ saxParser.setErrorHandler(new X4OErrorHandler(languageContext));
+ saxParser.setEntityResolver(new X4OEntityResolver(languageContext));
+ saxParser.setContentHandler(xth);
+ saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
+ saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
+
+ // Set properties and optional
+ Map saxParserProperties = languageContext.getLanguage().getLanguageConfiguration().getSAXParserProperties(languageContext);
+ for (Map.Entry entry:saxParserProperties.entrySet()) {
+ String name = entry.getKey();
+ Object value= entry.getValue();
+ saxParser.setProperty(name, value);
+ debugMessage("Set SAX property: "+name+" to: "+value,languageContext);
+ }
+ Map saxParserPropertiesOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(languageContext);
+ for (Map.Entry entry:saxParserPropertiesOptional.entrySet()) {
+ String name = entry.getKey();
+ Object value= entry.getValue();
+ try {
+ saxParser.setProperty(name, value);
+ debugMessage("Set SAX optional property: "+name+" to: "+value,languageContext);
+ } catch (SAXException e) {
+ debugMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageContext);
+ }
+ }
+
+ // Set sax features and optional
+ Map features = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeatures(languageContext);
+ for (String key:features.keySet()) {
+ Boolean value=features.get(key);
+ saxParser.setFeature(key, value);
+ debugMessage("Set SAX feature: "+key+" to: "+value,languageContext);
+ }
+ Map featuresOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(languageContext);
+ for (String key:featuresOptional.keySet()) {
+ Boolean value=featuresOptional.get(key);
+ try {
+ saxParser.setFeature(key, value);
+ debugMessage("Set SAX optional feature: "+key+" to: "+value,languageContext);
+ } catch (SAXException e) {
+ debugMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageContext);
+ }
+ }
+
+ // check for required features
+ List requiredFeatures = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(languageContext);
+ for (String requiredFeature:requiredFeatures) {
+ debugMessage("Checking required SAX feature: "+requiredFeature,languageContext);
+ if (saxParser.getFeature(requiredFeature)==false) {
+ throw new IllegalStateException("Missing required feature: "+requiredFeature);
+ }
+ }
+
+ // Finally start parsing the xml input stream
+ Object requestInputSource = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SOURCE);
+ InputSource input = null;
+ InputStream inputStream = null;
+ if (requestInputSource instanceof InputSource) {
+ input = (InputSource)requestInputSource;
+ } else {
+ inputStream = (InputStream)languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_STREAM);
+ input = new InputSource(inputStream);
+ }
+
+ Object requestInputEncoding = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_ENCODING);
+ if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
+ input.setEncoding(requestInputEncoding.toString());
+ }
+ Object requestSystemId = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SYSTEM_ID);
+ if (requestSystemId!=null && requestSystemId instanceof String) {
+ input.setSystemId(requestSystemId.toString());
+ }
+
+ try {
+ saxParser.parse(input);
+ } finally {
+ if (inputStream!=null) {
+ inputStream.close();
+ }
+ }
+ }
+
+ private void debugMessage(String message,X4OLanguageContext languageContext) throws SAXException {
+ if (languageContext.hasX4ODebugWriter()) {
+ try {
+ languageContext.getX4ODebugWriter().debugPhaseMessage(message, X4OContentParser.class);
+ } catch (ElementException ee) {
+ throw new SAXException(ee);
+ }
+ }
+ }
+}
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 9c09bd7..ebba198 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
@@ -40,6 +40,7 @@ import org.x4o.xml.element.ElementException;
import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementNamespaceContext;
import org.x4o.xml.element.ElementNamespaceInstanceProvider;
+import org.x4o.xml.io.sax.ext.ContentWriter;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguageContext;
import org.x4o.xml.lang.X4OLanguageConfiguration;
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriter.java
new file mode 100644
index 0000000..8fff353
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriter.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004-2013, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.x4o.xml.io.sax.ext;
+
+import java.io.Writer;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * ContentWriterXml writes SAX content handler events to XML.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 3, 2013
+ */
+public abstract class AbstractContentWriter extends AbstractContentWriterLexical implements ContentWriter {
+
+ public AbstractContentWriter(Writer out, String encoding,String charNewLine, String charTab) {
+ super(out, encoding, charNewLine, charTab);
+ }
+
+ /**
+ * Starts and end then element.
+ * @see org.x4o.xml.io.sax.ext.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);
+ }
+}
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterXml.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterHandler.java
similarity index 75%
rename from x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterXml.java
rename to x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterHandler.java
index 884020b..838b0e1 100644
--- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterXml.java
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterHandler.java
@@ -20,12 +20,9 @@
* 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;
+package org.x4o.xml.io.sax.ext;
import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
@@ -36,19 +33,20 @@ import java.util.Stack;
import org.x4o.xml.io.XMLConstants;
import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
- * ContentWriterXml writes SAX content handler events to XML.
+ * AbstractContentWriterHandler writes SAX content handler events as XML.
*
* @author Willem Cazander
- * @version 1.0 Apr 17, 2005
+ * @version 1.0 May 3, 2013
*/
-public class ContentWriterXml implements ContentWriter {
+public class AbstractContentWriterHandler implements ContentHandler {
- public final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
+ protected final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
protected String encoding = null;
private String charNewline = null;
private String charTab = null;
@@ -59,14 +57,13 @@ public class ContentWriterXml implements ContentWriter {
private StringBuffer startElement = null;
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 ContentWriterXml(Writer out,String encoding,String charNewLine,String charTab) {
+ public AbstractContentWriterHandler(Writer out,String encoding,String charNewLine,String charTab) {
if (out==null) {
throw new NullPointerException("Can't write on null writer.");
}
@@ -74,10 +71,10 @@ public class ContentWriterXml implements ContentWriter {
encoding = XMLConstants.XML_DEFAULT_ENCODING;
}
if (charNewLine==null) {
- charNewLine = XMLConstants.CHAR_NEWLINE;
+ charNewLine = XMLConstants.CHAR_NEWLINE+"";
}
if (charTab==null) {
- charTab = XMLConstants.CHAR_TAB;
+ charTab = XMLConstants.CHAR_TAB+"";
}
this.out = out;
this.encoding = encoding;
@@ -87,52 +84,6 @@ public class ContentWriterXml implements ContentWriter {
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 ContentWriterXml(Writer out,String encoding) {
- this(out,encoding,null,null);
- }
-
- /**
- * Creates XmlWriter which prints to the OutputStream interface.
- * @param out The OutputStream to write to.
- * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
- */
- public ContentWriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException {
- this(new OutputStreamWriter(out, encoding),encoding);
- }
-
- /**
- * Creates XmlWriter which prints to the Writer interface.
- * @param out The writer to print the xml to.
- */
- public ContentWriterXml(Writer out) {
- this(out,null);
- }
-
- /**
- * Creates XmlWriter which prints to the OutputStream interface.
- * @param out The OutputStream to write to.
- * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
- */
- public ContentWriterXml(OutputStream out) throws UnsupportedEncodingException {
- this(new OutputStreamWriter(out, XMLConstants.XML_DEFAULT_ENCODING),XMLConstants.XML_DEFAULT_ENCODING);
- }
-
- /**
- * Creates XmlWriter which prints to the OutputStream interface.
- * @param out The OutputStream to write to.
- * @param encoding The OutputStream encoding.
- * @param charNewLine The newline char.
- * @param charTab The tab char.
- * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
- */
- 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 {
@@ -168,15 +119,6 @@ public class ContentWriterXml implements ContentWriter {
}
}
- /**
- * 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);
- }
-
/**
* @param uri The xml namespace uri.
* @param localName The local name of the xml tag.
@@ -186,7 +128,7 @@ public class ContentWriterXml implements ContentWriter {
*/
public void startElement(String uri, String localName, String name,Attributes atts) throws SAXException {
if (localName==null) {
- localName = "null"; // mmm rm ?
+ throw new SAXException("LocalName may not be null.");
}
if (XMLConstants.isNameString(localName)==false) {
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
@@ -282,10 +224,15 @@ public class ContentWriterXml implements ContentWriter {
String attributeName = XMLConstants.escapeAttributeName(atts.getLocalName(i));
String attributeValue = atts.getValue(i);
if (attributeValue==null) {
- attributeValue = "null";
+ attributeValue = "null"; // TODO: Add null value key to config.
+ }
+ String attributeValueSafe = XMLConstants.escapeAttributeValue(attributeValue);
+ boolean printNewLine = attributeValueSafe.length()>80; // TODO add config
+ if (i==0) {
+ startElement.append(' ');
+ } else if (!printNewLine) {
+ startElement.append(' ');
}
- startElement.append(' ');
-
if (XMLConstants.NULL_NS_URI.equals(attributeUri) | attributeUri ==null) {
startElement.append(attributeName);
} else {
@@ -293,10 +240,15 @@ public class ContentWriterXml implements ContentWriter {
startElement.append(XMLConstants.XMLNS_ASSIGN);
startElement.append(attributeName);
}
-
startElement.append("=\"");
- startElement.append(XMLConstants.escapeAttributeValue(attributeValue));
+ startElement.append(attributeValueSafe);
startElement.append('"');
+ if (printNewLine) {
+ startElement.append(XMLConstants.CHAR_NEWLINE);
+ for (int ii = 0; ii < indent+1; ii++) {
+ startElement.append(charTab);
+ }
+ }
}
}
@@ -382,7 +334,7 @@ public class ContentWriterXml implements ContentWriter {
}
/**
- * Prints xml characters.
+ * Prints xml characters and uses characters(java.lang.String) method.
*
* @param ch Character buffer.
* @param start The start index of the chars in the ch buffer.
@@ -395,20 +347,18 @@ public class ContentWriterXml implements ContentWriter {
}
/**
- * @see org.x4o.xml.io.sax.ContentWriter#characters(java.lang.String)
+ * Escape and prints xml characters.
+ * @see org.x4o.xml.io.sax.ext.ContentWriter#characters(java.lang.String)
*/
public void characters(String text) throws SAXException {
if (text==null) {
return;
}
- autoCloseStartElement();
- checkPrintedReturn(text);
- if (printCDATA) {
- text = XMLConstants.escapeCharactersCdata(text,"","");
- } else {
- text = XMLConstants.escapeCharacters(text);
- }
- write(text);
+ charactersRaw(XMLConstants.escapeCharacters(text));
+ }
+
+ public void characters(char c) throws SAXException {
+ characters(new char[]{c},0,1);
}
// move or remove ?
@@ -435,7 +385,7 @@ public class ContentWriterXml implements ContentWriter {
}
/**
- * @see org.x4o.xml.io.sax.ContentWriter#ignorableWhitespace(java.lang.String)
+ * @see org.x4o.xml.io.sax.ext.ContentWriter#ignorableWhitespace(java.lang.String)
*/
public void ignorableWhitespace(String text) throws SAXException {
if (text==null) {
@@ -444,6 +394,10 @@ public class ContentWriterXml implements ContentWriter {
autoCloseStartElement();
write(text); // TODO: check chars
}
+
+ public void ignorableWhitespace(char c) throws SAXException {
+ ignorableWhitespace(new char[]{c},0,1);
+ }
/**
* Prints xml instructions.
@@ -453,14 +407,26 @@ public class ContentWriterXml implements ContentWriter {
* @param data The data.
*/
public void processingInstruction(String target, String data) throws SAXException {
+ String targetLow = target.toLowerCase();
+ if (targetLow.startsWith(XMLConstants.XML)) {
+ throw new SAXException("Processing instruction may not start with xml.");
+ }
+ if (XMLConstants.isNameString(target)==false) {
+ throw new SAXException("Processing instruction target is invalid name; '"+target+"'");
+ }
+ if (XMLConstants.isCharString(data)==false) {
+ throw new SAXException("Processing instruction data is invalid char; '"+data+"'");
+ }
+ autoCloseStartElement();
+ write(charNewline);
writeIndent();
write(XMLConstants.PROCESS_START);
write(target);
write(' ');
write(data);
write(XMLConstants.PROCESS_END);
- write(charNewline);
writeFlush();
+ printReturn = true;
}
/**
@@ -496,7 +462,7 @@ public class ContentWriterXml implements ContentWriter {
}
/**
- * @see org.x4o.xml.io.sax.ContentWriter#comment(java.lang.String)
+ * @see org.x4o.xml.io.sax.ext.ContentWriter#comment(java.lang.String)
*/
public void comment(String text) throws SAXException {
if (text==null) {
@@ -514,65 +480,8 @@ public class ContentWriterXml implements ContentWriter {
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) {
+ if (value.indexOf(XMLConstants.CHAR_NEWLINE)>0) {
printReturn = true;
} else {
printReturn = false;
@@ -583,7 +492,7 @@ public class ContentWriterXml implements ContentWriter {
* Auto close the start element if working in printing event.
* @throws IOException When prints gives exception.
*/
- private void autoCloseStartElement() throws SAXException {
+ protected void autoCloseStartElement() throws SAXException {
if (startElement==null) {
return;
}
@@ -601,7 +510,7 @@ public class ContentWriterXml implements ContentWriter {
}
}
- private void writeFlush() throws SAXException {
+ protected void writeFlush() throws SAXException {
try {
out.flush();
} catch (IOException e) {
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterLexical.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterLexical.java
new file mode 100644
index 0000000..902b43a
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AbstractContentWriterLexical.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2004-2013, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.x4o.xml.io.sax.ext;
+
+import java.io.Writer;
+
+import org.x4o.xml.io.XMLConstants;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * ContentWriterXml writes SAX content handler events to XML.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 3, 2013
+ */
+public abstract class AbstractContentWriterLexical extends AbstractContentWriterHandler implements LexicalHandler {
+
+ protected boolean printCDATA = false;
+
+ /**
+ * Creates XmlWriter which prints to the Writer interface.
+ * @param out The writer to print the xml to.
+ */
+ public AbstractContentWriterLexical(Writer out,String encoding,String charNewLine,String charTab) {
+ super(out, encoding, charNewLine, charTab);
+ }
+
+ /**
+ * @see org.xml.sax.ext.LexicalHandler#startCDATA()
+ */
+ public void startCDATA() throws SAXException {
+ autoCloseStartElement();
+ charactersRaw(XMLConstants.CDATA_START);
+ printCDATA = true;
+ }
+
+ /**
+ * @see org.xml.sax.ext.LexicalHandler#endCDATA()
+ */
+ public void endCDATA() throws SAXException {
+ charactersRaw(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 {
+ charactersRaw(XMLConstants.XML_DOCTYPE);
+ charactersRaw(" ");
+ charactersRaw(name);
+ if (publicId!=null) {
+ charactersRaw(" ");
+ charactersRaw(publicId);
+ }
+ if (systemId!=null) {
+ charactersRaw(" \"");
+ charactersRaw(systemId);
+ charactersRaw("\"");
+ }
+ charactersRaw(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 {
+ }
+
+ /**
+ * @see org.x4o.xml.io.sax.ext.AbstractContentWriterHandler#characters(char[], int, int)
+ */
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ characters(new String(ch, start, length));
+ }
+
+ /**
+ * @see org.x4o.xml.io.sax.ext.AbstractContentWriterHandler#characters(java.lang.String)
+ */
+ @Override
+ public void characters(String text) throws SAXException {
+ if (printCDATA) {
+ charactersRaw(XMLConstants.escapeCharactersCdata(text,"",""));
+ } else {
+ super.characters(text);
+ }
+ }
+}
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/AttributeMap.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AttributeMap.java
similarity index 99%
rename from x4o-driver/src/main/java/org/x4o/xml/io/sax/AttributeMap.java
rename to x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AttributeMap.java
index 1a36dc4..66b41e0 100644
--- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/AttributeMap.java
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/AttributeMap.java
@@ -20,7 +20,7 @@
* 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;
+package org.x4o.xml.io.sax.ext;
import org.xml.sax.Attributes;
import java.util.ArrayList;
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/ext/ContentWriter.java
similarity index 94%
rename from x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriter.java
rename to x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriter.java
index ad45bb7..2fbb830 100644
--- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriter.java
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriter.java
@@ -20,7 +20,7 @@
* 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;
+package org.x4o.xml.io.sax.ext;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -49,6 +49,10 @@ public interface ContentWriter extends ContentHandler,LexicalHandler {
void comment(String text) throws SAXException;
void ignorableWhitespace(String text) throws SAXException;
+
+ void ignorableWhitespace(char c) throws SAXException;
void characters(String text) throws SAXException;
+
+ void characters(char c) 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/ext/ContentWriterConfig.java
similarity index 98%
rename from x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterConfig.java
rename to x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterConfig.java
index 7620ea1..963ffcb 100644
--- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterConfig.java
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterConfig.java
@@ -20,7 +20,7 @@
* 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;
+package org.x4o.xml.io.sax.ext;
/**
* ContentWriterConfig Defines config options for ContentWriter.
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/ext/ContentWriterHtml.java
similarity index 87%
rename from x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterHtml.java
rename to x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterHtml.java
index 23941cf..6c8daaa 100644
--- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ContentWriterHtml.java
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterHtml.java
@@ -20,12 +20,11 @@
* 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;
+package org.x4o.xml.io.sax.ext;
import java.io.Writer;
import java.util.Calendar;
-import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -35,7 +34,7 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Willem Cazander
* @version 1.0 Apr 30, 2013
*/
-public class ContentWriterHtml extends ContentWriterXml {
+public class ContentWriterHtml extends ContentWriterXmlTag {
public ContentWriterHtml(Writer out,String encoding,String charNewLine,String charTab) {
super(out,encoding,charNewLine,charTab);
@@ -63,7 +62,7 @@ public class ContentWriterHtml extends ContentWriterXml {
}
public void printHeadTitle(String title) throws SAXException {
- printTagText("title",title);
+ printTagCharacters(Tag.title,title);
}
public void printHeadMetaContentType() throws SAXException {
@@ -156,24 +155,13 @@ public class ContentWriterHtml extends ContentWriterXml {
}
printTagEnd(Tag.a);
}
-
- private void printTagText(String tag,String text) throws SAXException {
- startElement ("", tag, "", EMPTY_ATTRIBUTES);
- characters(text);
- endElement ("",tag , "");
+ public void printTagCharacters(Tag tag,String text,String tagClass) throws SAXException {
+ printTagCharacters(tag,text,tagClass,null);
}
- 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);
+ public void printTagCharacters(Tag tag,String text,String tagClass,String tagId) throws SAXException {
+ printTagStart(tag,tagClass,tagId,null);
if (text==null) {
text = " ";
}
@@ -181,21 +169,21 @@ public class ContentWriterHtml extends ContentWriterXml {
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);
+ printTagStart(tag,tagClass,null,null);
}
- public void printTagStart(Tag tag,String tagClass,String tagId) throws SAXException {
- printTagStart(tag,tagClass,tagId,null);
+ public void printTagStart(Tag tag,Enum> tagClassEnum) throws SAXException {
+ printTagStart(tag,tagClassEnum,null);
+ }
+
+ public void printTagStart(Tag tag,Enum> tagClassEnum,String tagId) throws SAXException {
+ printTagStart(tag,tagClassEnum,tagId,null);
+ }
+
+ public void printTagStart(Tag tag,Enum> tagClassEnum,String tagId,String typeId) throws SAXException {
+ printTagStart(tag,tagClassEnum.name(),tagId,typeId);
}
public void printTagStart(Tag tag,String tagClass,String tagId,String typeId) throws SAXException {
@@ -212,14 +200,6 @@ public class ContentWriterHtml extends ContentWriterXml {
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 */
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterTag.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterTag.java
new file mode 100644
index 0000000..ef1ed3d
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterTag.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004-2013, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.x4o.xml.io.sax.ext;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * ContentWriterTag writes enum tags as xml.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 3, 2013
+ */
+public interface ContentWriterTag> extends ContentWriter {
+
+ String getTagNamespaceUri();
+
+ void printTagStartEnd(T tag) throws SAXException;
+
+ void printTagStartEnd(T tag,Attributes atts) throws SAXException;
+
+ void printTagStart(T tag) throws SAXException;
+
+ void printTagStart(T tag,Attributes atts) throws SAXException;
+
+ void printTagEnd(T tag) throws SAXException;
+
+ void printTagCharacters(T tag,String text) throws SAXException;
+}
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXml.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXml.java
new file mode 100644
index 0000000..9b5df3c
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXml.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2004-2013, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.x4o.xml.io.sax.ext;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+import org.x4o.xml.io.XMLConstants;
+
+/**
+ * ContentWriterXml writes SAX content handler events to XML.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 17, 2005
+ */
+public class ContentWriterXml extends AbstractContentWriter {
+
+ /**
+ * Creates XmlWriter which prints to the Writer interface.
+ * @param out The writer to print the xml to.
+ */
+ public ContentWriterXml(Writer out,String encoding,String charNewLine,String charTab) {
+ super(out, encoding, charNewLine, charTab);
+ }
+
+ /**
+ * Creates XmlWriter which prints to the Writer interface.
+ * @param out The writer to print the xml to.
+ */
+ public ContentWriterXml(Writer out,String encoding) {
+ this(out,encoding,null,null);
+ }
+
+ /**
+ * Creates XmlWriter which prints to the OutputStream interface.
+ * @param out The OutputStream to write to.
+ * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
+ */
+ public ContentWriterXml(OutputStream out,String encoding) throws UnsupportedEncodingException {
+ this(new OutputStreamWriter(out, encoding),encoding);
+ }
+
+ /**
+ * Creates XmlWriter which prints to the Writer interface.
+ * @param out The writer to print the xml to.
+ */
+ public ContentWriterXml(Writer out) {
+ this(out,null);
+ }
+
+ /**
+ * Creates XmlWriter which prints to the OutputStream interface.
+ * @param out The OutputStream to write to.
+ * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
+ */
+ public ContentWriterXml(OutputStream out) throws UnsupportedEncodingException {
+ this(new OutputStreamWriter(out, XMLConstants.XML_DEFAULT_ENCODING),XMLConstants.XML_DEFAULT_ENCODING);
+ }
+
+ /**
+ * Creates XmlWriter which prints to the OutputStream interface.
+ * @param out The OutputStream to write to.
+ * @param encoding The OutputStream encoding.
+ * @param charNewLine The newline char.
+ * @param charTab The tab char.
+ * @throws UnsupportedEncodingException Is thrown when UTF-8 can't we printed.
+ */
+ public ContentWriterXml(OutputStream out,String encoding,String charNewLine,String charTab) throws UnsupportedEncodingException {
+ this(new OutputStreamWriter(out, encoding),encoding,charNewLine,charTab);
+ }
+}
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXmlTag.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXmlTag.java
new file mode 100644
index 0000000..30d473b
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXmlTag.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2013, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.x4o.xml.io.sax.ext;
+
+import java.io.Writer;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * ContentWriterXml writes SAX content handler events to XML.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 3, 2013
+ */
+public class ContentWriterXmlTag> extends ContentWriterXml implements ContentWriterTag {
+
+ public ContentWriterXmlTag(Writer out,String encoding,String charNewLine,String charTab) {
+ super(out, encoding, charNewLine, charTab);
+ }
+
+ public String getTagNamespaceUri() {
+ return "";
+ }
+
+ public void printTagStartEnd(T tag,Attributes atts) throws SAXException {
+ printTagStart(tag,atts);
+ printTagEnd(tag);
+ }
+
+ public void printTagStartEnd(T tag) throws SAXException {
+ printTagStart(tag);
+ printTagEnd(tag);
+ }
+
+ public void printTagStart(T tag) throws SAXException {
+ printTagStart(tag,EMPTY_ATTRIBUTES);
+ }
+
+ public void printTagStart(T tag,Attributes atts) throws SAXException {
+ startElement (getTagNamespaceUri(), tag.name(), "", atts);
+ }
+
+ public void printTagEnd(T tag) throws SAXException {
+ endElement (getTagNamespaceUri(),tag.name() , "");
+ }
+
+ public void printTagCharacters(T tag,String text) throws SAXException {
+ printTagStart(tag);
+ if (text==null) {
+ text = " ";
+ }
+ characters(text);
+ printTagEnd(tag);
+ }
+}
diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXsd.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXsd.java
new file mode 100644
index 0000000..ac3a3e0
--- /dev/null
+++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/ContentWriterXsd.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2004-2013, Willem Cazander
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.x4o.xml.io.sax.ext;
+
+import java.io.Writer;
+
+import org.x4o.xml.io.XMLConstants;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * ContentWriterXsd writes XSD events as SAX events to XML.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 3, 2013
+ */
+public class ContentWriterXsd extends ContentWriterXmlTag {
+
+ public ContentWriterXsd(Writer out,String encoding,String charNewLine,String charTab) {
+ super(out,encoding,charNewLine,charTab);
+ }
+
+ public String getTagNamespaceUri() {
+ return XMLConstants.XML_SCHEMA_NS_URI;
+ }
+
+ public void printXsdImport(String namespace,String schemaLocation) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute ("", "namespace", "", "", namespace);
+ atts.addAttribute ("", "schemaLocation", "", "", schemaLocation);
+ startElement (getTagNamespaceUri(), "import", "", atts);
+ endElement (getTagNamespaceUri(), "import", ""); // import is keyword
+ }
+
+ public void printXsdDocumentation(String description) throws SAXException {
+ if (description==null) {
+ return;
+ }
+ printTagStart(Tag.annotation);
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute ("", "xml:lang", "", "", "en");
+ printTagStart(Tag.documentation,atts);
+ characters(description);
+ printTagEnd(Tag.documentation);
+ printTagEnd(Tag.annotation);
+ }
+
+ public void printXsdElementAttribute(String name,String type,String description) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute ("", "name", "", "", name);
+ atts.addAttribute ("", "type", "", "", type);
+ printTagStart(Tag.attribute,atts);
+ printXsdDocumentation(description);
+ printTagEnd(Tag.attribute);
+ }
+
+ public enum Tag {
+ all,annotation,any,anyAttribute,appinfo,attribute,attributeGroup,
+ choise,complexContent,complexType,documentation,element,extension,
+ field,group,/*_import,*/include,key,keyref,list,notation,
+ redefine,restriction,schema,selector,sequence,
+ simpleContent,simpleType,unoin,unique
+ }
+
+}
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 61a478d..5db6201 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
@@ -22,7 +22,6 @@
*/
package org.x4o.xml.lang.phase;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -45,21 +44,16 @@ 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.X4OContentParser;
import org.x4o.xml.io.sax.X4ODebugWriter;
-import org.x4o.xml.io.sax.X4OEntityResolver;
-import org.x4o.xml.io.sax.X4OErrorHandler;
-import org.x4o.xml.io.sax.X4OTagHandler;
+import org.x4o.xml.io.sax.ext.ContentWriter;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguageContext;
import org.x4o.xml.lang.X4OLanguageClassLoader;
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.helpers.AttributesImpl;
-import org.xml.sax.helpers.XMLReaderFactory;
/**
* Factory which can create X4OPhaseHandlers for all the predefined phases used in default x4o language parsing.
@@ -144,8 +138,6 @@ public class X4OPhaseLanguageRead {
}
}
-
-
/**
* Creates the startX4OPhase which is a empty meta phase.
*/
@@ -198,94 +190,8 @@ public class X4OPhaseLanguageRead {
}
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
try {
- //XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
- //config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
- //SAXParser parser = new SAXParser(config);
-
- // Create Sax parser with x4o tag handler
- X4OTagHandler xth = new X4OTagHandler(languageContext);
- XMLReader saxParser = XMLReaderFactory.createXMLReader();
- saxParser.setErrorHandler(new X4OErrorHandler(languageContext));
- saxParser.setEntityResolver(new X4OEntityResolver(languageContext));
- saxParser.setContentHandler(xth);
- saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
- saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
-
- // Set properties and optional
- Map saxParserProperties = languageContext.getLanguage().getLanguageConfiguration().getSAXParserProperties(languageContext);
- for (Map.Entry entry:saxParserProperties.entrySet()) {
- String name = entry.getKey();
- Object value= entry.getValue();
- saxParser.setProperty(name, value);
- debugPhaseMessage("Set SAX property: "+name+" to: "+value,this,languageContext);
- }
- Map saxParserPropertiesOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserPropertiesOptional(languageContext);
- for (Map.Entry entry:saxParserPropertiesOptional.entrySet()) {
- String name = entry.getKey();
- Object value= entry.getValue();
- try {
- saxParser.setProperty(name, value);
- debugPhaseMessage("Set SAX optional property: "+name+" to: "+value,this,languageContext);
- } catch (SAXException e) {
- debugPhaseMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),this,languageContext);
- }
- }
-
- // Set sax features and optional
- Map features = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeatures(languageContext);
- for (String key:features.keySet()) {
- Boolean value=features.get(key);
- saxParser.setFeature(key, value);
- debugPhaseMessage("Set SAX feature: "+key+" to: "+value,this,languageContext);
- }
- Map featuresOptional = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesOptional(languageContext);
- for (String key:featuresOptional.keySet()) {
- Boolean value=featuresOptional.get(key);
- try {
- saxParser.setFeature(key, value);
- debugPhaseMessage("Set SAX optional feature: "+key+" to: "+value,this,languageContext);
- } catch (SAXException e) {
- debugPhaseMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),this,languageContext);
- }
- }
-
- // check for required features
- List requiredFeatures = languageContext.getLanguage().getLanguageConfiguration().getSAXParserFeaturesRequired(languageContext);
- for (String requiredFeature:requiredFeatures) {
- debugPhaseMessage("Checking required SAX feature: "+requiredFeature,this,languageContext);
- if (saxParser.getFeature(requiredFeature)==false) {
- Exception e = new IllegalStateException("Missing required feature: "+requiredFeature);
- throw new X4OPhaseException(this,e);
- }
- }
-
- // Finally start parsing the xml input stream
- Object requestInputSource = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SOURCE);
- InputSource input = null;
- InputStream inputStream = null;
- if (requestInputSource instanceof InputSource) {
- input = (InputSource)requestInputSource;
- } else {
- inputStream = (InputStream)languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_STREAM);
- input = new InputSource(inputStream);
- }
-
- Object requestInputEncoding = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_ENCODING);
- if (requestInputEncoding!=null && requestInputEncoding instanceof String) {
- input.setEncoding(requestInputEncoding.toString());
- }
- Object requestSystemId = languageContext.getLanguageProperty(X4OLanguageProperty.READER_INPUT_SYSTEM_ID);
- if (requestSystemId!=null && requestSystemId instanceof String) {
- input.setSystemId(requestSystemId.toString());
- }
-
- try {
- saxParser.parse(input);
- } finally {
- if (inputStream!=null) {
- inputStream.close();
- }
- }
+ X4OContentParser parser = new X4OContentParser();
+ parser.parse(languageContext);
} catch (Exception e) {
throw new X4OPhaseException(this,e);
}
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 f150666..e52ff58 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
@@ -27,6 +27,8 @@ import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,7 +44,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.ContentWriterXml;
+import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguageContext;
import org.x4o.xml.lang.X4OLanguageProperty;
@@ -189,8 +191,11 @@ public class X4OPhaseLanguageWrite {
}
public void runElementPhase(Element element) throws X4OPhaseException {
}
- boolean schemaUriPrint;
- String schemaUriRoot;
+
+ private AttributeEntryComparator attributeEntryComparator = new AttributeEntryComparator();
+ private boolean schemaUriPrint;
+ private String schemaUriRoot;
+
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException {
OutputStream out = (OutputStream)languageContext.getLanguageProperty(X4OLanguageProperty.WRITER_OUTPUT_STREAM);
try {
@@ -200,8 +205,8 @@ public class X4OPhaseLanguageWrite {
schemaUriPrint = languageContext.getLanguagePropertyBoolean(X4OLanguageProperty.WRITER_SCHEMA_URI_PRINT);
schemaUriRoot = languageContext.getLanguagePropertyString(X4OLanguageProperty.WRITER_SCHEMA_URI_ROOT);
if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
- if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE; }
- if (charTab==null) { charTab = XMLConstants.CHAR_TAB; }
+ if (charNew==null) { charNew = XMLConstants.CHAR_NEWLINE+""; }
+ if (charTab==null) { charTab = XMLConstants.CHAR_TAB+""; }
Element root = languageContext.getRootElement();
if (schemaUriRoot==null) {
@@ -272,15 +277,18 @@ public class X4OPhaseLanguageWrite {
}
return result;
}
-
- private void writeTree(ContentWriterXml writer,Element element,boolean isRoot) throws SAXException, ElementObjectPropertyValueException {
- AttributesImpl atts = new AttributesImpl();
-
- if (isRoot && schemaUriPrint) {
- String rootUri = findElementUri(element);
- writer.startPrefixMapping("xsi", XMLConstants.XML_SCHEMA_INSTANCE_NS_URI);
- atts.addAttribute ("xsi", "schemaLocation", "", "", rootUri+" "+schemaUriRoot);
+ class AttributeEntry {
+ String id;
+ String value;
+ Integer writeOrder;
+ }
+ class AttributeEntryComparator implements Comparator {
+ public int compare(AttributeEntry o1, AttributeEntry o2) {
+ return o1.writeOrder.compareTo(o2.writeOrder);
}
+ }
+ private void writeTree(ContentWriterXml writer,Element element,boolean isRoot) throws SAXException, ElementObjectPropertyValueException {
+ List attr = new ArrayList(20);
if (element.getElementClass().getAutoAttributes()!=null && element.getElementClass().getAutoAttributes()==false) {
for (ElementClassAttribute eca:element.getElementClass().getElementClassAttributes()) {
if (eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
@@ -291,19 +299,29 @@ public class X4OPhaseLanguageWrite {
if (value==null) {
continue;
}
- atts.addAttribute ("", eca.getId(), "", "", ""+value);
+ AttributeEntry e = new AttributeEntry();
+ e.id = eca.getId();
+ e.value = ""+value;
+ e.writeOrder = calcOrderNumber(e.id,eca.getWriteOrder());
+ attr.add(e);
}
} else {
for (String p:getProperties(element.getElementObject().getClass())) {
-
+ Integer writeOrder = null;
ElementClassAttribute eca = element.getElementClass().getElementClassAttributeByName(p);
+ if (eca!=null) {
+ writeOrder = eca.getWriteOrder();
+ }
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()) {
continue;
}
boolean writeValue = true;
for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject().getClass())) {
eca = ei.getElementClassAttributeByName(p);
+ if (eca!=null && writeOrder==null) {
+ writeOrder = eca.getWriteOrder(); // add interface but allow override local
+ }
if (eca!=null && eca.getRunBeanValue()!=null && eca.getRunBeanValue()==false) {
writeValue = false;
break;
@@ -321,10 +339,30 @@ public class X4OPhaseLanguageWrite {
if (value instanceof List || value instanceof Collection) {
continue; // TODO; filter on type of childeren
}
- atts.addAttribute ("", p, "", "", ""+value);
+ AttributeEntry e = new AttributeEntry();
+ e.id = p;
+ e.value = ""+value;
+ e.writeOrder = calcOrderNumber(e.id,writeOrder);
+ attr.add(e);
}
}
+ // Create atts to write and append schema first.
+ AttributesImpl atts = new AttributesImpl();
+ if (isRoot && schemaUriPrint) {
+ String rootUri = findElementUri(element);
+ writer.startPrefixMapping("xsi", XMLConstants.XML_SCHEMA_INSTANCE_NS_URI);
+ atts.addAttribute ("xsi", "schemaLocation", "", "", rootUri+" "+schemaUriRoot);
+ }
+
+ // Sort attributes in natural order of localName and add to attributes
+ Collections.sort(attr, attributeEntryComparator);
+ for (int i=0;i3) {
+ return (name.charAt(0) * 1000) + (name.charAt(1) * 100) + (name.charAt(2) * 10) + (name.charAt(3) * 1);
+ }
+ throw new IllegalArgumentException("Can't calculate order of empty name.");
+ }
+
private String findElementUri(Element e) {
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) {
for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) {
diff --git a/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java b/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java
index 39f2765..d6845be 100644
--- a/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java
+++ b/x4o-driver/src/test/java/org/x4o/xml/eld/EldParserTest.java
@@ -22,25 +22,6 @@
*/
package org.x4o.xml.eld;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.x4o.xml.X4ODriver;
-import org.x4o.xml.X4ODriverManager;
-import org.x4o.xml.eld.EldDriver;
-import org.x4o.xml.element.Element;
-import org.x4o.xml.element.Element.ElementType;
-import org.x4o.xml.element.ElementClass;
-import org.x4o.xml.element.ElementNamespaceContext;
-import org.x4o.xml.io.X4OReader;
-import org.x4o.xml.io.X4OSchemaWriter;
-import org.x4o.xml.io.X4OWriter;
-import org.x4o.xml.lang.X4OLanguageModule;
-import org.x4o.xml.lang.X4OLanguageContext;
-import org.x4o.xml.lang.X4OLanguagePropertyKeys;
-import org.x4o.xml.test.TestDriver;
-
import junit.framework.TestCase;
/**
@@ -79,17 +60,16 @@ public class EldParserTest extends TestCase {
public void testRunEldParserCore() throws Exception {
- X4ODriver driver = (X4ODriver)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
-
- X4OReader reader = driver.createReader();
+ //X4ODriver driver = (X4ODriver)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
+ //X4OReader reader = driver.createReader();
//EldDriver parser = new EldDriver(true);
- reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
+ //reader.setProperty(X4OLanguagePropertyKeys.PHASE_SKIP_RELEASE, true);
try {
- X4OLanguageModule module = reader.readResource("META-INF/eld/eld-lang.eld");
- List resultTags = new ArrayList(50);
- for (ElementNamespaceContext ns:module.getElementNamespaceContexts()) {
-
- }
+ //X4OLanguageModule module = reader.readResource("META-INF/eld/eld-lang.eld");
+ //List resultTags = new ArrayList(50);
+ //for (ElementNamespaceContext ns:module.getElementNamespaceContexts()) {
+ //
+ //}
/*
for (Element e:parser.getDriver().getElementLanguage().getRootElement().getAllChilderen()) {
//System.out.println("obj: "+e.getElementObject());
@@ -117,8 +97,8 @@ public class EldParserTest extends TestCase {
public void testRunEldParser() throws Exception {
//EldDriver parser = new EldDriver(false);
//parser.parseResource("META-INF/test/test-lang.eld");
- X4ODriver driver = (X4ODriver)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
- X4OReader reader = driver.createReader();
- reader.readResource("META-INF/test/test-lang.eld");
+ //X4ODriver driver = (X4ODriver)X4ODriverManager.getX4ODriver(EldDriver.LANGUAGE_NAME);
+ //X4OReader reader = driver.createReader();
+ //reader.readResource("META-INF/test/test-lang.eld");
}
}
diff --git a/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterAttributeTest.java b/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterAttributeTest.java
new file mode 100644
index 0000000..519ea21
--- /dev/null
+++ b/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterAttributeTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Scanner;
+
+import org.x4o.xml.X4ODriver;
+import org.x4o.xml.io.X4OReader;
+import org.x4o.xml.test.TestDriver;
+import org.x4o.xml.test.models.TestObjectRoot;
+
+import junit.framework.TestCase;
+
+/**
+ * X4OWriterAttributeTest tests xml write attribute write order.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 19, 2013
+ */
+public class X4OWriterAttributeTest extends TestCase {
+
+
+ private File createOutputFile() throws IOException {
+ File outputFile = File.createTempFile("test-writer-attr", ".xml");
+ outputFile.deleteOnExit();
+ return outputFile;
+ }
+
+ public void testWriteAttrNatural() throws Exception {
+ File outputFile = createOutputFile();
+ X4ODriver driver = TestDriver.getInstance();
+ X4OReader reader = driver.createReader();
+ X4OWriter writer = driver.createWriter();
+
+ TestObjectRoot root = reader.readResource("tests/writer/test-attribute-order.xml");
+ writer.writeFile(root, outputFile);
+ String text = new Scanner( outputFile ).useDelimiter("\\A").next();
+ outputFile.delete();
+
+ assertTrue(text.startsWith(""));
+ assertTrue(text.contains("TestAttributeOrderChildNatural"+
+ " aaaName=\"NAME_1\" aabName=\"NAME_2\" aacName=\"NAME_3\""+
+ " abaName=\"NAME_4\" abbName=\"NAME_5\" abcName=\"NAME_6\""+
+ " caaName=\"NAME_7\" cabName=\"NAME_8\" cacName=\"NAME_9\""));
+ }
+
+ public void testWriteAttrOrdered() throws Exception {
+ File outputFile = createOutputFile();
+ X4ODriver driver = TestDriver.getInstance();
+ X4OReader reader = driver.createReader();
+ X4OWriter writer = driver.createWriter();
+
+ TestObjectRoot root = reader.readResource("tests/writer/test-attribute-order.xml");
+ writer.writeFile(root, outputFile);
+ String text = new Scanner( outputFile ).useDelimiter("\\A").next();
+ outputFile.delete();
+
+ assertTrue(text.startsWith(""));
+ assertTrue(text.contains("custom-ordered-child"+
+ " cacName=\"NAME_9\" cabName=\"NAME_8\" caaName=\"NAME_7\""+
+ " abcName=\"NAME_6\" abbName=\"NAME_5\" abaName=\"NAME_4\""+
+ " aaaName=\"NAME_1\" aabName=\"NAME_2\" aacName=\"NAME_3\""));
+ }
+}
diff --git a/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterTest.java b/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterTest.java
index 6552fbe..add5a4e 100644
--- a/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterTest.java
+++ b/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterTest.java
@@ -40,10 +40,10 @@ import org.x4o.xml.test.swixml.SwingEngine;
import junit.framework.TestCase;
/**
- * X4OWriterTest runs parser with debug output.
+ * X4OWriterTest test xml writer output.
*
* @author Willem Cazander
- * @version 1.0 Aug 26, 2012
+ * @version 1.0 Apr 28, 2013
*/
public class X4OWriterTest extends TestCase {
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
index 1ed7bc0..19c47d0 100644
--- 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
@@ -24,6 +24,7 @@ package org.x4o.xml.io.sax;
import java.io.StringWriter;
+import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -292,4 +293,121 @@ public class ContentWriterXmlTest extends TestCase {
assertTrue(e.getMessage().contains("2"));
assertTrue(e.getMessage().contains("open"));
}
+
+ public void testProcessingInstruction() throws Exception {
+ StringWriter outputWriter = new StringWriter();
+ ContentWriterXml writer = new ContentWriterXml(outputWriter);
+ AttributesImpl atts = new AttributesImpl();
+
+ Exception e = null;
+ try {
+ writer.startDocument();
+ writer.processingInstruction("target", "data");
+ writer.startElement("", "test", "", atts);
+ writer.endElement("", "test", "");
+ writer.endDocument();
+ } catch (Exception catchE) {
+ e = catchE;
+ }
+ String output = outputWriter.toString();
+ assertNull(e);
+ assertNotNull(output);
+ assertTrue(output.length()>0);
+ assertTrue(output.equals("\n\n"));
+ }
+
+ public void testProcessingInstructionInline() throws Exception {
+ StringWriter outputWriter = new StringWriter();
+ ContentWriterXml writer = new ContentWriterXml(outputWriter);
+ AttributesImpl atts = new AttributesImpl();
+
+ Exception e = null;
+ try {
+ writer.startDocument();
+ writer.processingInstruction("target", "data");
+ writer.startElement("", "test", "", atts);
+ writer.processingInstruction("target-doc", "data-doc");
+ writer.endElement("", "test", "");
+ writer.endDocument();
+ } catch (Exception catchE) {
+ e = catchE;
+ }
+ String output = outputWriter.toString();
+ assertNull(e);
+ assertNotNull(output);
+ assertTrue(output.length()>0);
+ assertTrue(output.equals("\n\n\n\t\n"));
+ }
+
+ public void testProcessingInstructionTargetXmlPrefix() throws Exception {
+ StringWriter outputWriter = new StringWriter();
+ ContentWriterXml writer = new ContentWriterXml(outputWriter);
+ Exception e = null;
+ try {
+ writer.startDocument();
+ writer.processingInstruction("xmlPrefix", "isInvalid");
+ } catch (Exception catchE) {
+ e = catchE;
+ }
+ assertNotNull(e);
+ assertEquals(SAXException.class, e.getClass());
+ assertTrue(e.getMessage().contains("instruction"));
+ assertTrue(e.getMessage().contains("start with xml"));
+ }
+
+ public void testProcessingInstructionTargetNoneNameChar() throws Exception {
+ StringWriter outputWriter = new StringWriter();
+ ContentWriterXml writer = new ContentWriterXml(outputWriter);
+ Exception e = null;
+ try {
+ writer.startDocument();
+ writer.processingInstruction("4Prefix", "isInvalid");
+ } catch (Exception catchE) {
+ e = catchE;
+ }
+ assertNotNull(e);
+ assertEquals(SAXException.class, e.getClass());
+ assertTrue(e.getMessage().contains("instruction"));
+ assertTrue(e.getMessage().contains("invalid name"));
+ assertTrue(e.getMessage().contains("4Prefix"));
+ }
+
+ public void testProcessingInstructionDataNoneChar() throws Exception {
+ StringWriter outputWriter = new StringWriter();
+ ContentWriterXml writer = new ContentWriterXml(outputWriter);
+ Exception e = null;
+ try {
+ writer.startDocument();
+ writer.processingInstruction("target", "isInvalidChar="+0xD800);
+ } catch (Exception catchE) {
+ e = catchE;
+ }
+ assertNotNull(e);
+ assertEquals(SAXException.class, e.getClass());
+ assertTrue(e.getMessage().contains("instruction"));
+ assertTrue(e.getMessage().contains("invalid char"));
+ assertTrue(e.getMessage().contains("isInvalidChar=55296"));
+ }
+
+ public void testAttributeValueLongData() throws Exception {
+ StringWriter outputWriter = new StringWriter();
+ ContentWriterXml writer = new ContentWriterXml(outputWriter);
+
+ AttributesImpl atts = new AttributesImpl();
+ String data = "_FOR_FOO_BAR";
+ String dataValue = "LOOP";
+ for (int i=0;i<15;i++) {
+ atts.addAttribute("", "attr"+i, "", "", dataValue+=data);
+ }
+ writer.startDocument();
+ writer.startElement("", "test", "", atts);
+ writer.startElement("", "testNode", "", new AttributesImpl());
+ writer.endElement("", "testNode", "");
+ writer.endElement("", "test", "");
+ writer.endDocument();
+
+ String output = outputWriter.toString();
+ assertNotNull(output);
+ assertTrue(output.split("\n").length==13);
+ }
}
diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/TagHandlerTest.java b/x4o-driver/src/test/java/org/x4o/xml/test/TagHandlerTest.java
index 0e59d59..7be9748 100644
--- a/x4o-driver/src/test/java/org/x4o/xml/test/TagHandlerTest.java
+++ b/x4o-driver/src/test/java/org/x4o/xml/test/TagHandlerTest.java
@@ -22,12 +22,8 @@
*/
package org.x4o.xml.test;
-import java.io.File;
-import java.io.FileOutputStream;
-
import org.x4o.xml.X4ODriver;
import org.x4o.xml.io.X4OReader;
-import org.x4o.xml.lang.X4OLanguagePropertyKeys;
import org.x4o.xml.test.models.TestObjectRoot;
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 dcafe6e..06bf072 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.ContentWriterXml;
+import org.x4o.xml.io.sax.ext.ContentWriterXml;
/**
* InlinePropertiesElement to test
diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChild.java b/x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChild.java
new file mode 100644
index 0000000..822ec7b
--- /dev/null
+++ b/x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChild.java
@@ -0,0 +1,148 @@
+/*
+ * 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.test.models;
+
+public class TestAttributeOrderChild extends TestObjectChild {
+
+ private String aaaName = null;
+ private String aabName = null;
+ private String aacName = null;
+
+ private String abaName = null;
+ private String abbName = null;
+ private String abcName = null;
+
+ private String caaName = null;
+ private String cabName = null;
+ private String cacName = null;
+
+ /**
+ * @return the caaName
+ */
+ public String getCaaName() {
+ return caaName;
+ }
+ /**
+ * @param caaName the caaName to set
+ */
+ public void setCaaName(String caaName) {
+ this.caaName = caaName;
+ }
+ /**
+ * @return the cabName
+ */
+ public String getCabName() {
+ return cabName;
+ }
+ /**
+ * @param cabName the cabName to set
+ */
+ public void setCabName(String cabName) {
+ this.cabName = cabName;
+ }
+ /**
+ * @return the cacName
+ */
+ public String getCacName() {
+ return cacName;
+ }
+ /**
+ * @param cacName the cacName to set
+ */
+ public void setCacName(String cacName) {
+ this.cacName = cacName;
+ }
+
+ /**
+ * @return the aaaName
+ */
+ public String getAaaName() {
+ return aaaName;
+ }
+ /**
+ * @param aaaName the aaaName to set
+ */
+ public void setAaaName(String aaaName) {
+ this.aaaName = aaaName;
+ }
+ /**
+ * @return the aabName
+ */
+ public String getAabName() {
+ return aabName;
+ }
+ /**
+ * @param aabName the aabName to set
+ */
+ public void setAabName(String aabName) {
+ this.aabName = aabName;
+ }
+ /**
+ * @return the aacName
+ */
+ public String getAacName() {
+ return aacName;
+ }
+ /**
+ * @param aacName the aacName to set
+ */
+ public void setAacName(String aacName) {
+ this.aacName = aacName;
+ }
+ /**
+ * @return the abaName
+ */
+ public String getAbaName() {
+ return abaName;
+ }
+ /**
+ * @param abaName the abaName to set
+ */
+ public void setAbaName(String abaName) {
+ this.abaName = abaName;
+ }
+ /**
+ * @return the abbName
+ */
+ public String getAbbName() {
+ return abbName;
+ }
+ /**
+ * @param abbName the abbName to set
+ */
+ public void setAbbName(String abbName) {
+ this.abbName = abbName;
+ }
+ /**
+ * @return the abcName
+ */
+ public String getAbcName() {
+ return abcName;
+ }
+ /**
+ * @param abcName the abcName to set
+ */
+ public void setAbcName(String abcName) {
+ this.abcName = abcName;
+ }
+}
diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChildNatural.java b/x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChildNatural.java
new file mode 100644
index 0000000..7cb05ef
--- /dev/null
+++ b/x4o-driver/src/test/java/org/x4o/xml/test/models/TestAttributeOrderChildNatural.java
@@ -0,0 +1,27 @@
+/*
+ * 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.test.models;
+
+public class TestAttributeOrderChildNatural extends TestAttributeOrderChild {
+
+}
diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/models/TestBean.java b/x4o-driver/src/test/java/org/x4o/xml/test/models/TestBean.java
index 9d37caa..00e4a92 100644
--- a/x4o-driver/src/test/java/org/x4o/xml/test/models/TestBean.java
+++ b/x4o-driver/src/test/java/org/x4o/xml/test/models/TestBean.java
@@ -22,8 +22,6 @@
*/
package org.x4o.xml.test.models;
-import java.util.Date;
-
/**
* Bean for property testing.
*
diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java b/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java
index 791c2e9..4f6de08 100644
--- a/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java
+++ b/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java
@@ -45,41 +45,6 @@ public class SwiXmlDriver extends X4ODriver {
public static final String[] LANGUAGE_VERSIONS = new String[]{LANGUAGE_VERSION_2,LANGUAGE_VERSION_3};
public static final String LANGUAGE_EL_SWING_ENGINE = "swingEngine";
- /*
- * Protected constructor for write schema api.
- * @param xmlVersion The xml version.
-
- protected SwiXmlDriver(SwiXmlVersion xmlVersion) {
-
- // Create language by version
- super(LANGUAGE_NAME,xmlVersion.getLanguageVersion());
-
- // Sets empty namespace uri for version 2 xml documents
- if (SwiXmlVersion.VERSION_2.equals(xmlVersion)) {
- setProperty(X4OLanguagePropertyKeys.INPUT_EMPTY_NAMESPACE_URI, VERSION_2_NS_URI);
- }
- }*/
-
- /*
- * Creates an SwiXmlParser with an SwingEngine and a xml version.
- * @param engine The SwingEngine to parse for.
- * @param xmlVersion The xml language version to parse.
-
- public SwiXmlDriver(SwingEngine engine,SwiXmlVersion xmlVersion) {
-
- // Create language
- this(xmlVersion);
-
- // Check engine
- if (engine==null) {
- throw new NullPointerException("Can't parse with null SwingEngine.");
- }
-
- // Add engine for callback
- addELBeanInstance(SWING_ENGINE_EL_NAME,engine);
- }*/
-
-
/**
* Helper for while parsing to get the SwingEngine.
* @param elementLanguage The elementLanguage to get the swingEngine out.
@@ -91,7 +56,6 @@ public class SwiXmlDriver extends X4ODriver {
return se;
}
-
static public SwiXmlDriver getInstance() {
return (SwiXmlDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME);
}
diff --git a/x4o-driver/src/test/resources/META-INF/test/test-lang.eld b/x4o-driver/src/test/resources/META-INF/test/test-lang.eld
index 7fde7bb..d07b023 100644
--- a/x4o-driver/src/test/resources/META-INF/test/test-lang.eld
+++ b/x4o-driver/src/test/resources/META-INF/test/test-lang.eld
@@ -142,13 +142,28 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/x4o-driver/src/test/resources/tests/writer/test-attribute-order.xml b/x4o-driver/src/test/resources/tests/writer/test-attribute-order.xml
new file mode 100644
index 0000000..e6e6163
--- /dev/null
+++ b/x4o-driver/src/test/resources/tests/writer/test-attribute-order.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
diff --git a/x4o-elddoc/.project b/x4o-eld-doc/.project
similarity index 89%
rename from x4o-elddoc/.project
rename to x4o-eld-doc/.project
index 9b776e0..5e3bf4a 100644
--- a/x4o-elddoc/.project
+++ b/x4o-eld-doc/.project
@@ -1,7 +1,7 @@
- x4o-elddoc
- x4o-elddoc
+ x4o-eld-doc
+ x4o-eld-doc
diff --git a/x4o-elddoc/pom.xml b/x4o-eld-doc/pom.xml
similarity index 94%
rename from x4o-elddoc/pom.xml
rename to x4o-eld-doc/pom.xml
index 04d5305..d20a516 100644
--- a/x4o-elddoc/pom.xml
+++ b/x4o-eld-doc/pom.xml
@@ -5,10 +5,10 @@
org.x4o
0.8.5-SNAPSHOT
- x4o-elddoc
+ x4o-eld-doc
jar
- x4o-elddoc
- x4o-elddoc
+ x4o-eld-doc
+ x4o-eld-doc
org.x4o
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java
new file mode 100644
index 0000000..96a31c0
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java
@@ -0,0 +1,271 @@
+/*
+ * 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.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
+import org.x4o.xml.eld.doc.api.ApiDocNodeWriterBean;
+import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
+import org.x4o.xml.eld.doc.api.ApiDocWriter;
+import org.x4o.xml.eld.doc.api.DefaultPageWriterHelp;
+import org.x4o.xml.eld.doc.api.DefaultPageWriterIndexAll;
+import org.x4o.xml.eld.doc.api.DefaultPageWriterTree;
+import org.x4o.xml.eld.doc.api.dom.ApiDoc;
+import org.x4o.xml.eld.doc.api.dom.ApiDocConcept;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
+import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
+import org.x4o.xml.element.ElementAttributeHandler;
+import org.x4o.xml.element.ElementBindingHandler;
+import org.x4o.xml.element.ElementClass;
+import org.x4o.xml.element.ElementConfigurator;
+import org.x4o.xml.element.ElementInterface;
+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;
+
+/**
+ * EldDocWriter writes the x4o eld documentation.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Aug 26, 2010
+ */
+public class EldDocWriter {
+
+ private X4OLanguageContext context = null;
+ private static final String[] C_CONTEXT = {"language","Overview","All language modules.","The loaded language modules.."};
+ private static final String[] C_MODULE = {"module","Module","The Language Modules.","The language is build by the modules and provides the namespaces."};
+ private static final String[] C_NAMESPACE = {"namespace","Namespace","The Language Namespace.","The language namespace holds all the xml elements."};
+ private static final String[] C_ELEMENT = {"element","Element","The Language Element.","The xml language element description."};
+
+ /**
+ * Creates an EldDocGenerator for this langauge context.
+ * @param context The language context to generate doc for.
+ */
+ public EldDocWriter(X4OLanguageContext context) {
+ this.context=context;
+ }
+
+ /**
+ * Writes the language documentation to the base path.
+ * @param basePath The path to write to documentation to.
+ * @throws ElementException Is thrown when error is done.
+ */
+ public void writeDoc(File basePath) throws ElementException {
+ try {
+ ApiDocWriter writer = new ApiDocWriter();
+ ApiDoc doc = buildLanguageDoc();
+ doc.checkModel();
+ writer.write(doc, basePath);
+ } catch (SAXException e) {
+ throw new ElementException(e);
+ } catch (IOException e) {
+ throw new ElementException(e);
+ }
+ }
+
+ private ApiDoc buildLanguageDoc() {
+ ApiDoc doc = new ApiDoc();
+ doc.setName("X4O ELD DOC");
+ doc.setDescription("X4O Meta Language Description");
+ doc.setDocAbout(createLanguageAbout());
+ doc.setDocCopyright(createLanguageCopyright());
+ doc.addDocKeywordAll(createLanguageKeywords());
+ doc.setFrameNavPrintParent(true);
+ doc.setFrameNavPrintParentId(true);
+
+ doc.setFrameNavConceptClass(ElementClass.class);
+ ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,new EldDocWriterLanguage());
+ ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,new EldDocWriterElementClass());
+ ApiDocNodeWriterBean.addAnnotatedNodeContentWriters(doc,this);
+
+ ApiDocConcept adc1 = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguageContext.class));
+ ApiDocConcept adc2 = doc.addConcept(new ApiDocConcept(adc1,C_MODULE,X4OLanguageModule.class,
+ ElementAttributeHandler.class,ElementConfigurator.class,ElementInterface.class,ElementBindingHandler.class));
+ ApiDocConcept adc3 = doc.addConcept(new ApiDocConcept(adc2,C_NAMESPACE,ElementNamespaceContext.class));
+ doc.addConcept(new ApiDocConcept(adc3,C_ELEMENT,ElementClass.class));
+
+ doc.addDocPage(EldDocXTreePageWriter.createDocPage());
+ doc.addDocPage(DefaultPageWriterTree.createDocPage());
+ doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
+ doc.addDocPage(DefaultPageWriterHelp.createDocPage());
+
+ ApiDocNode rootNode = new ApiDocNode(context,"language","Language","The X4O Language");
+ doc.setRootNode(rootNode);
+ for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { ApiDocNode modNode = rootNode.addNode(createNodeLanguageModule(mod));
+ for (ElementBindingHandler bind:mod.getElementBindingHandlers()) { modNode.addNode(createNodeElementBindingHandler(bind)); }
+ for (ElementAttributeHandler attr:mod.getElementAttributeHandlers()) { modNode.addNode(createNodeElementAttributeHandler(attr)); }
+ for (ElementConfigurator conf:mod.getElementConfiguratorGlobals()) { modNode.addNode(createNodeElementConfigurator(conf)); }
+ for (ElementInterface iface:mod.getElementInterfaces()) { ApiDocNode ifaceNode = modNode.addNode(createNodeElementInterface(iface));
+ for (ElementBindingHandler bind:iface.getElementBindingHandlers()) { ifaceNode.addNode(createNodeElementBindingHandler(bind)); }
+ for (ElementConfigurator conf:iface.getElementConfigurators()) { ifaceNode.addNode(createNodeElementConfigurator(conf)); } }
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { ApiDocNode nsNode = modNode.addNode(createNodeElementNamespaceContext(ns));
+ for (ElementClass ec:ns.getElementClasses()) { ApiDocNode ecNode = nsNode.addNode(createNodeElementClass(ec));
+ for (ElementConfigurator conf:ec.getElementConfigurators()) { ecNode.addNode(createNodeElementConfigurator(conf)); } } }
+ }
+ return doc;
+ }
+
+ private ApiDocNode createNodeElementBindingHandler(ElementBindingHandler bind) {
+ return new ApiDocNode(bind,bind.getId(),bind.getId(),bind.getDescription());
+ }
+ private ApiDocNode createNodeElementAttributeHandler(ElementAttributeHandler attr) {
+ return new ApiDocNode(attr,attr.getId(),attr.getId(),attr.getDescription());
+ }
+ private ApiDocNode createNodeElementConfigurator(ElementConfigurator conf) {
+ return new ApiDocNode(conf,conf.getId(),conf.getId(),conf.getDescription());
+ }
+ private ApiDocNode createNodeLanguageModule(X4OLanguageModule mod) {
+ return new ApiDocNode(mod,mod.getId(),mod.getId(),mod.getDescription());
+ }
+ private ApiDocNode createNodeElementInterface(ElementInterface iface) {
+ return new ApiDocNode(iface,iface.getId(),iface.getId(),iface.getDescription());
+ }
+ private ApiDocNode createNodeElementNamespaceContext(ElementNamespaceContext ns) {
+ return new ApiDocNode(ns,ns.getId(),ns.getUri(),ns.getDescription());
+ }
+ private ApiDocNode createNodeElementClass(ElementClass ec) {
+ return new ApiDocNode(ec,ec.getId(),ec.getId(),ec.getDescription());
+ }
+
+ private String createLanguageAbout() {
+ StringBuffer buf = new StringBuffer(100);
+ buf.append("XML X4O Language\n");
+ buf.append(context.getLanguage().getLanguageName().toUpperCase());
+ buf.append("™ ");
+ buf.append(context.getLanguage().getLanguageVersion());
+ return buf.toString();
+ }
+
+ private String createLanguageCopyright() {
+ 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();
+ }
+
+ private List createLanguageKeywords() {
+ List keywords = new ArrayList(10);
+ keywords.add(context.getLanguage().getLanguageName());
+ keywords.add("x4o");
+ keywords.add("xml");
+ keywords.add("language");
+ keywords.add("documentation");
+ return keywords;
+ }
+
+ private void printBeanProperties(ApiDocContentWriter 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);
+ if (m.getParameterTypes().length!=0) {
+ continue; // set without parameters
+ }
+ if (n.length()<2) {
+ continue;
+ }
+ n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
+ Object value = null;
+ try {
+ value = m.invoke(bean, new Object[] {});
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ writer.docTableRow(n,printValue(value));
+ }
+ }
+ writer.docTableEnd();
+ }
+
+ private String printValue(Object value) {
+ if (value==null) {
+ return "null";
+ }
+ if (value instanceof String) {
+ return (String)value;
+ }
+ if (value instanceof Class) {
+ return "class "+((Class>)value).getName();
+ }
+ if (value instanceof List) {
+ StringBuffer buf = new StringBuffer(100);
+ buf.append("[L: ");
+ List> l = (List>)value;
+ if (l.isEmpty()) {
+ buf.append("Empty");
+ }
+ for (Object o:l) {
+ buf.append(""+o);
+ buf.append(" ");
+ }
+ buf.append("]");
+ return buf.toString();
+ }
+ if (value instanceof Object[]) {
+ StringBuffer buf = new StringBuffer(100);
+ buf.append("[A: ");
+ Object[] l = (Object[])value;
+ if (l.length==0) {
+ buf.append("Empty");
+ }
+ for (Object o:l) {
+ buf.append(""+o);
+ buf.append(" ");
+ }
+ buf.append("]");
+ return buf.toString();
+ }
+
+ return value.toString();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementBindingHandler.class})
+ public void writeElementBindingHandlerBeanProperties(ApiDocWriteEvent event) throws SAXException {
+ printBeanProperties(event.getWriter(),event.getEvent().getUserData());
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementConfigurator.class})
+ public void writeElementConfiguratorBeanProperties(ApiDocWriteEvent event) throws SAXException {
+ printBeanProperties(event.getWriter(),event.getEvent().getUserData());
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java
new file mode 100644
index 0000000..a1b45fc
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java
@@ -0,0 +1,189 @@
+/*
+ * 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.lang.reflect.Method;
+import java.util.List;
+
+import org.x4o.xml.eld.doc.EldDocXTreePageWriter.TreeNode;
+import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
+import org.x4o.xml.eld.doc.api.ApiDocNodeWriterMethod;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
+import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
+import org.x4o.xml.element.ElementClass;
+import org.x4o.xml.element.ElementClassAttribute;
+import org.x4o.xml.element.ElementNamespaceContext;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
+import org.x4o.xml.lang.X4OLanguageContext;
+import org.x4o.xml.lang.X4OLanguageModule;
+import org.xml.sax.SAXException;
+
+/**
+ * EldDocWriterElementClass writer all content parts for the ElementClass.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 29, 2013
+ */
+public class EldDocWriterElementClass {
+
+ private String printList(List list) {
+ StringBuffer buf = new StringBuffer(40);
+ buf.append("[L: ");
+ if (list.isEmpty()) {
+ buf.append("Empty.");
+ }
+ for (String s:list) {
+ buf.append(s);
+ buf.append(' ');
+ }
+ buf.append("]");
+ return buf.toString();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
+ public void writeElementX4OSummary(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ElementClass ec = (ElementClass)event.getEvent().getUserData();
+ writer.docTableStart("Element X4O Properties", "Element X4O 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();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
+ public void writeElementX4OAttributeSummary(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ElementClass ec = (ElementClass)event.getEvent().getUserData();
+ writer.docTableStart("Element X4O Attributes", "All Element X4O Attributes Overview");
+ writer.docTableHeader("URI", "Name");
+ for (ElementClassAttribute attr:ec.getElementClassAttributes()) {
+ writer.docTableRow(attr.getId(),attr.getDescription());
+ }
+ writer.docTableEnd();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={ElementClass.class})
+ public void writeElementObjectPropertiesSummary(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ElementClass ec = (ElementClass)event.getEvent().getUserData();
+ Class> beanClass = ec.getElementClass();
+ if (beanClass==null) {
+ return;
+ }
+ 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);
+ if (m.getParameterTypes().length==0) {
+ continue; // set without parameters
+ }
+ if (n.length()<2) {
+ continue;
+ }
+ 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.
+ writer.docTableRow(n,""+type);
+ }
+ }
+ writer.docTableEnd();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DESCRIPTION_LINKS,targetClasses={ElementClass.class})
+ public void writeElementRelationLinks(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ElementClass ec = (ElementClass)event.getEvent().getUserData();
+ ElementNamespaceContext ns = (ElementNamespaceContext)event.getEvent().getParent().getUserData();
+ X4OLanguageModule mod = (X4OLanguageModule)event.getEvent().getParent().getParent().getUserData();
+ X4OLanguageContext context = (X4OLanguageContext)event.getEvent().getParent().getParent().getParent().getUserData();
+
+ // TODO: this is hacky
+ EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);
+
+ TreeNode node = xtree.new TreeNode();
+ node.context=context;
+ node.module=mod;
+ node.namespace=ns;
+ node.elementClass=ec;
+
+ String pathPrefix = "../../../../language/";
+
+ List parents = xtree.findParents(node);
+ writer.printTagStart(Tag.dl);
+ writer.printTagCharacters(Tag.dt,"Element Parents:");
+ writer.printTagStart(Tag.dd);
+ if (parents.isEmpty()) {
+ writer.characters("No parent.");
+ }
+ for (int i=0;i childs = xtree.findChilderen(node);
+ writer.printTagStart(Tag.dl);
+ writer.printTagCharacters(Tag.dt,"Element Childeren:");
+ writer.printTagStart(Tag.dd);
+ if (childs.isEmpty()) {
+ writer.characters("No childeren.");
+ }
+ for (int i=0;i event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ApiDocNode node = event.getEvent();
+ X4OLanguageContext context = (X4OLanguageContext)node.getUserData();
+ int attrHandlers = 0;
+ int bindHandlers = 0;
+ int interFaces = 0;
+ int eleConfigs = 0;
+ int elements = 0;
+ int namespaces = 0;
+ for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
+ attrHandlers += mod.getElementAttributeHandlers().size();
+ bindHandlers += mod.getElementBindingHandlers().size();
+ interFaces += mod.getElementInterfaces().size();
+ eleConfigs += mod.getElementConfiguratorGlobals().size();
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
+ namespaces++;
+ elements += ns.getElementClasses().size();
+ }
+ }
+ writer.docTableStart("Language Summary", "Language Stats Summary.");
+ 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();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
+ public void writeModulesSummary(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ApiDocNode node = event.getEvent();
+ writer.docTableStart("Modules Summary", "All modules.");
+ writer.docTableHeader("Name", "Description");
+ for (ApiDocNode child:node.getNodes()) {
+ String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
+ if (node.getParent()==null) {
+ link = ApiDocContentWriter.toSafeUri(node.getId())+"/"+link; // root node
+ }
+ writer.docTableRowHref(link,child.getName(),child.getDescription(),null);
+ }
+ writer.docTableEnd();
+ }
+
+ @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class})
+ public void writeNamespaceSummary(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ ApiDocNode node = event.getEvent();
+ X4OLanguageContext context = (X4OLanguageContext)node.getUserData();
+ writer.docTableStart("Namespace Summary", "All Language Namespaces Overview");
+ writer.docTableHeader("ID", "URI");
+ for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
+ writer.docTableRowHref("language/"+ApiDocContentWriter.toSafeUri(mod.getId())+"/"+ApiDocContentWriter.toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri(),null);
+ }
+ }
+ writer.docTableEnd();
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java
new file mode 100644
index 0000000..53b85a5
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java
@@ -0,0 +1,332 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
+import org.x4o.xml.eld.doc.api.DefaultPageWriterTree;
+import org.x4o.xml.eld.doc.api.dom.ApiDoc;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
+import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
+import org.x4o.xml.element.ElementBindingHandler;
+import org.x4o.xml.element.ElementClass;
+import org.x4o.xml.element.ElementInterface;
+import org.x4o.xml.element.ElementNamespaceContext;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
+import org.x4o.xml.lang.X4OLanguageContext;
+import org.x4o.xml.lang.X4OLanguageModule;
+import org.xml.sax.SAXException;
+
+/**
+ * EldDocXTreePageWriter for dom overview of tree but as seperate page.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 29, 2013
+ */
+public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiDocPageWriter {
+
+ public static ApiDocPage createDocPage() {
+ return new ApiDocPage("overview-xtree","XTree","XTree of dom elements.",new EldDocXTreePageWriter());
+ }
+
+ // TODO: rm this old tree code;
+ private void walkTree(TreeNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException {
+ String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
+
+ writer.printTagStart(Tag.ul);
+ writer.printTagStart(Tag.li,"",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,writer,pathPrefix);
+ }
+ writer.printTagEnd(Tag.ul);
+ }
+
+ /**
+ * TODO: remove this
+ * @see org.x4o.xml.eld.doc.api.DefaultPageWriterTree#writePageContent(org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent)
+ */
+ @Override
+ public void writePageContent(ApiDocWriteEvent e) throws SAXException {
+ //selectRootNode(e.getDoc()); // create
+ ApiDoc doc = e.getDoc();
+ X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData();
+
+ String pathPrefix = "language/";
+
+ // temp print old way
+ List rootNodes = new ArrayList(3);
+ for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
+ if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
+ // found language root elements.
+ for (ElementClass ec:ns.getElementClasses()) {
+ TreeNode node = new TreeNode();
+ node.context=context;
+ node.module=mod;
+ node.namespace=ns;
+ node.elementClass=ec;
+ rootNodes.add(node);
+ }
+ }
+ }
+ }
+ Collections.sort(rootNodes,new TreeNodeComparator());
+ for (TreeNode rootNode:rootNodes) {
+ walkTree(rootNode,e.getWriter(),pathPrefix);
+ }
+ }
+ private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespaceContext namespace,ElementClass ec) {
+ StringBuffer buf = new StringBuffer(100);
+ if (pathPrefix!=null) {
+ buf.append(pathPrefix);
+ }
+ buf.append(ApiDocContentWriter.toSafeUri(mod.getId()));
+ buf.append("/");
+ buf.append(ApiDocContentWriter.toSafeUri(namespace.getId()));
+ buf.append("/");
+ buf.append(ApiDocContentWriter.toSafeUri(ec.getId()));
+ buf.append("/index.html");
+ return buf.toString();
+ }
+
+
+ /**
+ * Overrided to select the dom view of the tree.
+ * @see org.x4o.xml.eld.doc.api.DefaultPageWriterTree#selectRootNode(org.x4o.xml.eld.doc.api.dom.ApiDoc)
+ */
+ @Override
+ protected ApiDocNode selectRootNode(ApiDoc doc) {
+ try {
+ return createXTree(doc);
+ } catch (SAXException e) {
+ throw new IllegalStateException("Could not create XTree for: "+doc.getName()+" error: "+e.getMessage(),e);
+ }
+ }
+
+ private ApiDocNode createXTree(ApiDoc doc) throws SAXException {
+
+ X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData();
+ ApiDocNode root = new ApiDocNode(context,"root","Root","Language root");
+
+ List rootNodes = new ArrayList(3);
+ for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
+ if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
+ // found language root elements.
+ for (ElementClass ec:ns.getElementClasses()) {
+ TreeNode node = new TreeNode();
+ node.context=context;
+ node.module=mod;
+ node.namespace=ns;
+ node.elementClass=ec;
+ rootNodes.add(node);
+ }
+ }
+ }
+ }
+ Collections.sort(rootNodes,new TreeNodeComparator());
+ for (TreeNode rootNode:rootNodes) {
+ walkTree(rootNode,"../");
+ }
+
+
+ return root;
+ }
+
+ private void walkTree(TreeNode node,String pathPrefix) throws SAXException {
+ //String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
+ List childs = findChilderen(node);
+ for (TreeNode child:childs) {
+ walkTree(child,pathPrefix);
+ }
+ }
+
+
+ class TreeNode {
+ X4OLanguageContext context;
+ X4OLanguageModule module;
+ ElementNamespaceContext namespace;
+ ElementClass elementClass;
+ TreeNode parent;
+ int indent = 0;
+ }
+
+ public List findChilderen(TreeNode node) {
+ List result = new ArrayList(10);
+
+ if (node.indent>20) {
+ return result; // hard fail limit
+ }
+ for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
+ for (ElementClass ec:ns.getElementClasses()) {
+ TreeNode n=null;
+ List tags = ec.getElementParents(node.namespace.getUri());
+ if (tags!=null && tags.contains(node.elementClass.getId())) {
+ n = new TreeNode();
+ n.context=node.context;
+ n.module=mod;
+ n.namespace=ns;
+ n.elementClass=ec;
+ n.indent=node.indent+1;
+ n.parent=node;
+ } else {
+ if (ec.getObjectClass()==null) {
+ continue;
+ }
+ // Check interfaces of parent , and see if child tag is there.
+ for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(ec.getObjectClass())) {
+ List eiTags = ei.getElementParents(node.namespace.getUri());
+ if (eiTags!=null && eiTags.contains(node.elementClass.getId())) {
+ n = new TreeNode();
+ n.context=node.context;
+ n.module=mod;
+ n.namespace=ns;
+ n.elementClass=ec;
+ n.indent=node.indent+1;
+ n.parent=node;
+ break;
+ }
+ }
+
+ if (node.elementClass.getObjectClass()==null) {
+ continue;
+ }
+ List binds = node.context.getLanguage().findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
+ if (binds.isEmpty()==false) {
+ n = new TreeNode();
+ n.context=node.context;
+ n.module=mod;
+ n.namespace=ns;
+ n.elementClass=ec;
+ n.indent=node.indent+1;
+ n.parent=node;
+ }
+ }
+ if (n!=null && isInTree(node,n)==false) {
+ result.add(n);
+ }
+ }
+ }
+ }
+ Collections.sort(result,new TreeNodeComparator());
+ return result;
+ }
+
+ private boolean isInTree(TreeNode node,TreeNode checkNode) {
+
+ if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
+ node.elementClass.getId().equals(checkNode.elementClass.getId())
+ ) {
+ return true;
+ }
+ if (node.parent!=null) {
+ return isInTree(node.parent,checkNode);
+ }
+ return false;
+ }
+
+ public List findParents(TreeNode node) {
+ List result = new ArrayList(10);
+ TreeNode n=null;
+ for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
+ for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
+
+ List tags = node.elementClass.getElementParents(ns.getUri());
+ if (tags!=null) {
+ for (ElementClass ec:ns.getElementClasses()) {
+ if (tags.contains(ec.getId())) {
+ n = new TreeNode();
+ n.context=node.context;
+ n.module=mod;
+ n.namespace=ns;
+ n.elementClass=ec;
+ n.indent=node.indent+1;
+ n.parent=node;
+ result.add(n);
+ }
+ }
+ }
+ for (ElementClass ec:ns.getElementClasses()) {
+
+ // Check interfaces of parent , and see if child tag is there.
+ if (node.elementClass.getObjectClass()!=null) {
+ for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(node.elementClass.getObjectClass())) {
+ List eiTags = ei.getElementParents(ns.getUri());
+ if (eiTags!=null && eiTags.contains(ec.getId())) {
+ n = new TreeNode();
+ n.context=node.context;
+ n.module=mod;
+ n.namespace=ns;
+ n.elementClass=ec;
+ n.indent=node.indent+1;
+ n.parent=node;
+ result.add(n);
+ break;
+ }
+ }
+ }
+ if (ec.getObjectClass()==null) {
+ continue;
+ }
+ if (node.elementClass.getObjectClass()==null) {
+ continue;
+ }
+ List binds = node.context.getLanguage().findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
+ if (binds.isEmpty()==false) {
+ n = new TreeNode();
+ n.context=node.context;
+ n.module=mod;
+ n.namespace=ns;
+ n.elementClass=ec;
+ n.indent=node.indent+1;
+ n.parent=node;
+ if (isInTree(node,n)==false) {
+ result.add(n);
+ }
+ }
+ }
+ }
+ }
+ Collections.sort(result,new TreeNodeComparator());
+ return result;
+ }
+
+ class TreeNodeComparator implements Comparator {
+ public int compare(TreeNode o1,TreeNode o2) {
+ return o1.elementClass.getId().compareTo(o2.elementClass.getId());
+ }
+ }
+}
diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java
similarity index 97%
rename from x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java
rename to x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java
index 9babc1b..d5a3a2a 100644
--- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java
@@ -97,9 +97,9 @@ public class X4OWriteLanguageDocExecutor {
X4ODriver> driver = X4ODriverManager.getX4ODriver(getLanguageName());
X4OLanguageContext context = driver.createLanguageContext(getLanguageVersion());
- // Start doc generator
- EldDocGenerator generator = new EldDocGenerator(context);
- generator.writeDoc(getBasePath());
+ // Run doc writer
+ EldDocWriter docWriter = new EldDocWriter(context);
+ docWriter.writeDoc(getBasePath());
}
/**
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentCss.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentCss.java
new file mode 100644
index 0000000..e07fc28
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentCss.java
@@ -0,0 +1,74 @@
+/*
+ * 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.api;
+
+/**
+ * ApiDocContentCss defines the css style names used in api docs.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 20, 2013
+ */
+public enum ApiDocContentCss {
+
+ indexHeader,
+ indexContainer,
+
+ bar,
+ block,
+ blockList,
+ strong,
+
+ topNav,
+ bottomNav,
+ navList,
+ navBarCell1Rev,
+ subNav,
+ subNavList,
+
+ subTitle,
+ tabEnd,
+
+ aboutLanguage,
+ legalCopy,
+
+ inheritance,
+ header,
+ description,
+ summary,
+ details,
+ docSummary,
+ contentContainer,
+ packageSummary,
+
+ colOne,
+ colFirst,
+ colLast,
+
+ altColor,
+ rowColor,
+
+ // frame names maybe can be used to create frame-less html5 JS version
+ frameNavOverview,
+ frameNavDetail,
+ frameContent
+}
diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentWriter.java
similarity index 76%
rename from x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java
rename to x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentWriter.java
index 016908e..6efd4f5 100644
--- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/ContentWriterDoc.java
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocContentWriter.java
@@ -20,7 +20,7 @@
* 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;
+package org.x4o.xml.eld.doc.api;
import java.io.Writer;
import java.util.ArrayList;
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.x4o.xml.io.sax.ContentWriterHtml;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -39,16 +39,16 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Willem Cazander
* @version 1.0 Apr 30, 2013
*/
-public class ContentWriterDoc extends ContentWriterHtml {
+public class ApiDocContentWriter extends ContentWriterHtml {
private boolean isAltRow = true;
- public ContentWriterDoc(Writer out,String encoding,String charNewLine,String charTab) {
+ public ApiDocContentWriter(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());
+ comment("Generated by "+ApiDocContentWriter.class.getSimpleName()+" on "+new Date());
}
public void docHtmlStart(NavBarConfig conf,String title,List keywords) throws SAXException {
@@ -84,7 +84,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
public void docHtmlEnd(NavBarConfig conf,String copyright) throws SAXException {
docNavBar(conf,false);
- printTagStart(Tag.p,"legalCopy");
+ printTagStart(Tag.p,ApiDocContentCss.legalCopy);
printTagStart(Tag.small);
charactersRaw(copyright);
printTagEnd(Tag.small);
@@ -153,7 +153,7 @@ public class ContentWriterDoc extends ContentWriterHtml {
comment("========= START OF "+barComment+" NAVBAR =======");
printTagStart(Tag.div,barCssDiv);
- printHrefNamed(barId); // Print named link navigation
+ printHrefNamed(barId); // Print named link navigation
AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "href", "", "", "#skip-"+barId);
atts.addAttribute ("", "title", "", "", "Skip navigation links");
@@ -172,37 +172,47 @@ public class ContentWriterDoc extends ContentWriterHtml {
String selectedCss = null;
if (navKey.equals(conf.navSelected)) {
selectedCss = "navBarCell1Rev";
+ navLink = null; // disables link
}
if (navLink==null) {
- printTagText(Tag.li, navName, selectedCss);
+ printTagCharacters(Tag.li, navName, selectedCss);
} else {
docNavBarListItemHref(pathPrefix+navLink,navName,selectedCss);
}
}
endElement("", "ul", "");
- printTagStart(Tag.div,"aboutLanguage"); // Print about language
+ printTagStart(Tag.div,ApiDocContentCss.aboutLanguage); // Print about language
printTagStart(Tag.em);
- printTagStart(Tag.strong);charactersRaw(conf.aboutLanguage);printTagEnd(Tag.strong);
+ printTagStart(Tag.strong);
+ for (int i=0;i paths) {
+ return toSafeUri(paths.toArray(new String[]{}));
+ }
+
+ static public String toSafeUri(String...paths) {
+ StringBuffer result = new StringBuffer(100);
+ for (int i=0;i> targetClasses = null;
+ private String contentGroup = null;
+ private String contentGroupType = null;
+
+ public ApiDocNodeWriterBean() {
+ targetClasses = new ArrayList>(5);
+ }
+
+ public ApiDocNodeWriterBean(ApiDocNodeBody nodeBody,Object bean,String method,Class>...classes) {
+ this();
+ this.nodeBody=nodeBody;
+ this.bean=bean;
+ this.method=method;
+ if (classes!=null && classes.length>0) {
+ targetClasses.addAll(Arrays.asList(classes));
+ }
+ }
+
+ public static void addAnnotatedNodeContentWriters(ApiDoc doc,Object bean) {
+ if (doc==null) {
+ throw new NullPointerException("Can't add to null ApiDoc.");
+ }
+ if (bean==null) {
+ throw new NullPointerException("Can't scan null bean.");
+ }
+ for (Method method:bean.getClass().getMethods()) {
+ ApiDocNodeWriterMethod ammo = method.getAnnotation(ApiDocNodeWriterMethod.class);
+ if (ammo==null) {
+ continue;
+ }
+ ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
+ if (ammo.nodeBodyOrder()!=-1) {
+ methodWriter.setNodeBodyOrder(ammo.nodeBodyOrder());
+ }
+ if (!ammo.contentGroup().isEmpty()) {
+ methodWriter.setContentGroup(ammo.contentGroup());
+ }
+ if (!ammo.contentGroupType().isEmpty()) {
+ methodWriter.setContentGroupType(ammo.contentGroupType());
+ }
+ doc.addNodeBodyWriter(methodWriter);
+ }
+ }
+
+ public void writeNodeContent(ApiDocWriteEvent event) throws SAXException {
+ Class> beanClass = bean.getClass();
+ try {
+ Method methodBean = beanClass.getMethod(method, new Class[]{ApiDocWriteEvent.class});
+ methodBean.invoke(bean, new Object[]{event});
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+ }
+
+ public void addtargetClass(Class> targetClass) {
+ targetClasses.add(targetClass);
+ }
+
+ public void removetargetClass(Class> targetClass) {
+ targetClasses.remove(targetClasses);
+ }
+
+ public List> getTargetClasses() {
+ return targetClasses;
+ }
+
+ /**
+ * @return the nodeBody
+ */
+ public ApiDocNodeBody getNodeBody() {
+ return nodeBody;
+ }
+
+ /**
+ * @param nodeBody the nodeBody to set
+ */
+ public void setNodeBody(ApiDocNodeBody nodeBody) {
+ this.nodeBody = nodeBody;
+ }
+
+ /**
+ * @return the bean
+ */
+ public Object getBean() {
+ return bean;
+ }
+
+ /**
+ * @param bean the bean to set
+ */
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ /**
+ * @return the method
+ */
+ public String getMethod() {
+ return method;
+ }
+
+ /**
+ * @param method the method to set
+ */
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ /**
+ * @return the nodeBodyOrder
+ */
+ public Integer getNodeBodyOrder() {
+ return nodeBodyOrder;
+ }
+
+ /**
+ * @param nodeBodyOrder the nodeBodyOrder to set
+ */
+ public void setNodeBodyOrder(Integer nodeBodyOrder) {
+ this.nodeBodyOrder = nodeBodyOrder;
+ }
+
+ /**
+ * @return the contentGroup
+ */
+ public String getContentGroup() {
+ return contentGroup;
+ }
+
+ /**
+ * @param contentGroup the contentGroup to set
+ */
+ public void setContentGroup(String contentGroup) {
+ this.contentGroup = contentGroup;
+ }
+
+ /**
+ * @return the contentGroupType
+ */
+ public String getContentGroupType() {
+ return contentGroupType;
+ }
+
+ /**
+ * @param contentGroupType the contentGroupType to set
+ */
+ public void setContentGroupType(String contentGroupType) {
+ this.contentGroupType = contentGroupType;
+ }
+}
\ No newline at end of file
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java
new file mode 100644
index 0000000..04081b3
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2007-2012 forwardfire.net 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.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
+
+/**
+ * ApiDocNodeBodyWriterMethod wraps api doc file writer events to a method.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 19, 2013
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD})
+public @interface ApiDocNodeWriterMethod {
+
+ Class>[] targetClasses();
+
+ ApiDocNodeBody nodeBody();
+
+ int nodeBodyOrder() default -1;
+
+ String contentGroup() default "";
+
+ String contentGroupType() default "";
+}
\ No newline at end of file
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java
new file mode 100644
index 0000000..c21bd11
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java
@@ -0,0 +1,810 @@
+/*
+ * 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.api;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.x4o.xml.eld.doc.api.ApiDocContentWriter.NavBarConfig;
+import org.x4o.xml.eld.doc.api.dom.ApiDoc;
+import org.x4o.xml.eld.doc.api.dom.ApiDocConcept;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNodeBody;
+import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNodeWriter;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
+import org.x4o.xml.io.XMLConstants;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml.DocType;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
+import org.x4o.xml.lang.X4OLanguageClassLoader;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * ApiDocWriter creates all output files for the ApiDoc.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 1, 2013
+ */
+public class ApiDocWriter {
+
+ private ApiDoc doc = null;
+ private File basePath = null;
+
+ /**
+ * Writes full api doc tree files to the base path.
+ * @param doc The ApiDoc to writer.
+ * @param basePath The bath path to write into.
+ * @throws IOException When file exception happens.
+ * @throws SAXException when xml exception happens.
+ */
+ public void write(ApiDoc doc,File basePath) throws IOException,SAXException {
+ if (doc==null) {
+ throw new NullPointerException("Can't write with null ApiDoc.");
+ }
+ if (basePath==null) {
+ throw new NullPointerException("Can't write with null basePath.");
+ }
+ this.doc=doc;
+ this.basePath=basePath;
+
+ // Write root and resource files
+ writeStyleSheet();
+ writeIndex();
+ writeOverviewFrame();
+ writeAllFrameNav(true);
+ writeAllFrameNav(false);
+
+ // Write pages
+ for (ApiDocPage page:doc.getDocPages()) {
+ writePage(page);
+ }
+
+ // Write api doc tree
+ writeNode(doc.getRootNode());
+ }
+
+ private void writeNode(ApiDocNode node) throws SAXException {
+ ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
+ if (concept==null) {
+ //System.out.println("----- no concept found for: "+node.getId()+" data: "+node.getUserData());
+ return;
+ }
+ List path = new ArrayList(10);
+ buildParentPath(node,path);
+ if (path.size()==1) {
+ path.remove(path.size()-1);
+ path.add("overview-"+node.getId()+".html");
+ } else {
+ path.add("index.html");
+ }
+ String pathPrefix = "";
+ for (int i=1;i bodyEvent = new ApiDocWriteEvent(doc,writer,node);
+ String title = node.getId();
+ String titleSub = null;
+ if (node.getParent()!=null) {
+ titleSub = node.getParent().getId()+":"+node.getId();
+ }
+
+ // Write node file
+ writer.docHtmlStart(config,title, doc.getDocKeywords());
+ writer.docPageClassStart(title, titleSub);
+ writer.docPageContentStart();
+ writeNodeTreePath(bodyEvent);
+ writeNodeDescription(bodyEvent);
+ writeNodeSummary(bodyEvent);
+ writeNodeDetails(bodyEvent);
+ writer.docPageContentEnd();
+ writer.docPageClassEnd();
+ writer.docHtmlEnd(config,doc.getDocCopyright());
+ writer.closeWriterSafe();
+
+ // Writer other files
+ writeAllFrameNavNode(node);
+ for (ApiDocNode child:node.getNodes()) {
+ writeNode(child);
+ }
+ }
+
+ private void writeNodeTreePath(ApiDocWriteEvent event) throws SAXException {
+ List bodyWriterTreePath = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.TREE_PATH);
+ if (bodyWriterTreePath.isEmpty()) {
+ defaultWriteTreePath(event.getEvent(),event.getWriter());
+ }
+ for (int i=0;i event) throws SAXException {
+ event.getWriter().characters(event.getEvent().getDescription());
+ }
+
+ private void writeNodeDescription(ApiDocWriteEvent event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ List bodyWriterDescriptionLinks = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DESCRIPTION_LINKS);
+ List bodyWriterDescriptionNode = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DESCRIPTION_NODE);
+ writer.printTagStart(Tag.div, ApiDocContentCss.description);
+ writer.docPageBlockStart();
+ if (bodyWriterDescriptionLinks.isEmpty()) {
+ //defaultWriteTreePath(node,writer);
+ }
+ for (int i=0;i event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ List bodyWriterSummary = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.SUMMARY);
+ writer.printTagStart(Tag.div, ApiDocContentCss.summary);
+ writer.docPageBlockStart();
+ if (bodyWriterSummary.isEmpty()) {
+ writer.docPageBlockStart();
+ defaultWriteSummary(event.getEvent(),writer);
+ writer.docPageBlockEnd();
+ }
+ for (int i=0;i event) throws SAXException {
+ ApiDocContentWriter writer = event.getWriter();
+ List bodyWriterDetail = findNodeBodyWriters(event.getEvent(),ApiDocNodeBody.DETAIL);
+ if (bodyWriterDetail.isEmpty()) {
+ return;// no default ..
+ }
+ writer.printTagStart(Tag.div, ApiDocContentCss.details);
+ writer.docPageBlockStart();
+ //if (bodyWriterDetail.isEmpty()) {
+ // writer.docPageBlockStart();
+ // defaultWriteDetailNode(node,writer);
+ // writer.docPageBlockEnd();
+ //}
+ for (int i=0;i pathClean = new ArrayList(10);
+ buildParentPath(node,pathClean);
+
+ if (concept.getParent()!=null && !concept.getParent().getId().equals(doc.getRootNode().getId())) {
+ ApiDocConcept conceptParent = concept.getParent();
+ conf.navLinks.put(conceptParent.getId(), ApiDocContentWriter.toSafeUri(pathClean)+prefix+"/index.html");
+ configActiveNavConceptLinks(conf,node,concept.getParent(),prefix+"/..");
+ }
+ }
+ private void configNextPrevLinks(NavBarConfig conf,ApiDocNode node) {
+ if (node.getParent()==null) {
+ return;
+ }
+ List pn = node.getParent().getNodes();
+ int pnSize = pn.size();
+ int nodeIdx = pn.indexOf(node);
+ if (nodeIdx>0) {
+ List pathClean = new ArrayList(10);
+ ApiDocNode prevNode = pn.get(nodeIdx-1);
+ if (node.getUserData().getClass().equals(prevNode.getUserData().getClass())) {
+ buildParentPath(prevNode,pathClean);
+ conf.prev = ApiDocContentWriter.toSafeUri(pathClean)+"/index.html";
+ }
+ }
+ if ((nodeIdx+1) pathClean = new ArrayList(10);
+ ApiDocNode nextNode = pn.get(nodeIdx+1);
+ if (node.getUserData().getClass().equals(nextNode.getUserData().getClass())) {
+ buildParentPath(nextNode,pathClean);
+ conf.next = ApiDocContentWriter.toSafeUri(pathClean)+"/index.html";
+ }
+ }
+ }
+
+ public void defaultWriteSummary(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
+ ApiDocConcept concept = findConceptByClass(node.getUserData().getClass());
+ writer.docTableStart(concept.getName()+" Summary", "All childeren in "+concept.getName());
+ writer.docTableHeader("Name", "Description");
+ for (ApiDocNode child:node.getNodes()) {
+ String link = ApiDocContentWriter.toSafeUri(child.getId())+"/index.html";
+ if (node.getParent()==null) {
+ link = ApiDocContentWriter.toSafeUri(node.getId())+"/"+link; // root node
+ }
+ writer.docTableRowHref(link,child.getName(),child.getDescription(),null);
+ }
+ writer.docTableEnd();
+ }
+
+ public void defaultWriteTreePath(ApiDocNode node,ApiDocContentWriter writer) throws SAXException {
+ if (node.getParent()==null) {
+ return; // no tree for root
+ }
+ List rootPath = new ArrayList(8);
+ defaultWriteTreePathBuildPath(node,rootPath);
+ defaultWriteTreePathWalker(rootPath.iterator(),writer,rootPath.size());
+ }
+
+ private void defaultWriteTreePathWalker(Iterator nodes,ApiDocContentWriter writer,int linkPrefixCount) throws SAXException {
+ if (nodes.hasNext()==false) {
+ return;
+ }
+ ApiDocNode node = nodes.next();
+ writer.printTagStart(Tag.ul, ApiDocContentCss.inheritance);
+ String nodeTitle = node.getId();
+ if (nodes.hasNext()==false) {
+ writer.printTagStart(Tag.li);
+ writer.characters(nodeTitle);
+ writer.printTagEnd(Tag.li);
+ } else {
+ writer.printTagStart(Tag.li);
+ StringBuffer buf = new StringBuffer(20);
+ for (int i=1;i result) {
+ if (node.getParent()!=null) {
+ defaultWriteTreePathBuildPath(node.getParent(),result);
+ }
+ result.add(node);
+ }
+
+ private ApiDocContentWriter createContentWriter(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 = " ";
+ ApiDocContentWriter result = new ApiDocContentWriter(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 NavBarConfig createNavBarConfig(String pathPrefix,File frame,ApiDocContentWriter writer) throws SAXException {
+ return createNavBarConfig(pathPrefix, null, null, frame, writer);
+ }
+
+ protected NavBarConfig createNavBarConfig(String pathPrefix,String prev,String next,File frame,ApiDocContentWriter 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,doc.getDocAbout());
+ conf.noFrameAllLink="allelements-noframe.html";
+ conf.noFrameAllName="All Elements";
+ conf.linkConstructorName="Tag";
+ conf.linkFieldName="Attributes";
+ conf.linkMethodName="Config";
+
+ for (ApiDocConcept concept:doc.getConcepts()) {
+ String navLink = "overview-"+concept.getId()+".html";
+ if (concept.getParent()!=null) {
+ navLink = null;
+ }
+ conf.addNavItem(concept.getId(), navLink, concept.getName());
+ }
+ for (ApiDocPage page:doc.getDocPages()) {
+ String navLink = page.getId()+".html";
+ conf.addNavItem(page.getId(), navLink, page.getName());
+ }
+ return conf;
+ }
+
+ private List findNodeBodyWriters(ApiDocNode node,ApiDocNodeBody nodeBody) {
+ List result = new ArrayList();
+ Class> objClass = node.getUserData().getClass();
+ for (ApiDocNodeWriter writer:doc.getNodeBodyWriters()) {
+ if (!nodeBody.equals(writer.getNodeBody())) {
+ continue;
+ }
+ for (Class> c:writer.getTargetClasses()) {
+ if (c.isAssignableFrom(objClass)) {
+ result.add(writer);
+ }
+ }
+ }
+ return result;
+ }
+
+ private ApiDocConcept findConceptByClass(Class> objClass) {
+ for (ApiDocConcept concept:doc.getConcepts()) {
+ if (concept.getConceptClass().isAssignableFrom(objClass)) {
+ return concept;
+ }
+ for (Class> c:concept.getConceptChildClasses()) {
+ if (c.isAssignableFrom(objClass)) {
+ return concept;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void buildParentPath(ApiDocNode node,List path) {
+ if (node.getParent()==null) {
+ path.add(node.getId());
+ return;
+ }
+ buildParentPath(node.getParent(),path);
+ path.add(node.getId());
+ }
+
+ private void writeStyleSheet() throws IOException {
+ try {
+ StringBuffer cssData = new StringBuffer();
+ appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-html.css");
+ appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-layout.css");
+ appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-inset.css");
+ appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-font.css");
+ appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/base/api-color.css");
+
+ //appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css");
+ appendResourceToBuffer(cssData,"org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css");
+
+ String css = cssData.toString();
+ css = css.replaceAll("\\s+"," ");
+ css = css.replaceAll("\\s*:\\s*",":");
+ css = css.replaceAll("\\s*\\;\\s*",";");
+ css = css.replaceAll("\\s*\\,\\s*",",");
+ css = css.replaceAll("\\s*\\{\\s*","{");
+ css = css.replaceAll("\\s*\\}\\s*","}\n"); // add return to have multi line file.
+
+ writeFileString(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(ApiDocContentWriter writer,String resourcePrefix,String title) throws SAXException {
+ writer.printTagStart(Tag.head);
+ writer.docCommentGenerated();
+ writer.printHeadMetaContentType();
+ writer.printHeadTitle(title);
+ writer.printHeadMetaDate();
+ writer.printHeadLinkCss(resourcePrefix+"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."+ApiDocContentCss.frameContent.name()+".location = top.targetPage; }\n"+
+ "}\n";
+
+ public void writeIndex() throws SAXException {
+ File outputFile = createOutputPathFile(basePath,"index.html");
+ ApiDocContentWriter writer = createContentWriter(outputFile);
+ try {
+ writer.printDocType(DocType.HTML_4_FRAMESET);
+ writer.comment("NewPage");
+ writer.printHtmlStart("en");
+ writeHeader(writer,"",doc.getName());
+ 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);
+
+ ApiDocConcept rootConcept = findConceptByClass(doc.getFrameNavConceptClass());
+ 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", "", "", ApiDocContentCss.frameNavOverview.name());
+ writer.printTagStart(Tag.frame, atts);
+ writer.printTagEnd(Tag.frame);
+ atts = new AttributesImpl();
+ atts.addAttribute ("", "src", "", "", "all"+rootConcept.getId()+"-frame.html");
+ atts.addAttribute ("", "title", "", "", "All Elements");
+ atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameNavDetail.name());
+ writer.printTagStart(Tag.frame, atts);
+ writer.printTagEnd(Tag.frame);
+ writer.printTagEnd(Tag.frameset);
+
+ String rootLink = "overview-"+ApiDocContentWriter.toSafeUri(doc.getRootNode().getId())+".html";
+
+ atts = new AttributesImpl();
+ atts.addAttribute ("", "src", "", "", rootLink);
+ atts.addAttribute ("", "title", "", "", "All Language Components");
+ atts.addAttribute ("", "name", "", "", ApiDocContentCss.frameContent.name());
+ atts.addAttribute ("", "scrolling", "", "", "yes");
+ writer.printTagStart(Tag.frame, atts);
+ writer.printTagEnd(Tag.frame);
+
+ writer.printTagStart(Tag.noframes);
+ writer.printScriptNoDiv();
+ writer.printTagCharacters(Tag.h2, "Frame Alert");
+ writer.printTagStart(Tag.p);
+ writer.characters("This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to ");
+ writer.printHref(rootLink, "Non-frame version");
+ writer.characters(".");
+ writer.printTagEnd(Tag.p);
+ writer.printTagEnd(Tag.noframes);
+
+ writer.printTagEnd(Tag.frameset);
+ writer.printHtmlEnd();
+ } finally {
+ writer.closeWriterSafe();
+ }
+ }
+
+ private void findNodeByUserDataClass(ApiDocNode node,Class> userDataClass,List result) {
+ if (userDataClass.isAssignableFrom(node.getUserData().getClass())) {
+ result.add(node);
+ }
+ for (ApiDocNode child:node.getNodes()) {
+ findNodeByUserDataClass((ApiDocNode)child,userDataClass,result);
+ }
+ }
+
+ public void writeOverviewFrame() throws SAXException {
+ ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
+ ApiDocConcept conceptParent = concept.getParent();
+ List nodes = new ArrayList(50);
+ findNodeByUserDataClass(doc.getRootNode(),conceptParent.getConceptClass(),nodes);
+
+ File outputFile = createOutputPathFile(basePath,"overview-frame.html");
+ ApiDocContentWriter writer = createContentWriter(outputFile);
+ try {
+ String conceptPlural = concept.getName()+"s";
+ String conceptParentPlural = conceptParent.getName()+"s";
+
+ writer.printDocType(DocType.HTML_4_TRANSITIONAL);
+ writer.comment("NewPage");
+ writer.printHtmlStart("en");
+ writeHeader(writer,"","All "+conceptPlural+" of "+doc.getName());
+ writer.printTagStart(Tag.body);
+
+ writer.printTagStart(Tag.div,ApiDocContentCss.indexHeader);
+ writer.printHrefTarget("all"+concept.getId()+"-frame.html", "All "+conceptPlural,ApiDocContentCss.frameNavDetail.name());
+ writer.printTagEnd(Tag.div);
+
+ writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
+ writer.printTagCharacters(Tag.h2, conceptParentPlural);
+ writer.printTagStart(Tag.ul);
+ for (ApiDocNode node:nodes) {
+ String linkName = node.getName();
+ if (doc.getFrameNavOverviewPrintParent()) {
+ if (doc.getFrameNavPrintParentId()) {
+ linkName = node.getParent().getId()+":"+node.getName();
+ } else {
+ linkName = node.getParent().getName()+":"+node.getName();
+ }
+ }
+ writer.printTagStart(Tag.li);
+ writer.printHrefTarget(doc.getRootNode().getId()+"/"+ApiDocContentWriter.toSafeUri(node.getParent().getId())+"/"+node.getId()+"/"+node.getId()+"-frame.html", linkName,ApiDocContentCss.frameNavDetail.name());
+ writer.printTagEnd(Tag.li);
+ }
+ writer.printTagEnd(Tag.ul);
+ writer.printTagEnd(Tag.div);
+
+ writer.printTagEnd(Tag.body);
+ writer.printHtmlEnd();
+ } finally {
+ writer.closeWriterSafe();
+ }
+ }
+
+ public void writeAllFrameNav(boolean isFrame) throws SAXException {
+ ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
+ if (isFrame) {
+ writeAllFrameNav("",true,null,"all"+concept.getId()+"-frame.html");
+ } else {
+ writeAllFrameNav("",false,null,"all"+concept.getId()+"-noframe.html");
+ }
+ }
+
+ private void writeAllFrameNavNode(ApiDocNode node) throws SAXException {
+ ApiDocConcept concept = findConceptByClass(doc.getFrameNavConceptClass());
+ ApiDocConcept conceptParent = concept.getParent();
+ if (!conceptParent.getConceptClass().isAssignableFrom(node.getUserData().getClass())) {
+ return; // only frame nav nodes.
+ }
+ List path = new ArrayList(10);
+ buildParentPath(node,path);
+ String pathS = "";
+ for (int i=0;i nodes = new ArrayList(50);
+ findNodeByUserDataClass(doc.getRootNode(),concept.getConceptClass(),nodes);
+
+ File outputFile = createOutputPathFile(basePath,fileName);
+ ApiDocContentWriter writer = createContentWriter(outputFile);
+ try {
+ String conceptPlural = concept.getName()+"s";
+ //String conceptParentPlural = conceptParent.getName()+"s";
+
+ writer.printDocType(DocType.HTML_4_TRANSITIONAL);
+ writer.comment("NewPage");
+ writer.printHtmlStart("en");
+ writeHeader(writer,pathPrefix,"All "+conceptPlural+" of "+doc.getName());
+ writer.printTagStart(Tag.body);
+ if (searchNode==null) {
+ writer.printTagCharacters(Tag.h1, "All "+conceptPlural, "bar");
+ } else {
+ writer.printTagStart(Tag.h1,ApiDocContentCss.bar);
+ writer.printHrefTarget("index.html", searchNode.getId(),ApiDocContentCss.frameContent.name());
+ writer.printTagEnd(Tag.h1);
+ }
+
+ writer.printTagStart(Tag.div,ApiDocContentCss.indexContainer);
+ writer.printTagStart(Tag.ul);
+
+ boolean printParent = new Boolean(true).equals(doc.getFrameNavPrintParent());
+ boolean printParentParent = new Boolean(true).equals(doc.getFrameNavPrintParentParent());
+
+ for (ApiDocNode node:nodes) {
+ List nodePath = new ArrayList(10);
+ buildParentPath(node,nodePath);
+ if (searchNode!=null) {
+ // TODO: compare full tree paths.
+ if (!node.getParent().getId().equals(searchNode.getId())) {
+ continue;
+ }
+ if (searchNode.getParent()!=null && !node.getParent().getParent().getId().equals(searchNode.getParent().getId())) {
+ continue;
+ }
+ if (searchNode.getParent().getParent()!=null && !node.getParent().getParent().getParent().getId().equals(searchNode.getParent().getParent().getId())) {
+ continue;
+ }
+ }
+
+ String linkName = node.getName();
+ String linkUrl = ApiDocContentWriter.toSafeUri(nodePath)+"/index.html";
+ if (searchNode!=null) {
+ linkUrl = ApiDocContentWriter.toSafeUri(node.getId(),"index.html");
+ }
+ if (printParent) {
+ if (printParentParent) {
+ if (doc.getFrameNavPrintParentId()) {
+ linkName = node.getParent().getParent().getId()+":"+linkName;
+ } else {
+ linkName = node.getParent().getParent().getName()+":"+linkName;
+ }
+ } else {
+ if (doc.getFrameNavPrintParentId()) {
+ linkName = node.getParent().getId()+":"+linkName;
+ } else {
+ linkName = node.getParent().getName()+":"+linkName;
+ }
+ }
+ }
+ writer.printTagStart(Tag.li);
+ if (isFrame) {
+ writer.printHrefTarget(linkUrl, linkName,ApiDocContentCss.frameContent.name());
+ } else {
+ writer.printHref(linkUrl, linkName);
+ }
+ writer.printTagEnd(Tag.li);
+ }
+
+ writer.printTagEnd(Tag.ul);
+ writer.printTagEnd(Tag.div);
+
+ writer.printTagEnd(Tag.body);
+ writer.printHtmlEnd();
+ } finally {
+ writer.closeWriterSafe();
+ }
+ }
+
+ private void writePage(ApiDocPage page) throws SAXException {
+ File outputFile = createOutputPathFile(basePath,page.getId()+".html");
+ ApiDocContentWriter writer = createContentWriter(outputFile);
+ String pathPrefix = "";
+ try {
+ NavBarConfig conf = createNavBarConfig(pathPrefix, outputFile, writer);
+ conf.navSelected=page.getId();
+ String title = page.getName();
+ writer.docHtmlStart(conf,title, doc.getDocKeywords());
+ writer.docPageClassStart(title, page.getDescription());
+
+ ApiDocWriteEvent e = new ApiDocWriteEvent(doc,writer,page);
+
+ //writer.docPageContentStart();
+ for (ApiDocPageWriter pageWriter:page.getPageWriters()) {
+ pageWriter.writePageContent(e);
+ }
+ //writer.docPageContentEnd();
+
+ writer.docPageClassEnd();
+ writer.docHtmlEnd(conf, doc.getDocCopyright());
+ } finally {
+ writer.closeWriterSafe();
+ }
+ }
+
+ private void appendResourceToBuffer(StringBuffer buffer,String resource) throws IOException {
+ ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
+ BufferedReader reader = null;
+ try {
+ InputStream inputStream = cl.getResourceAsStream(resource);
+ reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+ for (int c = reader.read(); c != -1; c = reader.read()) {
+ buffer.append((char)c);
+ }
+ } finally {
+ if (reader!=null) {
+ reader.close();
+ }
+ }
+ }
+
+ private void writeFileString(String text,File basePath,String...argu) throws SecurityException, IOException, InterruptedException {
+ OutputStream outputStream = new FileOutputStream(createOutputPathFile(basePath,argu));
+ try {
+ for (int i=0;i e) throws SAXException {
+ ApiDoc doc = e.getDoc();
+ //ApiDocPage page = e.getEvent();
+ ApiDocContentWriter writer = e.getWriter();
+
+ writer.printTagStart(Tag.div,"header");
+ writer.printTagCharacters(Tag.h1, "How This API Document Is Organized", "title");
+ writer.printTagStart(Tag.div,"subTitle");
+ writer.characters("This ApiDoc document has pages corresponding to the items in the navigation bar, described as follows.");
+ writer.printTagEnd(Tag.div);
+ writer.printTagEnd(Tag.div);
+
+ writer.docPageContentStart();
+ writer.docPageBlockStart();
+ for (ApiDocConcept concept:doc.getConcepts()) {
+ writer.printTagCharacters(Tag.h2, concept.getName());
+ writer.printTagStart(Tag.p);
+ writer.charactersRaw(concept.getDescriptionHelp());
+ writer.printTagEnd(Tag.p);
+ writer.docPageBlockNext();
+ }
+ for (ApiDocPage docPage:doc.getDocPages()) {
+ writer.printTagCharacters(Tag.h2, docPage.getName());
+ writer.printTagStart(Tag.p);
+ writer.charactersRaw(docPage.getDescription());
+ writer.printTagEnd(Tag.p);
+ writer.docPageBlockNext();
+ }
+ writer.docPageBlockEnd();
+ writer.docPageContentEnd();
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterIndexAll.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterIndexAll.java
new file mode 100644
index 0000000..83098f1
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterIndexAll.java
@@ -0,0 +1,59 @@
+/*
+ * 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.api;
+
+import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
+import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
+import org.xml.sax.SAXException;
+
+/**
+ * DefaultPageWriterIndexAll creates the index-all page content.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 22, 2013
+ */
+public class DefaultPageWriterIndexAll implements ApiDocPageWriter {
+
+ public static ApiDocPage createDocPage() {
+ return new ApiDocPage("index-all","Index","Index of all api ketwords.",new DefaultPageWriterIndexAll());
+ }
+
+ public void writePageContent(ApiDocWriteEvent e) throws SAXException {
+ // ApiDoc doc = e.getDoc();
+ // ApiDocPage page = e.getEvent();
+ ApiDocContentWriter writer = e.getWriter();
+ 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.printTagCharacters(Tag.h2, ""+i);
+ writer.characters("TODO");
+ }
+ writer.docPageContentEnd();
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterTree.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterTree.java
new file mode 100644
index 0000000..239f7df
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/DefaultPageWriterTree.java
@@ -0,0 +1,89 @@
+/*
+ * 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.api;
+
+import org.x4o.xml.eld.doc.api.dom.ApiDoc;
+import org.x4o.xml.eld.doc.api.dom.ApiDocNode;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPage;
+import org.x4o.xml.eld.doc.api.dom.ApiDocPageWriter;
+import org.x4o.xml.eld.doc.api.dom.ApiDocWriteEvent;
+import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag;
+import org.xml.sax.SAXException;
+
+/**
+ * DefaultPageWriterTree creates the default tree overview page content.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 22, 2013
+ */
+public class DefaultPageWriterTree implements ApiDocPageWriter {
+
+ public static ApiDocPage createDocPage() {
+ return new ApiDocPage("overview-tree","Tree","Tree of api concepts.",new DefaultPageWriterTree());
+ }
+
+ protected ApiDocNode selectRootNode(ApiDoc doc) {
+ ApiDocNode rootNode = doc.getRootNodeTreePage();
+ if (rootNode==null) {
+ rootNode = doc.getRootNode();
+ }
+ return rootNode;
+ }
+
+ public void writePageContent(ApiDocWriteEvent e) throws SAXException {
+ ApiDoc doc = e.getDoc();
+ ApiDocPage page = e.getEvent();
+ ApiDocContentWriter writer = e.getWriter();
+ //writer.docPagePackageTitle(title, "Overview Tree");
+ writer.docPageContentStart();
+ writeTree(doc,selectRootNode(doc),writer,"");
+ writer.docPagePackageDescription(page.getName(), "Tree","All Language elements as tree.");
+ writer.docPageContentEnd();
+ }
+
+ private void writeTree(ApiDoc doc, ApiDocNode node,ApiDocContentWriter writer,String pathPrefix) throws SAXException {
+
+ for (Class> excludeClass:doc.getTreeNodeClassExcludes()) {
+ if (excludeClass.isAssignableFrom(node.getUserData().getClass())) {
+ return;
+ }
+ }
+
+
+ String href = ApiDocContentWriter.toSafeUri("todo");// toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
+
+ writer.printTagStart(Tag.ul);
+ writer.printTagStart(Tag.li,"",null,"circle");
+ if (node.getParent()!=null) {
+ writer.characters(node.getParent().getId());
+ writer.characters(":");
+ }
+ writer.printHref(href, node.getName(), node.getName(), "strong");
+ writer.printTagEnd(Tag.li);
+
+ for (ApiDocNode child:node.getNodes()) {
+ writeTree(doc,child,writer,pathPrefix);
+ }
+ writer.printTagEnd(Tag.ul);
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDoc.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDoc.java
new file mode 100644
index 0000000..e6708bc
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDoc.java
@@ -0,0 +1,350 @@
+/*
+ * 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.api.dom;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * ApiDoc holds all config and data to write a full api doc structure.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public class ApiDoc {
+
+ private String name = null;
+ private String description = null;
+ private ApiDocNode rootNode = null;
+ private ApiDocNode rootNodeTreePage = null;
+ private List nodeBodyWriters = null;
+ private List concepts = null;
+ private String docCopyright = null;
+ private String docAbout = null;
+ private List docKeywords = null;
+ private List docPages = null;
+ private Class> frameNavConceptClass = null;
+ private Boolean frameNavOverviewPrintParent = null;
+ private Boolean frameNavPrintParentId = null;
+ private Boolean frameNavPrintParent = null;
+ private Boolean frameNavPrintParentParent = null;
+ private List> treeNodeClassExcludes = null;
+
+ public ApiDoc() {
+ nodeBodyWriters = new ArrayList(20);
+ concepts = new ArrayList(10);
+ docKeywords = new ArrayList(5);
+ docPages = new ArrayList(5);
+ treeNodeClassExcludes = new ArrayList>(5);
+ }
+
+ public ApiDoc(ApiDocNode rootNode) {
+ this();
+ setRootNode(rootNode);
+ }
+
+ public void checkModel() throws NullPointerException,IllegalArgumentException {
+ checkNull(name,"name");
+ checkNull(description,"description");
+ checkNull(docAbout,"docAbout");
+ checkNull(docCopyright,"docCopyright");
+ checkNull(rootNode,"rootNode");
+ checkNull(frameNavConceptClass,"frameNavConceptClass");
+ if (concepts.isEmpty()) {
+ throw new IllegalStateException("Can't work with empty concepts");
+ }
+ if (nodeBodyWriters.isEmpty()) {
+ throw new IllegalStateException("Can't work with empty nodeBodyWriters");
+ }
+ if (frameNavOverviewPrintParent==null) {
+ frameNavOverviewPrintParent=false;
+ }
+ if (frameNavPrintParent==null) {
+ frameNavPrintParent=false;
+ }
+ if (frameNavPrintParentParent==null) {
+ frameNavPrintParentParent=false;
+ }
+ if (frameNavPrintParentId==null) {
+ frameNavPrintParentId=false;
+ }
+ }
+
+ private void checkNull(Object obj,String objName) {
+ if (obj==null) {
+ throw new NullPointerException("Can't work with null "+objName);
+ }
+ }
+
+ public ApiDocNodeWriter addNodeBodyWriter(ApiDocNodeWriter writer) {
+ nodeBodyWriters.add(writer);
+ return writer;
+ }
+
+ public boolean removeNodeBodyWriter(ApiDocNodeWriter writer) {
+ return nodeBodyWriters.remove(writer);
+ }
+
+ public List getNodeBodyWriters() {
+ return nodeBodyWriters;
+ }
+
+ public ApiDocConcept addConcept(ApiDocConcept concept) {
+ concepts.add(concept);
+ return concept;
+ }
+
+ public boolean removeConcept(ApiDocConcept concept) {
+ return concepts.remove(concept);
+ }
+
+ public List getConcepts() {
+ return concepts;
+ }
+
+ public void addDocKeyword(String keyword) {
+ docKeywords.add(keyword);
+ }
+
+ public void addDocKeywordAll(Collection keywords) {
+ docKeywords.addAll(keywords);
+ }
+
+ public boolean removeDocKeyword(String keyword) {
+ return docKeywords.remove(keyword);
+ }
+
+ public List getDocKeywords() {
+ return docKeywords;
+ }
+
+ /**
+ * @return the docCopyright
+ */
+ public String getDocCopyright() {
+ return docCopyright;
+ }
+
+ /**
+ * @param docCopyright the docCopyright to set
+ */
+ public void setDocCopyright(String docCopyright) {
+ this.docCopyright = docCopyright;
+ }
+
+ /**
+ * Creates default copyright message for owner.
+ * @param owner The owner of the copyright.
+ */
+ public void createDocCopyright(String owner) {
+ Calendar calendar = Calendar.getInstance();
+ StringBuffer buf = new StringBuffer(100);
+ buf.append("Copyright © ");
+ buf.append(calendar.get(Calendar.YEAR));
+ buf.append(" ");
+ buf.append(owner.toUpperCase());
+ buf.append(" ");
+ buf.append("All Rights Reserved.");
+ setDocCopyright(buf.toString());
+ }
+
+ /**
+ * @return the docAbout
+ */
+ public String getDocAbout() {
+ return docAbout;
+ }
+
+ /**
+ * @param docAbout the docAbout to set
+ */
+ public void setDocAbout(String docAbout) {
+ this.docAbout = docAbout;
+ }
+
+ public ApiDocPage addDocPage(ApiDocPage page) {
+ docPages.add(page);
+ return page;
+ }
+
+ public boolean removeDocPage(ApiDocPage page) {
+ return docPages.remove(page);
+ }
+
+ public List getDocPages() {
+ return docPages;
+ }
+
+ public ApiDocPage findDocPageById(String docPageId) {
+ if (docPageId==null) {
+ throw new NullPointerException("Can't search for null id.");
+ }
+ for (ApiDocPage page:docPages) {
+ if (page.getId().equals(docPageId)) {
+ return page;
+ }
+ }
+ return null;
+ }
+
+ public Class> addTreeNodeClassExclude(Class> excludeClass) {
+ treeNodeClassExcludes.add(excludeClass);
+ return excludeClass;
+ }
+
+ public boolean removeTreeNodeClassExclude(Class> excludeClass) {
+ return treeNodeClassExcludes.remove(excludeClass);
+ }
+
+ public List> getTreeNodeClassExcludes() {
+ return treeNodeClassExcludes;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the rootNodeTreePage
+ */
+ public ApiDocNode getRootNodeTreePage() {
+ return rootNodeTreePage;
+ }
+
+ /**
+ * @param rootNodeTreePage the rootNodeTreePage to set
+ */
+ public void setRootNodeTreePage(ApiDocNode rootNodeTreePage) {
+ this.rootNodeTreePage = rootNodeTreePage;
+ }
+
+ /**
+ * @return the rootNode
+ */
+ public ApiDocNode getRootNode() {
+ return rootNode;
+ }
+
+ /**
+ * @param rootNode the rootNode to set
+ */
+ public void setRootNode(ApiDocNode rootNode) {
+ this.rootNode = rootNode;
+ }
+
+ /**
+ * @return the frameNavConceptClass
+ */
+ public Class> getFrameNavConceptClass() {
+ return frameNavConceptClass;
+ }
+
+ /**
+ * @param frameNavConceptClass the frameNavConceptClass to set
+ */
+ public void setFrameNavConceptClass(Class> frameNavConceptClass) {
+ this.frameNavConceptClass = frameNavConceptClass;
+ }
+
+ /**
+ * @return the frameNavPrintParent
+ */
+ public Boolean getFrameNavPrintParent() {
+ return frameNavPrintParent;
+ }
+
+ /**
+ * @param frameNavPrintParent the frameNavPrintParent to set
+ */
+ public void setFrameNavPrintParent(Boolean frameNavPrintParent) {
+ this.frameNavPrintParent = frameNavPrintParent;
+ }
+
+ /**
+ * @return the frameNavPrintParentParent
+ */
+ public Boolean getFrameNavPrintParentParent() {
+ return frameNavPrintParentParent;
+ }
+
+ /**
+ * @param frameNavPrintParentParent the frameNavPrintParentParent to set
+ */
+ public void setFrameNavPrintParentParent(Boolean frameNavPrintParentParent) {
+ this.frameNavPrintParentParent = frameNavPrintParentParent;
+ }
+
+ /**
+ * @return the frameNavOverviewPrintParent
+ */
+ public Boolean getFrameNavOverviewPrintParent() {
+ return frameNavOverviewPrintParent;
+ }
+
+ /**
+ * @param frameNavOverviewPrintParent the frameNavOverviewPrintParent to set
+ */
+ public void setFrameNavOverviewPrintParent(Boolean frameNavOverviewPrintParent) {
+ this.frameNavOverviewPrintParent = frameNavOverviewPrintParent;
+ }
+
+ /**
+ * @return the frameNavPrintParentId
+ */
+ public Boolean getFrameNavPrintParentId() {
+ return frameNavPrintParentId;
+ }
+
+ /**
+ * @param frameNavPrintParentId the frameNavPrintParentId to set
+ */
+ public void setFrameNavPrintParentId(Boolean frameNavPrintParentId) {
+ this.frameNavPrintParentId = frameNavPrintParentId;
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocConcept.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocConcept.java
new file mode 100644
index 0000000..ccc9bcd
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocConcept.java
@@ -0,0 +1,167 @@
+/*
+ * 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.api.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ApiDocConcept defines the prime concepts which for which we write documents.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public class ApiDocConcept {
+
+ private String id = null;
+ private String name = null;
+ private String descriptionName = null;
+ private String descriptionHelp = null;
+ private ApiDocConcept parent = null;
+ private Class> conceptClass = null;
+ private List> conceptChildClasses = null;
+
+ public ApiDocConcept() {
+ conceptChildClasses = new ArrayList>(5);
+ }
+
+ public ApiDocConcept(ApiDocConcept parent,String id,Class> conceptClass) {
+ this();
+ setId(id);
+ setConceptClass(conceptClass);
+ setParent(parent);
+ }
+
+ public ApiDocConcept(ApiDocConcept parent,String[] text,Class> conceptClass,Class>...classes) {
+ this(parent,text[0],text[1],text[2],text[3],conceptClass,classes);
+ }
+
+ public ApiDocConcept(ApiDocConcept parent,String id,String name,String descriptionName,String descriptionHelp,Class> conceptClass,Class>...classes) {
+ this(parent,id,conceptClass);
+ setName(name);
+ setDescriptionName(descriptionName);
+ setDescriptionHelp(descriptionHelp);
+ for (Class> cl:classes) {
+ addConceptChildClass(cl);
+ }
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the descriptionName
+ */
+ public String getDescriptionName() {
+ return descriptionName;
+ }
+
+ /**
+ * @param descriptionName the descriptionName to set
+ */
+ public void setDescriptionName(String descriptionName) {
+ this.descriptionName = descriptionName;
+ }
+
+ /**
+ * @return the descriptionHelp
+ */
+ public String getDescriptionHelp() {
+ return descriptionHelp;
+ }
+
+ /**
+ * @param descriptionHelp the descriptionHelp to set
+ */
+ public void setDescriptionHelp(String descriptionHelp) {
+ this.descriptionHelp = descriptionHelp;
+ }
+
+ /**
+ * @return the conceptClass
+ */
+ public Class> getConceptClass() {
+ return conceptClass;
+ }
+
+ /**
+ * @param conceptClass the conceptClass to set
+ */
+ public void setConceptClass(Class> conceptClass) {
+ this.conceptClass = conceptClass;
+ }
+
+ public void addConceptChildClass(Class> targetClass) {
+ conceptChildClasses.add(targetClass);
+ }
+
+ public void removeConceptChildClass(Class> targetClass) {
+ conceptChildClasses.remove(conceptChildClasses);
+ }
+
+ public List> getConceptChildClasses() {
+ return conceptChildClasses;
+ }
+
+ /**
+ * @return the parent
+ */
+ public ApiDocConcept getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent the parent to set
+ */
+ public void setParent(ApiDocConcept parent) {
+ this.parent = parent;
+ }
+
+
+}
+
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNode.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNode.java
new file mode 100644
index 0000000..d48f5f1
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNode.java
@@ -0,0 +1,164 @@
+/*
+ * 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.api.dom;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * ApiDocNode defines the concept impl data tree nodes for which we write documents.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public class ApiDocNode {
+
+ private Object userData = null;
+ private String id = null;
+ private String name = null;
+ private String description = null;
+ private ApiDocNode parent = null;
+ private List nodes = null;
+ private Map contentGroupTypes = null;
+
+ public ApiDocNode() {
+ nodes = new ArrayList(30);
+ contentGroupTypes = new HashMap(3);
+ }
+
+ public ApiDocNode(Object userData,String id,String name,String description) {
+ this();
+ setUserData(userData);
+ setId(id);
+ setName(name);
+ if (description==null) {
+ description = name;
+ }
+ setDescription(description);
+ }
+
+ public ApiDocNode addNode(ApiDocNode node) {
+ node.setParent(this);
+ nodes.add(node);
+ return node;
+ }
+
+ public boolean removeNode(ApiDocNode node) {
+ return nodes.remove(node);
+ }
+
+ public List getNodes() {
+ return nodes;
+ }
+
+ public void addContentGroupType(String id,String name) {
+ contentGroupTypes.put(id, name);
+ }
+
+ public void removeContentGroupType(String id) {
+ contentGroupTypes.remove(id);
+ }
+
+ public String getContentGroupTypeName(String id) {
+ return contentGroupTypes.get(id);
+ }
+
+ public Set getContentGroupTypeKeys() {
+ return contentGroupTypes.keySet();
+ }
+
+ /**
+ * @return the userData
+ */
+ public Object getUserData() {
+ return userData;
+ }
+
+ /**
+ * @param userData the userData to set
+ */
+ public void setUserData(Object userData) {
+ this.userData = userData;
+ }
+
+
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the parent
+ */
+ public ApiDocNode getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent the parent to set
+ */
+ public void setParent(ApiDocNode parent) {
+ this.parent = parent;
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeBody.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeBody.java
new file mode 100644
index 0000000..7f98803
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeBody.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.eld.doc.api.dom;
+
+/**
+ * ApiDocNodeBody are the parts from which the content body is created.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public enum ApiDocNodeBody {
+
+ TREE_PATH,
+ DESCRIPTION_LINKS,
+ DESCRIPTION_NODE,
+ SUMMARY,
+ DETAIL
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java
new file mode 100644
index 0000000..c0659f0
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java
@@ -0,0 +1,41 @@
+/*
+ * 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.api.dom;
+
+import java.util.List;
+
+import org.xml.sax.SAXException;
+
+/**
+ * ApiDocNodeWriter are the parts from which the content body is created.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public interface ApiDocNodeWriter {
+
+ ApiDocNodeBody getNodeBody();
+ List> getTargetClasses();
+
+ void writeNodeContent(ApiDocWriteEvent e) throws SAXException;
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPage.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPage.java
new file mode 100644
index 0000000..64174ef
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPage.java
@@ -0,0 +1,117 @@
+/*
+ * 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.api.dom;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ApiDocPage defines seperate pages for the documentation.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public class ApiDocPage {
+
+ private String id = null;
+ private String name = null;
+ private String description = null;
+ private List pageWriters = null;
+
+ public ApiDocPage() {
+ pageWriters = new ArrayList(30);
+ }
+
+ public ApiDocPage(String id,String name,String description,ApiDocPageWriter...writers) {
+ this();
+ setId(id);
+ setName(name);
+ setDescription(description);
+ for (ApiDocPageWriter writer:writers) {
+ addPageWriter(writer);
+ }
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the page writers.
+ */
+ public List getPageWriters() {
+ return pageWriters;
+ }
+
+ /**
+ * @param writer the writer to add.
+ */
+ public void addPageWriter(ApiDocPageWriter writer) {
+ pageWriters.add(writer);
+ }
+
+ /**
+ * @param writer the writer to add.
+ */
+ public void removePageWriter(ApiDocPageWriter writer) {
+ pageWriters.remove(writer);
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPageWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPageWriter.java
new file mode 100644
index 0000000..9921337
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocPageWriter.java
@@ -0,0 +1,36 @@
+/*
+ * 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.api.dom;
+
+import org.xml.sax.SAXException;
+
+/**
+ * ApiDocPageWriter writes a page content part.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public interface ApiDocPageWriter {
+
+ void writePageContent(ApiDocWriteEvent e) throws SAXException;
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocWriteEvent.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocWriteEvent.java
new file mode 100644
index 0000000..9b88f3b
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocWriteEvent.java
@@ -0,0 +1,71 @@
+/*
+ * 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.api.dom;
+
+import org.x4o.xml.eld.doc.api.ApiDocContentWriter;
+
+/**
+ * ApiDocWriteEvent holds the needed objects to process write events of content parts.
+ *
+ * @author Willem Cazander
+ * @version 1.0 May 12, 2013
+ */
+public class ApiDocWriteEvent {
+
+ private ApiDoc doc = null;
+ private T event = null;
+ private ApiDocContentWriter writer = null;
+
+ /**
+ * Creates an ApiDocNodeBodyEvent.
+ * @param doc The ApiDoc we are writing.
+ * @param writer The content writer to write to.
+ * @param event The event we are firing this event for.
+ */
+ public ApiDocWriteEvent(ApiDoc doc,ApiDocContentWriter writer,T event) {
+ this.doc=doc;
+ this.writer=writer;
+ this.event=event;
+ }
+
+ /**
+ * @return the doc
+ */
+ public ApiDoc getDoc() {
+ return doc;
+ }
+
+ /**
+ * @return the event
+ */
+ public T getEvent() {
+ return event;
+ }
+
+ /**
+ * @return the writer
+ */
+ public ApiDocContentWriter getWriter() {
+ return writer;
+ }
+}
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java
new file mode 100644
index 0000000..714f1cc
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/**
+ * Api Doc Dom classes.
+ *
+ * @author Willem Cazander
+ * @since 1.0 May 12,2013
+ */
+package org.x4o.xml.eld.doc.api.dom;
diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java
new file mode 100644
index 0000000..8a72477
--- /dev/null
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/**
+ * Api Doc Writer classes.
+ *
+ * @author Willem Cazander
+ * @since 1.0 May 12,2013
+ */
+package org.x4o.xml.eld.doc.api;
diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/package-info.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/package-info.java
similarity index 96%
rename from x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/package-info.java
rename to x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/package-info.java
index 45ed7fd..6ac7ab9 100644
--- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/package-info.java
+++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/package-info.java
@@ -20,10 +20,12 @@
* 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.
*/
+
/**
* The X4O ELD documentation classes.
*
- * @since 1.0
+ * @author Willem Cazander
+ * @since 1.0 Aug 26, 2010
*/
package org.x4o.xml.eld.doc;
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css
new file mode 100644
index 0000000..e7df1cc
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-color.css
@@ -0,0 +1,127 @@
+
+/* Color style sheet */
+
+body {
+ background-color:#ffffff;
+ color:#353833;
+}
+a:link, a:visited {
+ color:#4c6b87;
+}
+a:hover, a:focus {
+ color:#bb7a2a;
+}
+a:active {
+ color:#4c6b87;
+}
+a[name] {
+ color:#353833;
+}
+a[name]:hover {
+ color:#353833;
+}
+.bar a, .bar a:link, .bar a:visited, .bar a:active {
+ color:#FFFFFF;
+}
+.bar a:hover, .bar a:focus {
+ color:#bb7a2a;
+}
+.tab {
+ background-color:#0066FF;
+ color:#ffffff;
+}
+.bar {
+ color:#FFFFFF;
+}
+.topNav {
+ color:#FFFFFF;
+}
+.bottomNav {
+ color:#FFFFFF;
+}
+.subNav {
+ background-color:#dee3e9;
+ border-bottom:1px solid #9eadc0;
+}
+.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
+ color:#FFFFFF;
+}
+.topNav a:hover, .bottomNav a:hover {
+ color:#bb7a2a;
+}
+.navBarCell1Rev {
+ color:#FFFFFF;
+ border:1px solid #c9aa44;
+}
+.title {
+ color:#2c4557;
+}
+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;
+}
+ul.blockList ul.blockList ul.blockList li.blockList h3 {
+ background-color:#dee3e9;
+ border-top:1px solid #9eadc0;
+ border-bottom:1px solid #9eadc0;
+}
+.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
+ color:#4E4E4E;
+}
+ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
+ border:1px solid #9eadc0;
+ background-color:#f9f9f9;
+}
+ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
+ background-color:#ffffff;
+ border:1px solid #9eadc0;
+ border-top:none;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
+ border:none;
+ border-bottom:1px solid #9eadc0;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
+ border-bottom:none;
+}
+.contentContainer table, .classUseContainer table, .constantValuesContainer table {
+ border-bottom:1px solid #9eadc0;
+}
+.contentContainer .description table, .contentContainer .details table {
+ border-bottom:none;
+}
+.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
+ color:#FFFFFF;
+}
+caption a:link, caption a:hover, caption a:active, caption a:visited {
+ color:#FFFFFF;
+}
+.tableSubHeadingColor {
+ background-color: #EEEEFF;
+}
+.altColor {
+ background-color:#eeeeef;
+}
+.rowColor {
+ background-color:#ffffff;
+}
+th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
+ background:#dee3e9;
+ border-top:1px solid #9eadc0;
+ border-bottom:1px solid #9eadc0;
+}
+td.colFirst, th.colFirst {
+ border-left:1px solid #9eadc0;
+}
+td.colLast, th.colLast {
+ border-right:1px solid #9eadc0;
+}
+td.colOne, th.colOne {
+ border-right:1px solid #9eadc0;
+ border-left:1px solid #9eadc0;
+}
+.sourceLineNo {
+ color:green;
+}
+
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css
new file mode 100644
index 0000000..dab9ba5
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-font.css
@@ -0,0 +1,92 @@
+
+body {
+ font-family:Arial, Helvetica, sans-serif;
+ font-size:76%;
+}
+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;
+}
+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;
+}
+.aboutLanguage {
+ font-size:0.8em;
+}
+.tab {
+ font-weight:bold;
+}
+.bar {
+ font-size:1.0em;
+}
+ul.subNavList li{
+ font-size:90%;
+}
+.indexHeader h1 {
+ font-size:1.3em;
+}
+.header ul li, .footer ul li {
+ font-size:1.2em;
+}
+.indexContainer {
+ font-size:1.0em;
+}
+.indexContainer h2 {
+ font-size:1.1em;
+}
+.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
+ font-size:1.1em;
+ font-weight:bold;
+}
+.serializedFormContainer dl.nameValue dt {
+ font-size:1.1em;
+ font-weight:bold;
+}
+.serializedFormContainer dl.nameValue dd {
+ font-size:1.1em;
+}
+ul.horizontal li {
+ font-size:0.9em;
+}
+.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
+ font-weight:bold;
+}
+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;
+}
+h1.hidden {
+ font-size:0.9em;
+}
+.strong {
+ font-weight:bold;
+}
+
+
+
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css
new file mode 100644
index 0000000..d0df950
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-html.css
@@ -0,0 +1,53 @@
+
+
+
+a:link, a:visited {
+ text-decoration:none;
+}
+a:hover, a:focus {
+ text-decoration:none;
+}
+a:active {
+ text-decoration:none;
+}
+a[name] {
+}
+a[name]:hover {
+ text-decoration:none;
+}
+
+ul {
+ list-style-type:disc;
+}
+.bar a, .bar a:link, .bar a:visited, .bar a:active {
+ text-decoration:none;
+}
+ul.navList li{
+ list-style:none;
+}
+ul.subNavList li{
+ list-style:none;
+}
+.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
+ text-decoration:none;
+}
+.topNav a:hover, .bottomNav a:hover {
+ text-decoration:none;
+}
+.header ul li, .footer ul li {
+ list-style:none;
+}
+.indexContainer ul li {
+ list-style:none;
+}
+ul.inheritance li {
+ list-style:none;
+}
+ul.blockList li.blockList, ul.blockListLast li.blockList {
+ list-style:none;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
+ list-style:none;
+}
+
+
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css
new file mode 100644
index 0000000..140e980
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-inset.css
@@ -0,0 +1,183 @@
+
+
+body {
+ margin:0px;
+ padding:0px;
+}
+.aboutLanguage {
+ padding:0px 21px;
+ margin-top:-7px;
+}
+.legalCopy {
+ margin-left:0.5em;
+}
+.tab {
+ padding:8px;
+}
+.bar {
+ padding:0.8em 0.5em 0.4em 0.8em;
+ margin:0px;
+}
+.topNav {
+ padding:0px;
+ padding-top:10px;
+}
+.bottomNav {
+ margin-top:10px;
+ padding:0px;
+ padding-top:10px;
+}
+.subNav div {
+ padding:0px 0px 5px 6px;
+}
+ul.navList, ul.subNavList {
+ margin:0px 25px 0px 0px;
+ padding:0px;
+}
+ul.navList li{
+ padding:3px 6px;
+}
+.navBarCell1Rev {
+ margin: auto 5px;
+}
+.header, .footer {
+ margin:0px 20px;
+ padding:5px 0px 0px 0px;
+}
+.indexHeader {
+ margin:10px;
+}
+.title {
+ margin:10px 0px;
+}
+.subTitle {
+ margin:5px 0px 0px 0px;
+}
+.header ul {
+ margin:0px 0px 25px 0px;
+ padding:0px;
+}
+.footer ul {
+ margin:20px 0 5px 0;
+}
+div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
+ margin:0px 0px 6px -8px;
+ padding:2px 5px;
+}
+ul.blockList ul.blockList ul.blockList li.blockList h3 {
+ 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 {
+ padding:10px 20px;
+}
+.indexContainer {
+ margin:10px;
+}
+.indexContainer h2 {
+ padding:0px 0px 3px 0px;
+}
+.indexContainer ul {
+ margin:0px;
+ padding:0px;
+}
+.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
+ margin:10px 0px 0px 0px;
+}
+.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
+ margin:10px 0px 10px 20px;
+}
+.serializedFormContainer dl.nameValue dt {
+ margin-left:1px;
+}
+.serializedFormContainer dl.nameValue dd {
+ margin:0px 0px 0px 1px;
+}
+ul.inheritance {
+ margin:0px;
+ padding:0px;
+}
+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 {
+ margin-bottom:25px;
+}
+ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
+ padding:0px 20px 5px 10px;
+}
+ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
+ padding:0px 0px 5px 8px;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
+ margin-left:0px;
+ padding-left:0px;
+ padding-bottom:15px;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
+ padding-bottom:0;
+}
+table tr td dl, table tr td dl dt, table tr td dl dd {
+ margin-top:0px;
+ margin-bottom:1px;
+}
+.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{
+ 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 {
+ padding:0px;
+ margin:0px;
+}
+.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
+ padding-top:8px;
+ padding-left:8px;
+}
+ul.blockList ul.blockList li.blockList table {
+ margin:0px 0px 12px 0px;
+}
+.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
+ padding:3px 3px 3px 7px;
+}
+th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
+ padding:3px 3px 3px 7px;
+}
+table.overviewSummary {
+ padding:0px;
+ margin-left:0px;
+}
+.description pre {
+ margin-top:0px;
+}
+.deprecatedContent {
+ margin:0px;
+ padding:10px 0px;
+}
+.docSummary {
+ padding:0px;
+}
+.sourceLineNo {
+ padding:0px 30px 0px 0px;
+}
+.block {
+ margin:3px 0px 0px 0px;
+}
+
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css
new file mode 100644
index 0000000..a5fc9fc
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/base/api-layout.css
@@ -0,0 +1,131 @@
+
+
+.clear {
+ clear:both;
+ height:0px;
+ overflow:hidden;
+}
+.aboutLanguage {
+ float:right;
+ z-index:200;
+}
+
+.tab {
+ width:5em;
+}
+.bar {
+ height:auto;
+}
+.topNav {
+ float:left;
+ width:100%;
+ clear:right;
+ height:2.8em;
+ overflow:hidden;
+}
+.bottomNav {
+ float:left;
+ width:100%;
+ clear:right;
+ height:2.8em;
+ overflow:hidden;
+}
+.subNav {
+ float:left;
+ width:100%;
+ overflow:hidden;
+}
+.subNav div {
+ clear:left;
+ float:left;
+}
+ul.navList, ul.subNavList {
+ float:left;
+}
+ul.navList li, ul.subNavList li {
+ float:left;
+}
+.header, .footer {
+ clear:both;
+}
+.indexHeader {
+ position:relative;
+}
+.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
+ clear:both;
+ position:relative;
+}
+.indexContainer {
+ position:relative;
+}
+.serializedFormContainer dl.nameValue dt {
+ display:inline;
+}
+.serializedFormContainer dl.nameValue dd {
+ display:inline;
+}
+ul.horizontal li {
+ display:inline;
+}
+ul.inheritance li {
+ display:inline;
+}
+.contentContainer table, .classUseContainer table, .constantValuesContainer table {
+ width:100%;
+}
+.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table {
+ width:100%;
+}
+.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;
+}
+.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption {
+ position:relative;
+ text-align:left;
+ clear:none;
+ overflow:hidden;
+}
+.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;
+ display:block;
+ float:left;
+ height:18px;
+}
+.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
+ width:10px;
+ position:relative;
+ float:left;
+}
+ul.blockList ul.blockList li.blockList table {
+ width:100%;
+}
+.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td {
+ text-align:left;
+}
+th.colFirst, th.colLast, th.colOne, .constantValuesContainer th {
+ text-align:left;
+}
+td.colFirst, th.colFirst {
+ white-space:nowrap;
+}
+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;
+}
+h1.hidden {
+ visibility:hidden;
+ overflow:hidden;
+}
+.block {
+ display:block;
+}
+
+
+
+
+
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css
new file mode 100644
index 0000000..cd976bd
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk6/stylesheet.css
@@ -0,0 +1,106 @@
+
+body {
+ padding:10px;
+ font-family:none;
+}
+
+.topNav,
+.bottomNav {
+ height:auto;
+}
+
+.tab {
+ background-color:#00CCFF;
+}
+
+.bar,
+.topNav,
+.bottomNav {
+ background-color: #EEEEFF;
+ border-top: 2px solid #000;
+ padding-top: 0px;
+ padding-bottom: 0px;
+}
+
+.subNav {
+ background-color: #FFF;
+ border-bottom: 2px solid #000;
+ font-size:0.8em;
+}
+
+.topNav a:link,
+.topNav a:active,
+.topNav a:visited,
+.bottomNav a:link,
+.bottomNav a:active,
+.bottomNav a:visited {
+ color:#000;
+ text-decoration: underline;
+ font-weight:bold;
+ font-size:1.2em;
+}
+
+.aboutLanguage {
+ position:absolute;
+ right:10px;
+ text-align:right;
+ width:250px;
+ font-size: 0.9em;
+ color:#000;
+ margin:0px;
+ background-color: #FFF;
+ padding:1px;
+}
+
+li {
+ color: #000;
+}
+
+.topNav ul li,
+.bottomNav ul li {
+ margin-top:3px;
+}
+
+.navBarCell1Rev {
+ color:#FFF;
+ background-color:#00008B;
+ font-weight:bold;
+ border:none;
+ margin-top:3px;
+ margin-bottom:3px;
+}
+
+.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
+ background-color: #EEEEFF;
+}
+
+.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
+ background-color: #EEEEFF;
+}
+
+th.colFirst,
+th.colLast,
+th.colOne,
+.constantValuesContainer th {
+ background-color:#CCCCFF;
+ border-top: 1px solid #000;
+ border-bottom: 1px solid #000;
+}
+
+.altColor {
+ background-color: #FFF;
+}
+
+.contentContainer table tbody tr td,
+.classUseContainer table tbody tr td,
+.constantValuesContainer table tbody tr td {
+ border-bottom: 1px solid #000;
+}
+
+td.colFirst,
+th.colFirst {
+ border-right: 1px solid #000;
+}
+
+
+
diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png
similarity index 100%
rename from x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png
rename to x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/background.png
diff --git a/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
new file mode 100644
index 0000000..f2dc19e
--- /dev/null
+++ b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
@@ -0,0 +1,22 @@
+
+.tab {
+ background-image:url(titlebar.png);
+ background-position:left top;
+ background-repeat:no-repeat;
+}
+.bar,.topNav,.bottomNav {
+ background-image:url(background.png);
+ background-repeat:repeat-x;
+}
+.navBarCell1Rev {
+ background-image:url(tab.png);
+}
+.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span {
+ background-image:url(titlebar.png);
+}
+.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
+ background-image:url(titlebar_end.png);
+ background-repeat:no-repeat;
+ background-position:top right;
+}
+
diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png
similarity index 100%
rename from x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png
rename to x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/tab.png
diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png
similarity index 100%
rename from x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png
rename to x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar.png
diff --git a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png b/x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png
similarity index 100%
rename from x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png
rename to x4o-eld-doc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/titlebar_end.png
diff --git a/x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java b/x4o-eld-doc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java
similarity index 83%
rename from x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java
rename to x4o-eld-doc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java
index db53c22..607a3f7 100644
--- a/x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java
+++ b/x4o-eld-doc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java
@@ -40,8 +40,9 @@ import junit.framework.TestCase;
*/
public class X4OWriteLanguageDocExecutorTest extends TestCase {
- private File getTempPath(String dir) throws Exception {
- File tempFile = File.createTempFile("test-path", ".tmp");
+ private File createOutputTargetPath(String dir) throws Exception {
+ File tempFile = new File("target/path");
+ //File tempFile = File.createTempFile("junit", "test");
String absolutePath = tempFile.getAbsolutePath();
String tempPath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)+1);
tempFile.delete();
@@ -54,28 +55,28 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
public void testCelDoc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
- writer.setBasePath(getTempPath("junit-cel"));
+ writer.setBasePath(createOutputTargetPath("junit-cel"));
writer.setLanguageName(CelDriver.LANGUAGE_NAME);
writer.execute();
}
public void testEldDoc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
- writer.setBasePath(getTempPath("junit-eld"));
+ writer.setBasePath(createOutputTargetPath("junit-eld"));
writer.setLanguageName(EldDriver.LANGUAGE_NAME);
writer.execute();
}
public void testUnitDoc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
- writer.setBasePath(getTempPath("junit-test"));
+ writer.setBasePath(createOutputTargetPath("junit-test"));
writer.setLanguageName(TestDriver.LANGUAGE_NAME);
writer.execute();
}
public void testSwiXml2Doc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
- writer.setBasePath(getTempPath("junit-swixml2"));
+ writer.setBasePath(createOutputTargetPath("junit-swixml2"));
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
writer.execute();
@@ -83,7 +84,7 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
public void testSwiXml3Doc() throws Exception {
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
- writer.setBasePath(getTempPath("junit-swixml3"));
+ writer.setBasePath(createOutputTargetPath("junit-swixml3"));
writer.setLanguageName(SwiXmlDriver.LANGUAGE_NAME);
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
writer.execute();
@@ -91,6 +92,6 @@ public class X4OWriteLanguageDocExecutorTest extends TestCase {
public void testEldDocMain() throws Exception {
- X4OWriteLanguageDocExecutor.main(new String[] {"-p",getTempPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME});
+ X4OWriteLanguageDocExecutor.main(new String[] {"-p",createOutputTargetPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME});
}
}
diff --git a/x4o-elddoc/src/test/resources/.empty b/x4o-eld-doc/src/test/resources/.empty
similarity index 100%
rename from x4o-elddoc/src/test/resources/.empty
rename to x4o-eld-doc/src/test/resources/.empty
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
deleted file mode 100644
index adb3ed9..0000000
--- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocGenerator.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2004-2013, Willem Cazander
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.x4o.xml.eld.doc;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.x4o.xml.element.ElementAttributeHandler;
-import org.x4o.xml.element.ElementBindingHandler;
-import org.x4o.xml.element.ElementClass;
-import org.x4o.xml.element.ElementConfigurator;
-import org.x4o.xml.element.ElementInterface;
-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.
- *
- * @author Willem Cazander
- * @version 1.0 Aug 26, 2010
- */
-public class EldDocGenerator {
-
- private X4OLanguageContext context = null;
-
- /**
- * Creates an EldDocGenerator for this langauge context.
- * @param context The language context to generate doc for.
- */
- public EldDocGenerator(X4OLanguageContext context) {
- this.context=context;
- }
-
- /**
- * Writes the language documentation to the base path.
- * @param basePath The path to write to documentation to.
- * @throws ElementException Is thrown when error is done.
- */
- public void writeDoc(File basePath) throws ElementException {
- EldDocHtmlWriter writer = new EldDocHtmlWriter();
- try {
-
- writer.writeTheme(basePath);
- writer.writeIndex(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, context);
-
-
- for (ElementBindingHandler bind:mod.getElementBindingHandlers()) {
- writer.writeBindingHandler(basePath,bind,mod,context);
- }
- for (ElementAttributeHandler attr:mod.getElementAttributeHandlers()) {
- writer.writeAttributeHandler(basePath,attr,mod,context);
- }
- for (ElementConfigurator conf:mod.getElementConfiguratorGlobals()) {
- writer.writeElementConfigurator(basePath,conf,mod,context);
- }
- for (ElementInterface iface:mod.getElementInterfaces()) {
- writer.writeElementInterface(basePath,iface,mod,context);
-
- for (ElementBindingHandler bind:iface.getElementBindingHandlers()) {
- 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,context);
- }
- }
-
- for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
-
- 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,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
deleted file mode 100644
index ee531ef..0000000
--- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java
+++ /dev/null
@@ -1,1401 +0,0 @@
-/*
- * Copyright (c) 2004-2013, Willem Cazander
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package org.x4o.xml.eld.doc;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-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.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;
-import org.x4o.xml.element.ElementClassAttribute;
-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.
- *
- *
- *
- * @author Willem Cazander
- * @version 1.0 Aug 26, 2010
- */
-public class EldDocHtmlWriter {
-
- private String toSafeUri(String uri) {
- StringBuilder buf = new StringBuilder(20);
- for (char c:uri.toLowerCase().toCharArray()) {
- if (Character.isLetter(c)) {
- buf.append(c);
- }
- if (Character.isDigit(c)) {
- buf.append(c);
- }
- if ('.'==c) {
- buf.append(c);
- }
- if ('-'==c) {
- buf.append(c);
- }
- if ('_'==c) {
- buf.append(c);
- }
- }
- String prefix = buf.toString();
- if (prefix.startsWith("http")) {
- prefix = prefix.substring(4);
- }
- if (prefix.startsWith("uri")) {
- prefix = prefix.substring(3);
- }
- if (prefix.startsWith("url")) {
- prefix = prefix.substring(3);
- }
- return prefix;
- }
-
- 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);
- for (int i=0;iWelcome to the EldDocs
");
-
-
- 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 {
- writer.closeWriterSafe();
- }
- }
-
- 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 = "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 {
- writer.closeWriterSafe();
- }
- }
-
- 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";
- writeStart(conf,writer,context,title);
- writer.docPagePackageTitle(title, "Overview Tree");
- writer.docPageContentStart();
-
- List rootNodes = new ArrayList(3);
- for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {
- for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
- if (ns.getLanguageRoot()!=null && ns.getLanguageRoot()) {
- // found language root elements.
- for (ElementClass ec:ns.getElementClasses()) {
- TreeNode node = new TreeNode();
- node.context=context;
- node.module=mod;
- node.namespace=ns;
- node.elementClass=ec;
- rootNodes.add(node);
- }
- }
- }
- }
- Collections.sort(rootNodes,new TreeNodeComparator());
- for (TreeNode rootNode:rootNodes) {
- walkTree(rootNode,writer,pathPrefix);
- }
-
- writer.docPagePackageDescription(title, "Tree","All Language elements as tree.");
- writer.docPageContentEnd();
- writeEnd(conf,writer,context);
- } finally {
- writer.closeWriterSafe();
- }
- }
-
- class TreeNode {
- X4OLanguageContext context;
- X4OLanguageModule module;
- ElementNamespaceContext namespace;
- ElementClass elementClass;
- TreeNode parent;
- int indent = 0;
- }
-
- private void walkTree(TreeNode node,ContentWriterDoc writer,String pathPrefix) throws SAXException {
- String href = toElementUri(pathPrefix,node.module,node.namespace,node.elementClass);
-
- 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,writer,pathPrefix);
- }
- writer.printTagEnd(Tag.ul);
- }
-
- private List findChilderen(TreeNode node) {
- List result = new ArrayList(10);
-
- if (node.indent>20) {
- return result; // hard fail limit
- }
- for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
- for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
- for (ElementClass ec:ns.getElementClasses()) {
- TreeNode n=null;
- List tags = ec.getElementParents(node.namespace.getUri());
- if (tags!=null && tags.contains(node.elementClass.getId())) {
- n = new TreeNode();
- n.context=node.context;
- n.module=mod;
- n.namespace=ns;
- n.elementClass=ec;
- n.indent=node.indent+1;
- n.parent=node;
- } else {
- if (ec.getObjectClass()==null) {
- continue;
- }
- // Check interfaces of parent , and see if child tag is there.
- for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(ec.getObjectClass())) {
- List eiTags = ei.getElementParents(node.namespace.getUri());
- if (eiTags!=null && eiTags.contains(node.elementClass.getId())) {
- n = new TreeNode();
- n.context=node.context;
- n.module=mod;
- n.namespace=ns;
- n.elementClass=ec;
- n.indent=node.indent+1;
- n.parent=node;
- break;
- }
- }
-
- if (node.elementClass.getObjectClass()==null) {
- continue;
- }
- List binds = node.context.getLanguage().findElementBindingHandlers(node.elementClass.getObjectClass(), ec.getObjectClass());
- if (binds.isEmpty()==false) {
- n = new TreeNode();
- n.context=node.context;
- n.module=mod;
- n.namespace=ns;
- n.elementClass=ec;
- n.indent=node.indent+1;
- n.parent=node;
- }
- }
- if (n!=null && isInTree(node,n)==false) {
- result.add(n);
- }
- }
- }
- }
- Collections.sort(result,new TreeNodeComparator());
- return result;
- }
-
- private boolean isInTree(TreeNode node,TreeNode checkNode) {
-
- if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) &&
- node.elementClass.getId().equals(checkNode.elementClass.getId())
- ) {
- return true;
- }
- if (node.parent!=null) {
- return isInTree(node.parent,checkNode);
- }
- return false;
- }
-
- private List findParents(TreeNode node) {
- List result = new ArrayList(10);
- TreeNode n=null;
- for (X4OLanguageModule mod:node.context.getLanguage().getLanguageModules()) {
- for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
-
- List tags = node.elementClass.getElementParents(ns.getUri());
- if (tags!=null) {
- for (ElementClass ec:ns.getElementClasses()) {
- if (tags.contains(ec.getId())) {
- n = new TreeNode();
- n.context=node.context;
- n.module=mod;
- n.namespace=ns;
- n.elementClass=ec;
- n.indent=node.indent+1;
- n.parent=node;
- result.add(n);
- }
- }
- }
- for (ElementClass ec:ns.getElementClasses()) {
-
- // Check interfaces of parent , and see if child tag is there.
- if (node.elementClass.getObjectClass()!=null) {
- for (ElementInterface ei:node.context.getLanguage().findElementInterfaces(node.elementClass.getObjectClass())) {
- List eiTags = ei.getElementParents(ns.getUri());
- if (eiTags!=null && eiTags.contains(ec.getId())) {
- n = new TreeNode();
- n.context=node.context;
- n.module=mod;
- n.namespace=ns;
- n.elementClass=ec;
- n.indent=node.indent+1;
- n.parent=node;
- result.add(n);
- break;
- }
- }
- }
- if (ec.getObjectClass()==null) {
- continue;
- }
- if (node.elementClass.getObjectClass()==null) {
- continue;
- }
- List binds = node.context.getLanguage().findElementBindingHandlers(ec.getObjectClass(),node.elementClass.getObjectClass());
- if (binds.isEmpty()==false) {
- n = new TreeNode();
- n.context=node.context;
- n.module=mod;
- n.namespace=ns;
- n.elementClass=ec;
- n.indent=node.indent+1;
- n.parent=node;
- if (isInTree(node,n)==false) {
- result.add(n);
- }
- }
- }
- }
- }
- Collections.sort(result,new TreeNodeComparator());
- return result;
- }
-
-
- 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 {
- 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(writer,mod.getElementInterfaces(),pathPrefixModule);
- writer.docPageBlockNext();
-
- 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 {
- writer.closeWriterSafe();
- }
- }
-
- 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 = "Overview ("+ns.getUri()+")";
- writeStart(conf,writer,context,title);
- writer.docPagePackageTitle(title, ns.getDescription());
- writer.docPageContentStart();
-
- 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) {
- writer.docTableRowHref(toSafeUri(ec.getId())+"/index.html",ec.getId(),ec.getDescription(),null);
- }
- writer.docTableEnd();
-
- writer.docPagePackageDescription(title, "Module","All language options this modules provides.");
- writer.docPageContentEnd();
- writeEnd(conf,writer,context);
- } finally {
- writer.closeWriterSafe();
- }
- }
-
- private String printList(List list) {
- StringBuffer buf = new StringBuffer(40);
- buf.append("[L: ");
- if (list.isEmpty()) {
- buf.append("Empty.");
- }
- for (String s:list) {
- buf.append(s);
- buf.append(' ');
- }
- buf.append("]");
- 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 clazz:bind.getBindChildClasses()) {
- printTableRowSummary(pw,"class",""+clazz.getName());
- }
- printTableEnd(pw);
- */
- 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();
- }
- }
-
- 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 {
- 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();
- }
- }
-
- 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);
- if (m.getParameterTypes().length==0) {
- continue; // set without parameters
- }
- if (n.length()<2) {
- continue;
- }
- 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.
- writer.docTableRow(n,""+type);
- }
- }
- writer.docTableEnd();
- }
-
- 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);
- if (m.getParameterTypes().length!=0) {
- continue; // set without parameters
- }
- if (n.length()<2) {
- continue;
- }
- n = n.substring(0,1).toLowerCase()+n.substring(1,n.length());
- Object value = null;
- try {
- value = m.invoke(bean, new Object[] {});
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
-
- writer.docTableRow(n,printValue(value));
- }
- }
- writer.docTableEnd();
- }
-
- private String printValue(Object value) {
- if (value==null) {
- return "null";
- }
- if (value instanceof String) {
- return (String)value;
- }
- if (value instanceof Class) {
- return "class "+((Class>)value).getName();
- }
- if (value instanceof List) {
- StringBuffer buf = new StringBuffer(100);
- buf.append("[L: ");
- List> l = (List>)value;
- if (l.isEmpty()) {
- buf.append("Empty");
- }
- for (Object o:l) {
- buf.append(""+o);
- buf.append(" ");
- }
- buf.append("]");
- return buf.toString();
- }
- if (value instanceof Object[]) {
- StringBuffer buf = new StringBuffer(100);
- buf.append("[A: ");
- Object[] l = (Object[])value;
- if (l.length==0) {
- buf.append("Empty");
- }
- for (Object o:l) {
- buf.append(""+o);
- buf.append(" ");
- }
- buf.append("]");
- return buf.toString();
- }
-
- return value.toString();
- }
-
- 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) {
- writer.docTableRow(attr.getId(),attr.getDescription());
- }
- writer.docTableEnd();
- }
-
- 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) {
- writer.docTableRowHref(pathPrefix+toSafeUri(mod.getId())+"/"+toSafeUri(ns.getId())+"/index.html",ns.getId(),ns.getUri(),null);
- }
- writer.docTableEnd();
- }
-
- 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) {
- writer.docTableRowHref(pathPrefix+"conf/"+toSafeUri(conf.getId())+".html",conf.getId(),conf.getDescription(),null);
- }
- writer.docTableEnd();
- }
-
- 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) {
- writer.docTableRowHref(pathPrefix+"conf/"+toSafeUri(conf.getId())+".html",conf.getId(),conf.getDescription(),null);
- }
- writer.docTableEnd();
- }
-
- 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) {
- writer.docTableRowHref(pathPrefix+"bind/"+toSafeUri(bind.getId())+".html",bind.getId(),null,null);
- }
- writer.docTableEnd();
- }
-
- 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) {
- writer.docTableRowHref(pathPrefix+"attr/"+toSafeUri(attr.getId())+".html",attr.getId(),attr.getDescription(),null);
- }
- writer.docTableEnd();
- }
-
- 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) {
- writer.docTableRowHref(pathPrefix+"interface/"+toSafeUri(iface.getId())+".html",""+iface.getId(),iface.getDescription(),null);
- }
- writer.docTableEnd();
- }
-
- class ElementLanguageModuleComparator implements Comparator {
- public int compare(X4OLanguageModule o1,X4OLanguageModule o2) {
- return o1.getId().compareTo(o2.getId());
- }
- }
-
- class TreeNodeComparator implements Comparator {
- public int compare(TreeNode o1,TreeNode o2) {
- return o1.elementClass.getId().compareTo(o2.elementClass.getId());
- }
- }
-
- class ElementClassComparator implements Comparator {
- public int compare(ElementClass o1,ElementClass o2) {
- return o1.getId().compareTo(o2.getId());
- }
- }
-}
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
deleted file mode 100644
index 002e17f..0000000
--- a/x4o-elddoc/src/main/resources/org/x4o/xml/eld/doc/theme/jdk7/stylesheet.css
+++ /dev/null
@@ -1,447 +0,0 @@
-/* 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-plugin/x4o-plugin-ant/pom.xml b/x4o-plugin/x4o-plugin-ant/pom.xml
index c74316e..ce90d9b 100644
--- a/x4o-plugin/x4o-plugin-ant/pom.xml
+++ b/x4o-plugin/x4o-plugin-ant/pom.xml
@@ -16,7 +16,7 @@
org.x4o
- x4o-elddoc
+ x4o-eld-doc
${project.version}
@@ -192,7 +192,7 @@
org.x4o
- x4o-elddoc
+ x4o-eld-doc
${project.version}
diff --git a/x4o-plugin/x4o-plugin-maven/pom.xml b/x4o-plugin/x4o-plugin-maven/pom.xml
index 22b0700..816263f 100644
--- a/x4o-plugin/x4o-plugin-maven/pom.xml
+++ b/x4o-plugin/x4o-plugin-maven/pom.xml
@@ -17,7 +17,7 @@
org.x4o
- x4o-elddoc
+ x4o-eld-doc
${project.version}
@@ -109,7 +109,7 @@
org.x4o
- x4o-elddoc
+ x4o-eld-doc
${project.version}