Made eld docs more compleet and updated xsd to add missing description

tag.
This commit is contained in:
Willem Cazander 2012-12-20 22:39:28 +01:00
parent 91064df3f3
commit aa9c9743d7
22 changed files with 609 additions and 124 deletions

View file

@ -53,7 +53,6 @@
##CODE ##CODE
- Add (super) tag for extending tags of other namespace - Add (super) tag for extending tags of other namespace
- Add EldInfo element
- XMLOverrideEvent - XMLOverrideEvent
- inboud sax parser !! - inboud sax parser !!
- input stream output converter :) - input stream output converter :)
@ -71,5 +70,4 @@
- Xinclude option - Xinclude option
- SAX events as input source - SAX events as input source
- (70%) XML debug output - (70%) XML debug output
- (20%) x4o comment element

View file

@ -623,7 +623,7 @@ public class X4OPhaseHandlerFactory {
protected void setX4OPhase() { protected void setX4OPhase() {
phase = X4OPhase.fillTemplatingPhase; phase = X4OPhase.fillTemplatingPhase;
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
} }
}; };
return result; return result;
@ -638,13 +638,13 @@ public class X4OPhaseHandlerFactory {
protected void setX4OPhase() { protected void setX4OPhase() {
phase = X4OPhase.transformPhase; phase = X4OPhase.transformPhase;
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
if (element.isTransformingTree()==false) { if (element.isTransformingTree()==false) {
return; return;
} }
try { try {
if (hasX4ODebugWriter()) { if (hasX4ODebugWriter()) {
getX4ODebugWriter().debugElement(element); getX4ODebugWriter().debugElement(element);
} }
element.doElementRun(); element.doElementRun();
} catch (ElementException e) { } catch (ElementException e) {
@ -665,7 +665,7 @@ public class X4OPhaseHandlerFactory {
protected void setX4OPhase() { protected void setX4OPhase() {
phase = X4OPhase.runDirtyElementPhase; phase = X4OPhase.runDirtyElementPhase;
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
Map<Element,X4OPhase> dirtyElements = element.getElementLanguage().getDirtyElements(); Map<Element,X4OPhase> dirtyElements = element.getElementLanguage().getDirtyElements();
if (dirtyElements.isEmpty()) { if (dirtyElements.isEmpty()) {
return; return;

View file

@ -217,7 +217,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("bindingHandler",null,BeanElement.class); ec = new DefaultElementClass("bindingHandler",null,BeanElement.class);
ec.addElementParent(CEL_ROOT_URI, "module"); ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent("", "elementInterface"); ec.addElementParent(CEL_CORE_URI, "elementInterface");
try { try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute()); attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("id"); attr.setName("id");
@ -247,8 +247,8 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("configurator",null,BeanElement.class); ec = new DefaultElementClass("configurator",null,BeanElement.class);
//ec.addElementParent(CEL_ROOT_URI, "module"); //ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent("", "elementInterface"); ec.addElementParent(CEL_CORE_URI, "elementInterface");
ec.addElementParent("", "element"); ec.addElementParent(CEL_CORE_URI, "element");
try { try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute()); attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("bean.class"); attr.setName("bean.class");
@ -282,17 +282,18 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec = new DefaultElementClass("description",null,DescriptionElement.class); ec = new DefaultElementClass("description",null,DescriptionElement.class);
ec.setSchemaContentBase("string"); ec.setSchemaContentBase("string");
ec.addElementParent(CEL_ROOT_URI, "module"); ec.addElementParent(CEL_ROOT_URI, "module");
ec.addElementParent("", "attributeHandler"); ec.addElementParent(CEL_CORE_URI, "namespace");
ec.addElementParent("", "bindingHandler"); ec.addElementParent(CEL_CORE_URI, "attributeHandler");
ec.addElementParent("", "configurator"); ec.addElementParent(CEL_CORE_URI, "bindingHandler");
ec.addElementParent("", "configuratorGlobal"); ec.addElementParent(CEL_CORE_URI, "configurator");
ec.addElementParent("", "elementInterface"); ec.addElementParent(CEL_CORE_URI, "configuratorGlobal");
ec.addElementParent("", "element"); ec.addElementParent(CEL_CORE_URI, "elementInterface");
ec.addElementParent("", "attribute"); ec.addElementParent(CEL_CORE_URI, "element");
ec.addElementParent(CEL_CORE_URI, "attribute");
elementClassList.add(ec); elementClassList.add(ec);
ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class); ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class);
ec.addElementParent("", "element"); ec.addElementParent(CEL_CORE_URI, "element");
try { try {
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute()); attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
attr.setName("tag"); attr.setName("tag");

View file

@ -46,7 +46,7 @@ public class ElementClassAddParentElement extends AbstractElement {
} }
String namespaceUri = getAttributes().get("uri"); String namespaceUri = getAttributes().get("uri");
if (namespaceUri==null) { if (namespaceUri==null) {
namespaceUri = ""; // current namespace ? namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
} }
if (getParent().getElementObject() instanceof ElementClass) { if (getParent().getElementObject() instanceof ElementClass) {
((ElementClass)getParent().getElementObject()).addElementParent(namespaceUri,tag); ((ElementClass)getParent().getElementObject()).addElementParent(namespaceUri,tag);

View file

@ -369,12 +369,6 @@ public class EldXsdXmlWriter {
if (parents!=null && parents.contains(ec.getTag())) { if (parents!=null && parents.contains(ec.getTag())) {
refElements.add(checkClass.getTag()); refElements.add(checkClass.getTag());
} }
if (nsWrite.getUri().equals(ns.getUri())) {
parents = checkClass.getElementParents("");
if (parents!=null && parents.contains(ec.getTag())) {
refElements.add(checkClass.getTag());
}
}
if (ec.getObjectClass()==null) { if (ec.getObjectClass()==null) {
continue; continue;
} }

View file

@ -111,6 +111,12 @@ public abstract class AbstractElementClass extends AbstractElementClassBase impl
* @see org.x4o.xml.element.ElementClass#addElementParent(java.lang.String,java.lang.String) * @see org.x4o.xml.element.ElementClass#addElementParent(java.lang.String,java.lang.String)
*/ */
public void addElementParent(String namespaceUri,String tag) { public void addElementParent(String namespaceUri,String tag) {
if (namespaceUri==null) {
throw new NullPointerException("Can't add parent tag with null namespace uri.");
}
if (namespaceUri.isEmpty()) {
throw new IllegalArgumentException("Can't add parent tag with empty namespace uri.");
}
List<String> tags = elementParents.get(namespaceUri); List<String> tags = elementParents.get(namespaceUri);
if (tags==null) { if (tags==null) {
tags = new ArrayList<String>(5); tags = new ArrayList<String>(5);

View file

@ -123,9 +123,18 @@ public abstract class AbstractElementLanguageModule extends AbstractElementMetaB
* @see org.x4o.xml.element.ElementLanguageModule#addElementBindingHandler(ElementBindingHandler) * @see org.x4o.xml.element.ElementLanguageModule#addElementBindingHandler(ElementBindingHandler)
*/ */
public void addElementBindingHandler(ElementBindingHandler elementBindingHandler) { public void addElementBindingHandler(ElementBindingHandler elementBindingHandler) {
if (elementBindingHandler==null) {
throw new NullPointerException("Can't add null binding handler.");
}
if (elementBindingHandler.getId()==null) { if (elementBindingHandler.getId()==null) {
throw new NullPointerException("Can't add with null id property."); throw new NullPointerException("Can't add with null id property.");
} }
// Check so doc tree does not loop; see EldDocHtmlWriter.findChilderen()
for (Class<?> cl:elementBindingHandler.getBindChildClasses()) {
if (elementBindingHandler.getBindParentClass().equals(cl)) {
throw new IllegalStateException("Can't add binding handler: "+elementBindingHandler.getId()+" with same parent as child class.");
}
}
logger.finer("Adding ElementBindingHandler: "+elementBindingHandler); logger.finer("Adding ElementBindingHandler: "+elementBindingHandler);
elementBindingHandlers.add(elementBindingHandler); elementBindingHandlers.add(elementBindingHandler);
} }

View file

@ -7,25 +7,26 @@
ModuleName: Core Element Languag Module ModuleName: Core Element Languag Module
Namespaces: 2 Namespaces: 2
Namespace: http://cel.x4o.org/xml/ns/cel-core Namespace: http://cel.x4o.org/xml/ns/cel-core
Created on: Sun Nov 18 06:22:14 CET 2012 Created on: Thu Dec 20 22:30:55 CET 2012
--> -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" <schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:this="http://cel.x4o.org/xml/ns/cel-core" xmlns:this="http://cel.x4o.org/xml/ns/cel-core"
version="1.0" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://cel.x4o.org/xml/ns/cel-core"> version="1.0" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://cel.x4o.org/xml/ns/cel-core">
<complexType name="namespaceType"> <complexType name="namespaceType">
<choice minOccurs="0" maxOccurs="unbounded"> <choice minOccurs="0" maxOccurs="unbounded">
<element name="description" type="this:descriptionType"/>
<element name="element" type="this:elementType"/> <element name="element" type="this:elementType"/>
</choice> </choice>
<attribute name="uri" type="string" use="required"/> <attribute name="uri" type="string" use="required"/>
<attribute name="name" type="string"/> <attribute name="name" type="string"/>
<attribute name="prefixMapping" type="string"/> <attribute name="elementNamespaceInstanceProvider" type="string"/>
<attribute name="schemaUri" type="string"/>
<attribute name="schemaResource" type="string"/> <attribute name="schemaResource" type="string"/>
<attribute name="schemaPrefix" type="string"/> <attribute name="schemaPrefix" type="string"/>
<attribute name="languageRoot" type="boolean"/> <attribute name="languageRoot" type="boolean"/>
<attribute name="elementNamespaceInstanceProvider" type="string"/> <attribute name="prefixMapping" type="string"/>
<attribute name="schemaUri" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType> </complexType>
<complexType name="descriptionType"> <complexType name="descriptionType">
<simpleContent> <simpleContent>
@ -44,12 +45,12 @@
<attribute name="objectClass" type="string"/> <attribute name="objectClass" type="string"/>
<attribute name="elementClass" type="string"/> <attribute name="elementClass" type="string"/>
<attribute name="tag" type="string"/> <attribute name="tag" type="string"/>
<attribute name="schemaContentBase" type="string"/> <attribute name="autoAttributes" type="boolean"/>
<attribute name="schemaContentComplex" type="boolean"/> <attribute name="schemaContentComplex" type="boolean"/>
<attribute name="schemaContentMixed" type="boolean"/> <attribute name="schemaContentMixed" type="boolean"/>
<attribute name="autoAttributes" type="boolean"/> <attribute name="schemaContentBase" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType> </complexType>
<complexType name="configuratorGlobalType"> <complexType name="configuratorGlobalType">
<choice minOccurs="0" maxOccurs="unbounded"> <choice minOccurs="0" maxOccurs="unbounded">
@ -80,14 +81,14 @@
<element name="description" type="this:descriptionType"/> <element name="description" type="this:descriptionType"/>
</choice> </choice>
<attribute name="name" type="string"/> <attribute name="name" type="string"/>
<attribute name="defaultValue" type="string"/> <attribute name="required" type="boolean"/>
<attribute name="runResolveEL" type="boolean"/> <attribute name="runResolveEL" type="boolean"/>
<attribute name="runConverters" type="boolean"/> <attribute name="runConverters" type="boolean"/>
<attribute name="runBeanFill" type="boolean"/> <attribute name="defaultValue" type="string"/>
<attribute name="objectConverter" type="string"/> <attribute name="objectConverter" type="string"/>
<attribute name="required" type="boolean"/> <attribute name="runBeanFill" type="boolean"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType> </complexType>
<complexType name="classConverterType"> <complexType name="classConverterType">
<choice minOccurs="0" maxOccurs="unbounded"/> <choice minOccurs="0" maxOccurs="unbounded"/>
@ -108,8 +109,8 @@
<element name="description" type="this:descriptionType"/> <element name="description" type="this:descriptionType"/>
</choice> </choice>
<attribute name="interfaceClass" type="string"/> <attribute name="interfaceClass" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType> </complexType>
<complexType name="elementParentType"> <complexType name="elementParentType">
<choice minOccurs="0" maxOccurs="unbounded"/> <choice minOccurs="0" maxOccurs="unbounded"/>

View file

@ -7,7 +7,7 @@
ModuleName: Core Element Languag Module ModuleName: Core Element Languag Module
Namespaces: 2 Namespaces: 2
Namespace: http://cel.x4o.org/xml/ns/cel-root Namespace: http://cel.x4o.org/xml/ns/cel-root
Created on: Sun Nov 18 06:22:14 CET 2012 Created on: Thu Dec 20 22:30:55 CET 2012
--> -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" <schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cel-core="http://cel.x4o.org/xml/ns/cel-core" xmlns:cel-core="http://cel.x4o.org/xml/ns/cel-core"
@ -25,10 +25,10 @@
</choice> </choice>
<attribute name="name" type="string"/> <attribute name="name" type="string"/>
<attribute name="providerName" type="string"/> <attribute name="providerName" type="string"/>
<attribute name="sourceResource" type="string"/>
<attribute name="elementLanguageModuleLoader" type="string"/> <attribute name="elementLanguageModuleLoader" type="string"/>
<attribute name="id" type="string"/> <attribute name="sourceResource" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType> </complexType>
</element> </element>
</schema> </schema>

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition ModuleName: Element Language Definition
Namespaces: 3 Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-conv Namespace: http://eld.x4o.org/xml/ns/eld-conv
Created on: Sun Nov 18 06:22:58 CET 2012 Created on: Thu Dec 20 22:30:10 CET 2012
--> -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" <schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:this="http://eld.x4o.org/xml/ns/eld-conv" xmlns:this="http://eld.x4o.org/xml/ns/eld-conv"

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition ModuleName: Element Language Definition
Namespaces: 3 Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-lang Namespace: http://eld.x4o.org/xml/ns/eld-lang
Created on: Sun Nov 18 06:22:58 CET 2012 Created on: Thu Dec 20 22:30:10 CET 2012
--> -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" <schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv" xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
@ -16,16 +16,17 @@
<import namespace="http://eld.x4o.org/xml/ns/eld-conv" schemaLocation="eld-conv-1.0.xsd"/> <import namespace="http://eld.x4o.org/xml/ns/eld-conv" schemaLocation="eld-conv-1.0.xsd"/>
<complexType name="namespaceType"> <complexType name="namespaceType">
<choice minOccurs="0" maxOccurs="unbounded"> <choice minOccurs="0" maxOccurs="unbounded">
<element name="description" type="this:descriptionType"/>
<element name="element" type="this:elementType"/> <element name="element" type="this:elementType"/>
</choice> </choice>
<attribute name="uri" type="string" use="required"/> <attribute name="uri" type="string" use="required"/>
<attribute name="name" type="string"/> <attribute name="name" type="string"/>
<attribute name="elementNamespaceInstanceProvider" type="string"/>
<attribute name="schemaUri" type="string"/> <attribute name="schemaUri" type="string"/>
<attribute name="schemaResource" type="string"/> <attribute name="schemaResource" type="string"/>
<attribute name="schemaPrefix" type="string"/> <attribute name="schemaPrefix" type="string"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="languageRoot" type="boolean"/> <attribute name="languageRoot" type="boolean"/>
<attribute name="elementNamespaceInstanceProvider" type="string"/> <attribute name="prefixMapping" type="string"/>
<attribute name="id" type="string"/> <attribute name="id" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
</complexType> </complexType>

View file

@ -32,6 +32,7 @@
providerName="eld.x4o.org" providerName="eld.x4o.org"
id="eld-module" id="eld-module"
> >
<description>The full element language definition(eld) which is used to define xml languages.</description>
<bindingHandler id="ElementClassBindingHandler" bean.class="org.x4o.xml.eld.lang.ElementClassBindingHandler"/> <bindingHandler id="ElementClassBindingHandler" bean.class="org.x4o.xml.eld.lang.ElementClassBindingHandler"/>
<bindingHandler id="ElementModuleBindingHandler" bean.class="org.x4o.xml.eld.lang.ElementModuleBindingHandler"/> <bindingHandler id="ElementModuleBindingHandler" bean.class="org.x4o.xml.eld.lang.ElementModuleBindingHandler"/>
@ -50,7 +51,7 @@
languageRoot="true" languageRoot="true"
id="eld-root" id="eld-root"
> >
<!-- Root Element for nice namespace'ing --> <description>Single root namespace so xsd schema generation works correct.</description>
<element tag="module" objectClass="${parentLanguageConfiguration.defaultElementLanguageModule}" elementClass="org.x4o.xml.eld.lang.ModuleElement"> <element tag="module" objectClass="${parentLanguageConfiguration.defaultElementLanguageModule}" elementClass="org.x4o.xml.eld.lang.ModuleElement">
<attribute name="id" required="true"> <attribute name="id" required="true">
<description>The module id.</description> <description>The module id.</description>
@ -67,6 +68,7 @@
name="Element Language Definition" name="Element Language Definition"
id="eld-lang" id="eld-lang"
> >
<description>Some basic language definitions and some helper tags.</description>
<!-- First copy some core elements over from parent config --> <!-- First copy some core elements over from parent config -->
<element tag="namespace" objectClass="${parentLanguageConfiguration.defaultElementNamespaceContext}"> <element tag="namespace" objectClass="${parentLanguageConfiguration.defaultElementNamespaceContext}">
@ -160,6 +162,7 @@
<element tag="description" elementClass="org.x4o.xml.eld.lang.DescriptionElement" schemaContentBase="string"> <element tag="description" elementClass="org.x4o.xml.eld.lang.DescriptionElement" schemaContentBase="string">
<description>An ELD elementDescription field which lets you type text like this one in xml characters instead of an attribute.</description> <description>An ELD elementDescription field which lets you type text like this one in xml characters instead of an attribute.</description>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/> <elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
<elementParent tag="namespace"/>
<elementParent tag="bindingHandler"/> <elementParent tag="bindingHandler"/>
<elementParent tag="attributeHandler"/> <elementParent tag="attributeHandler"/>
<elementParent tag="configurator"/> <elementParent tag="configurator"/>
@ -267,7 +270,8 @@
name="Element Attribute Converters" name="Element Attribute Converters"
id="eld-conv" id="eld-conv"
> >
<!-- Config all converters, move ? --> <description>Basic set of attribute value converters.</description>
<element tag="beanConverter" elementClass="org.x4o.xml.eld.lang.BeanElement"> <element tag="beanConverter" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an loadable in bean.class for an ObjectConverter.</description> <description>Define an loadable in bean.class for an ObjectConverter.</description>
<attribute name="bean.class"> <attribute name="bean.class">

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition ModuleName: Element Language Definition
Namespaces: 3 Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-root Namespace: http://eld.x4o.org/xml/ns/eld-root
Created on: Sun Nov 18 06:22:58 CET 2012 Created on: Thu Dec 20 22:30:10 CET 2012
--> -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" <schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv" xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
@ -29,9 +29,9 @@
</choice> </choice>
<attribute name="id" type="string" use="required"/> <attribute name="id" type="string" use="required"/>
<attribute name="name" type="string"/> <attribute name="name" type="string"/>
<attribute name="sourceResource" type="string"/>
<attribute name="elementLanguageModuleLoader" type="string"/>
<attribute name="providerName" type="string"/> <attribute name="providerName" type="string"/>
<attribute name="elementLanguageModuleLoader" type="string"/>
<attribute name="sourceResource" type="string"/>
<attribute name="description" type="string"/> <attribute name="description" type="string"/>
</complexType> </complexType>
</element> </element>

View file

@ -0,0 +1,88 @@
/*
* Copyright (c) 2004-2012, 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.swixml.bind;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementBindingHandlerException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Aug 16, 2012
*/
public class JFrameBindingHandler extends AbstractElementBindingHandler {
/**
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
*/
public Class<?> getBindParentClass() {
return JFrame.class;
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/
public Class<?>[] getBindChildClasses() {
return new Class[] {JMenuBar.class,JComponent.class};
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
*/
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
JFrame frame = (JFrame)parentObject;
if (childObject instanceof JMenuBar) {
JMenuBar child = (JMenuBar)childObject;
frame.getRootPane().setJMenuBar(child);
} else if (childObject instanceof JComponent) {
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) {
frame.getContentPane().add(child);
} else {
frame.getContentPane().add(child,con);
}
}
}
}

View file

@ -25,13 +25,8 @@ package org.x4o.xml.test.swixml.bind;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import org.x4o.xml.element.AbstractElementBindingHandler; import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
@ -43,14 +38,13 @@ import org.x4o.xml.element.ElementBindingHandlerException;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 16, 2012 * @version 1.0 Aug 16, 2012
*/ */
public class JComponentBindingHandler extends AbstractElementBindingHandler { public class JInternalFrameBindingHandler extends AbstractElementBindingHandler {
/** /**
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass() * @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
*/ */
public Class<?> getBindParentClass() { public Class<?> getBindParentClass() {
return JComponent.class; return JInternalFrame.class;
//return new Class[] {JPanel.class,JScrollPane.class,JSplitPane.class,JFrame.class,JInternalFrame.class};
} }
/** /**
@ -78,41 +72,11 @@ public class JComponentBindingHandler extends AbstractElementBindingHandler {
con = BorderLayout.SOUTH; con = BorderLayout.SOUTH;
} }
if (parentObject instanceof JSplitPane) { JInternalFrame frame = (JInternalFrame)parentObject;
JSplitPane pane = (JSplitPane)parentObject; if (con==null) {
if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane frame.getContentPane().add(child);
pane.setLeftComponent(child);
} else if (pane.getRightComponent() instanceof JButton) {
pane.setRightComponent(child);
} else {
throw new ElementBindingHandlerException("SplitPane is full.");
}
} else if (parentObject instanceof JScrollPane) {
JScrollPane pane = (JScrollPane)parentObject;
pane.setViewportView(child);
} else if (parentObject instanceof JFrame) {
JFrame frame = (JFrame)parentObject;
if (con==null) {
frame.getContentPane().add(child);
} else {
frame.getContentPane().add(child,con);
}
} else if (parentObject instanceof JInternalFrame) {
JInternalFrame frame = (JInternalFrame)parentObject;
if (con==null) {
frame.getContentPane().add(child);
} else {
frame.getContentPane().add(child,con);
}
} else if (parentObject instanceof JPanel) {
JPanel parent = (JPanel)parentObject;
if (con==null) {
parent.add(child);
} else {
parent.add(child,con);
}
} else { } else {
// No bind but this destroys the xsd, change into multiple classes. frame.getContentPane().add(child,con);
} }
} }
} }

View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 2004-2012, 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.swixml.bind;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementBindingHandlerException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Aug 16, 2012
*/
public class JPanelBindingHandler extends AbstractElementBindingHandler {
/**
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
*/
public Class<?> getBindParentClass() {
return JPanel.class;
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/
public Class<?>[] getBindChildClasses() {
return new Class[] {JComponent.class};
}
/**
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
*/
public void doBind(Object parentObject, Object childObject, Element childElement) 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;
}
JPanel parent = (JPanel)parentObject;
if (con==null) {
parent.add(child);
} else {
parent.add(child,con);
}
}
}

View file

@ -23,41 +23,48 @@
package org.x4o.xml.test.swixml.bind; package org.x4o.xml.test.swixml.bind;
import javax.swing.JFrame; import javax.swing.JButton;
import javax.swing.JMenuBar; import javax.swing.JComponent;
import javax.swing.JSplitPane;
import org.x4o.xml.element.AbstractElementBindingHandler; import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementBindingHandlerException; import org.x4o.xml.element.ElementBindingHandlerException;
/** /**
* * JSplitPaneBindingHandler binds components to the JSplitPane
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 16, 2012 * @version 1.0 Aug 16, 2012
*/ */
public class JMenuBarBindingHandler extends AbstractElementBindingHandler { public class JSplitPaneBindingHandler extends AbstractElementBindingHandler {
/** /**
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass() * @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
*/ */
public Class<?> getBindParentClass() { public Class<?> getBindParentClass() {
return JFrame.class; return JSplitPane.class;
} }
/** /**
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses() * @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
*/ */
public Class<?>[] getBindChildClasses() { public Class<?>[] getBindChildClasses() {
return new Class[] {JMenuBar.class}; return new Class[] {JComponent.class};
} }
/** /**
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element) * @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
*/ */
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException { public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
JMenuBar child = (JMenuBar)childObject; JComponent child = (JComponent)childObject;
JFrame frame = (JFrame)parentObject; JSplitPane pane = (JSplitPane)parentObject;
frame.getRootPane().setJMenuBar(child); if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane
pane.setLeftComponent(child);
} else if (pane.getRightComponent() instanceof JButton) {
pane.setRightComponent(child);
} else {
throw new ElementBindingHandlerException("SplitPane is full.");
}
} }
} }

View file

@ -34,8 +34,11 @@
id="swixml2-module" id="swixml2-module"
> >
<bindingHandler id="JComponentBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JComponentBindingHandler"/> <bindingHandler id="JFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JFrameBindingHandler"/>
<bindingHandler id="JMenuBarBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JMenuBarBindingHandler"/> <bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" method="setViewportView"/>
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/> <classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/> <classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/> <classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
@ -87,9 +90,10 @@
uri="http://swixml.x4o.org/xml/ns/swixml-root" uri="http://swixml.x4o.org/xml/ns/swixml-root"
schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-2.0.xsd" schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-2.0.xsd"
schemaResource="swixml-root-2.0.xsd" schemaResource="swixml-root-2.0.xsd"
schemaPrefix="root" schemaPrefix="sx-root"
name="Root element" name="Root element"
languageRoot="true" languageRoot="true"
id="sx-root"
> >
<!-- Single element in language root to create nice tree, for imports in xsd namespace aware generated files. --> <!-- Single element in language root to create nice tree, for imports in xsd namespace aware generated files. -->
<element tag="frame" objectClass="javax.swing.JFrame"/> <element tag="frame" objectClass="javax.swing.JFrame"/>
@ -99,6 +103,7 @@
schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-2.0.xsd" schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-2.0.xsd"
schemaResource="swixml-lang-2.0.xsd" schemaResource="swixml-lang-2.0.xsd"
schemaPrefix="sx-lang" schemaPrefix="sx-lang"
id="sx-lang"
> >
<!-- Note frame should not be here(it can but xsd needs root), but else classic xml does not parse without xmlns additions. --> <!-- Note frame should not be here(it can but xsd needs root), but else classic xml does not parse without xmlns additions. -->
<element tag="frame" objectClass="javax.swing.JFrame"/> <element tag="frame" objectClass="javax.swing.JFrame"/>

View file

@ -34,8 +34,11 @@
id="swixml3-module" id="swixml3-module"
> >
<bindingHandler id="JComponentBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JComponentBindingHandler"/> <bindingHandler id="JFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JFrameBindingHandler"/>
<bindingHandler id="JMenuBarBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JMenuBarBindingHandler"/> <bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" method="setViewportView"/>
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/> <classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/> <classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/> <classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
@ -84,9 +87,10 @@
uri="http://swixml.x4o.org/xml/ns/swixml-root" uri="http://swixml.x4o.org/xml/ns/swixml-root"
schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-3.0.xsd" schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-3.0.xsd"
schemaResource="swixml-root-3.0.xsd" schemaResource="swixml-root-3.0.xsd"
schemaPrefix="root" schemaPrefix="sx-root"
name="Root element" name="Root element"
languageRoot="true" languageRoot="true"
id="sx-root"
> >
<element tag="JFrame" objectClass="javax.swing.JFrame"/> <element tag="JFrame" objectClass="javax.swing.JFrame"/>
</namespace> </namespace>
@ -95,6 +99,7 @@
schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-3.0.xsd" schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-3.0.xsd"
schemaResource="swixml-lang-3.0.xsd" schemaResource="swixml-lang-3.0.xsd"
schemaPrefix="sx-lang" schemaPrefix="sx-lang"
id="sx-lang"
> >
<element tag="JMenubar" objectClass="javax.swing.JMenuBar"/> <element tag="JMenubar" objectClass="javax.swing.JMenuBar"/>
<element tag="JMenu" objectClass="javax.swing.JMenu"/> <element tag="JMenu" objectClass="javax.swing.JMenu"/>

View file

@ -56,6 +56,7 @@ public class EldDocGenerator {
writer.writeStylesheet(basePath); writer.writeStylesheet(basePath);
writer.writeOverviewModule(basePath, context); writer.writeOverviewModule(basePath, context);
writer.writeOverviewNamespace(basePath, context); writer.writeOverviewNamespace(basePath, context);
writer.writeOverviewTree(basePath, context);
for (ElementLanguageModule mod:context.getElementLanguageModules()) { for (ElementLanguageModule mod:context.getElementLanguageModules()) {
@ -88,7 +89,7 @@ public class EldDocGenerator {
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
writer.writeOverviewElement(basePath, ns,mod); writer.writeOverviewElement(basePath, ns,mod);
for (ElementClass ec:ns.getElementClasses()) { for (ElementClass ec:ns.getElementClasses()) {
writer.writeElement(basePath, ec, ns, mod); writer.writeElement(basePath, ec, ns, mod,context);
for (ElementConfigurator conf:ec.getElementConfigurators()) { for (ElementConfigurator conf:ec.getElementConfigurators()) {
writer.writeElementConfigurator(basePath,conf,mod,ns,ec); writer.writeElementConfigurator(basePath,conf,mod,ns,ec);
} }

View file

@ -29,6 +29,8 @@ import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -100,6 +102,9 @@ public class EldDocHtmlWriter {
buf.append(File.separatorChar); buf.append(File.separatorChar);
buf.append(toSafeUri(argu[argu.length-1])); buf.append(toSafeUri(argu[argu.length-1]));
File outputFile = new File(buf.toString()); File outputFile = new File(buf.toString());
if (outputFile.exists()) {
outputFile.delete();
}
//System.out.println("Creating file: "+outputFile); //System.out.println("Creating file: "+outputFile);
PrintWriter pw = new PrintWriter(outputFile); PrintWriter pw = new PrintWriter(outputFile);
return pw; return pw;
@ -143,13 +148,13 @@ public class EldDocHtmlWriter {
int elements = 0; int elements = 0;
int namespaces = 0; int namespaces = 0;
for (ElementLanguageModule mod:context.getElementLanguageModules()) { for (ElementLanguageModule mod:context.getElementLanguageModules()) {
attrHandlers =+ mod.getElementAttributeHandlers().size(); attrHandlers += mod.getElementAttributeHandlers().size();
bindHandlers =+ mod.getElementBindingHandlers().size(); bindHandlers += mod.getElementBindingHandlers().size();
interFaces =+ mod.getElementInterfaces().size(); interFaces += mod.getElementInterfaces().size();
eleConfigs =+ mod.getElementConfiguratorGlobals().size(); eleConfigs += mod.getElementConfiguratorGlobals().size();
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) { for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
namespaces++; namespaces++;
elements =+ ns.getElementClasses().size(); elements += ns.getElementClasses().size();
} }
} }
@ -178,7 +183,7 @@ public class EldDocHtmlWriter {
PrintWriter pw = createPrintWriter(basePath,"module-overview.html"); PrintWriter pw = createPrintWriter(basePath,"module-overview.html");
try { try {
String title = context.getLanguageConfiguration().getLanguage()+" "+context.getLanguageConfiguration().getLanguageVersion()+" ELD"; String title = context.getLanguageConfiguration().getLanguage()+" "+context.getLanguageConfiguration().getLanguageVersion()+" ELD";
printHeader(pw,"Overview ("+title+")",""); printHeader(pw,"Overview Modules ("+title+")","");
printPageIndexTitle(pw,title,null,null); printPageIndexTitle(pw,title,null,null);
printTableStart(pw,"Modules"); printTableStart(pw,"Modules");
for (ElementLanguageModule mod:context.getElementLanguageModules()) { for (ElementLanguageModule mod:context.getElementLanguageModules()) {
@ -198,7 +203,7 @@ public class EldDocHtmlWriter {
String pathPrefix = ""; String pathPrefix = "";
try { try {
String title = context.getLanguageConfiguration().getLanguage()+" "+context.getLanguageConfiguration().getLanguageVersion()+" ELD"; String title = context.getLanguageConfiguration().getLanguage()+" "+context.getLanguageConfiguration().getLanguageVersion()+" ELD";
printHeader(pw,"Overview ("+title+")",pathPrefix); printHeader(pw,"Overview Namespace("+title+")",pathPrefix);
printPageIndexTitle(pw,title,null,null); printPageIndexTitle(pw,title,null,null);
for (ElementLanguageModule mod:context.getElementLanguageModules()) { for (ElementLanguageModule mod:context.getElementLanguageModules()) {
printNamespaces(pw,mod.getElementNamespaceContexts(),pathPrefix,mod); printNamespaces(pw,mod.getElementNamespaceContexts(),pathPrefix,mod);
@ -211,6 +216,179 @@ public class EldDocHtmlWriter {
} }
} }
public void writeOverviewTree(File basePath,ElementLanguage context) throws IOException {
PrintWriter pw = createPrintWriter(basePath,"tree-overview.html");
String pathPrefix = "";
try {
String title = context.getLanguageConfiguration().getLanguage()+" "+context.getLanguageConfiguration().getLanguageVersion()+" ELD";
printHeader(pw,"Overview Tree ("+title+")",pathPrefix);
printPageIndexTitle(pw,title,null,null);
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
for (ElementLanguageModule mod:context.getElementLanguageModules()) {
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);
}
}
}
}
for (TreeNode rootNode:rootNodes) {
walkTree(rootNode,pw,pathPrefix);
}
printBottom(pw,pathPrefix);
} finally {
if (pw!=null) {
pw.close();
}
}
}
class TreeNode {
ElementLanguage context;
ElementLanguageModule module;
ElementNamespaceContext namespace;
ElementClass elementClass;
TreeNode parent;
int indent = 0;
}
private void walkTree(TreeNode node,PrintWriter pw,String pathPrefix) {
for (int i=0;i<node.indent;i++) {
pw.print(TAB);
}
pw.print("-&nbsp;<a href=\"");
pw.print(pathPrefix);
pw.print(toSafeUri(node.module.getId()));
pw.print("/");
pw.print(toSafeUri(node.namespace.getId()));
pw.print("/");
pw.print(toSafeUri(node.elementClass.getTag()));
pw.print("/index.html\">");
pw.print(node.namespace.getId());
pw.print(":");
pw.print(node.elementClass.getTag());
pw.print("</a><br/>\n");
List<TreeNode> childs = findChilderen(node);
for (TreeNode child:childs) {
walkTree(child,pw,pathPrefix);
}
}
private List<TreeNode> findChilderen(TreeNode node) {
List<TreeNode> result = new ArrayList<TreeNode>(10);
if (node.indent>20) {
return result; // hard fail limit
}
for (ElementLanguageModule mod:node.context.getElementLanguageModules()) {
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
for (ElementClass ec:ns.getElementClasses()) {
TreeNode n=null;
List<String> tags = ec.getElementParents(node.namespace.getUri());
if (tags!=null && tags.contains(node.elementClass.getTag())) {
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 (node.elementClass.getObjectClass()==null | ec.getObjectClass()==null) {
continue;
}
List<ElementBindingHandler> binds = node.context.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);
}
}
}
}
return result;
}
private boolean isInTree(TreeNode node,TreeNode checkNode) {
if (node.namespace.getUri().equals(checkNode.namespace.getUri())) {
if (node.elementClass.getTag().equals(checkNode.elementClass.getTag())) {
return true;
}
}
if (node.parent!=null) {
return isInTree(node.parent,checkNode);
}
return false;
}
private List<TreeNode> findParents(TreeNode node) {
List<TreeNode> result = new ArrayList<TreeNode>(10);
TreeNode n=null;
for (ElementLanguageModule mod:node.context.getElementLanguageModules()) {
for (ElementNamespaceContext ns:mod.getElementNamespaceContexts()) {
List<String> tags = node.elementClass.getElementParents(ns.getUri());
if (tags!=null) {
for (ElementClass ec:ns.getElementClasses()) {
if (tags.contains(ec.getTag())) {
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()) {
if (node.elementClass.getObjectClass()==null | ec.getObjectClass()==null) {
continue;
}
List<ElementBindingHandler> binds = node.context.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);
}
}
}
}
}
return result;
}
public void writeOverviewModule(File basePath,ElementLanguageModule mod) throws IOException { public void writeOverviewModule(File basePath,ElementLanguageModule mod) throws IOException {
PrintWriter pw = createPrintWriter(basePath,mod.getId(),"index.html"); PrintWriter pw = createPrintWriter(basePath,mod.getId(),"index.html");
String pathPrefix = "../"; String pathPrefix = "../";
@ -255,28 +433,98 @@ public class EldDocHtmlWriter {
} }
} }
public void writeElement(File basePath,ElementClass ec,ElementNamespaceContext ns,ElementLanguageModule mod) throws IOException { private String printList(List<String> 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 writeElement(File basePath,ElementClass ec,ElementNamespaceContext ns,ElementLanguageModule mod,ElementLanguage context) throws IOException {
PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getTag(),"index.html"); PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getTag(),"index.html");
String pathPrefix = "../../../"; String pathPrefix = "../../../";
try { try {
printHeader(pw,"Tag ("+ec.getTag()+")",pathPrefix); printHeader(pw,"Tag ("+ec.getTag()+")",pathPrefix);
printPageTitle(pw,"Tag",ec.getTag(),ec.getDescription()); printPageTitle(pw,"Tag",ec.getTag(),ec.getDescription());
TreeNode node = new TreeNode();
node.context=context;
node.module=mod;
node.namespace=ns;
node.elementClass=ec;
List<TreeNode> parents = findParents(node);
printTableStart(pw,"Element Parents");
pw.print("\t<tr class=\"TableRowColor\">\n");
pw.print("\t\t<td colspan=\"2\">");
if (parents.isEmpty()) {
pw.print("No parent.");
}
for (TreeNode n:parents) {
pw.print("\t\t\t&nbsp;<a href=\"");
pw.print(pathPrefix);
pw.print(toSafeUri(n.module.getId()));
pw.print("/");
pw.print(toSafeUri(n.namespace.getId()));
pw.print("/");
pw.print(toSafeUri(n.elementClass.getTag()));
pw.print("/index.html\">");
pw.print(n.namespace.getId());
pw.print(":");
pw.print(n.elementClass.getTag());
pw.print("</a>\n");
}
pw.print("</td>\n");
pw.print("\t</tr>\n");
printTableEnd(pw);
List<TreeNode> childs = findChilderen(node);
printTableStart(pw,"Element Childeren");
pw.print("\t<tr class=\"TableRowColor\">\n");
pw.print("\t\t<td colspan=\"2\">");
if (childs.isEmpty()) {
pw.print("No childeren.");
}
for (TreeNode n:childs) {
pw.print("\t\t\t&nbsp;<a href=\"");
pw.print(pathPrefix);
pw.print(toSafeUri(n.module.getId()));
pw.print("/");
pw.print(toSafeUri(n.namespace.getId()));
pw.print("/");
pw.print(toSafeUri(n.elementClass.getTag()));
pw.print("/index.html\">");
pw.print(n.namespace.getId());
pw.print(":");
pw.print(n.elementClass.getTag());
pw.print("</a>\n");
}
pw.print("</td>\n");
pw.print("\t</tr>\n");
printTableEnd(pw);
printTableStart(pw,"Element Properties"); printTableStart(pw,"Element Properties");
printTableRowSummary(pw,"id",""+ec.getId());
printTableRowSummary(pw,"tag",""+ec.getTag());
printTableRowSummary(pw,"objectClass",""+ec.getObjectClass()); printTableRowSummary(pw,"objectClass",""+ec.getObjectClass());
printTableRowSummary(pw,"elementClass",""+ec.getElementClass()); printTableRowSummary(pw,"elementClass",""+ec.getElementClass());
printTableRowSummary(pw,"autoAttributes",""+ec.getAutoAttributes()); printTableRowSummary(pw,"autoAttributes",""+ec.getAutoAttributes());
printTableRowSummary(pw,"skipPhases",printList(ec.getSkipPhases()));
printTableRowSummary(pw,"schemaContentBase",""+ec.getSchemaContentBase()); printTableRowSummary(pw,"schemaContentBase",""+ec.getSchemaContentBase());
printTableRowSummary(pw,"schemaContentComplex",""+ec.getSchemaContentComplex()); printTableRowSummary(pw,"schemaContentComplex",""+ec.getSchemaContentComplex());
printTableRowSummary(pw,"schemaContentMixed",""+ec.getSchemaContentMixed()); printTableRowSummary(pw,"schemaContentMixed",""+ec.getSchemaContentMixed());
//printTableRowSummary(pw,"description",""+ec.getDescription());
printTableEnd(pw); printTableEnd(pw);
printElementAttributes(pw,ec.getElementClassAttributes());
printTableStart(pw,"Element Attributes");
for (ElementClassAttribute attr:ec.getElementClassAttributes()) {
printTableRowSummary(pw,attr.getName(),attr.getDescription());
}
printTableEnd(pw);
if (ec.getObjectClass()!=null) { if (ec.getObjectClass()!=null) {
printClassProperties(pw, ec.getObjectClass()); printClassProperties(pw, ec.getObjectClass());
} }
@ -300,7 +548,8 @@ public class EldDocHtmlWriter {
printConfigurators(pw,iface.getElementConfigurators(),pathLocal); printConfigurators(pw,iface.getElementConfigurators(),pathLocal);
printBindingHandlers(pw,iface.getElementBindingHandlers(),pathLocal); printBindingHandlers(pw,iface.getElementBindingHandlers(),pathLocal);
//iface.getElementClassAttributes()
printElementAttributes(pw,iface.getElementClassAttributes());
printBeanProperties(pw, iface); printBeanProperties(pw, iface);
printBottom(pw,pathPrefix); printBottom(pw,pathPrefix);
@ -366,11 +615,13 @@ public class EldDocHtmlWriter {
printHeader(pw,"BindingHandler ("+bind.getId()+")",pathPrefix); printHeader(pw,"BindingHandler ("+bind.getId()+")",pathPrefix);
printPageTitle(pw,"BindingHandler",bind.getId(),bind.getDescription()); printPageTitle(pw,"BindingHandler",bind.getId(),bind.getDescription());
/*
printTableStart(pw,"Child Classes"); printTableStart(pw,"Child Classes");
for (Class<?> clazz:bind.getBindChildClasses()) { for (Class<?> clazz:bind.getBindChildClasses()) {
printTableRowSummary(pw,"class",""+clazz.getName()); printTableRowSummary(pw,"class",""+clazz.getName());
} }
printTableEnd(pw); printTableEnd(pw);
*/
printBeanProperties(pw, bind); printBeanProperties(pw, bind);
printBottom(pw,pathPrefix); printBottom(pw,pathPrefix);
} finally { } finally {
@ -458,12 +709,62 @@ public class EldDocHtmlWriter {
e.printStackTrace(); e.printStackTrace();
} }
printTableRowSummary(pw,n,""+value); printTableRowSummary(pw,n,printValue(value));
} }
} }
printTableEnd(pw); printTableEnd(pw);
} }
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(PrintWriter pw,Collection<ElementClassAttribute> elementClassAttributes) {
printTableStart(pw,"Element Attributes");
for (ElementClassAttribute attr:elementClassAttributes) {
printTableRowSummary(pw,attr.getName(),attr.getDescription());
}
printTableEnd(pw);
}
private void printNamespaces(PrintWriter pw,List<ElementNamespaceContext> namespaces,String pathPrefix ,ElementLanguageModule mod) { private void printNamespaces(PrintWriter pw,List<ElementNamespaceContext> namespaces,String pathPrefix ,ElementLanguageModule mod) {
printTableStart(pw,"Namespaces"); printTableStart(pw,"Namespaces");
for (ElementNamespaceContext ns:namespaces) { for (ElementNamespaceContext ns:namespaces) {
@ -564,6 +865,7 @@ public class EldDocHtmlWriter {
if (description!=null) { if (description!=null) {
pw.print(description); pw.print(description);
pw.print("<br/>\n"); pw.print("<br/>\n");
pw.print("<br/>\n");
} }
} }
@ -676,5 +978,6 @@ public class EldDocHtmlWriter {
pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"index.html\">Index</a>&nbsp;</td>\n"); pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"index.html\">Index</a>&nbsp;</td>\n");
pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"module-overview.html\">Modules</a>&nbsp;</td>\n"); pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"module-overview.html\">Modules</a>&nbsp;</td>\n");
pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"namespace-overview.html\">Namespaces</a>&nbsp;</td>\n"); pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"namespace-overview.html\">Namespaces</a>&nbsp;</td>\n");
pw.print("\t\t<td class=\"NavBarCell1\"><a href=\""+pathPrefix+"tree-overview.html\">Tree</a>&nbsp;</td>\n");
} }
} }

View file

@ -26,7 +26,9 @@ package org.x4o.xml.eld.doc;
import java.io.File; import java.io.File;
import org.x4o.xml.eld.EldParserSupport; import org.x4o.xml.eld.EldParserSupport;
import org.x4o.xml.eld.EldParserSupportCore;
import org.x4o.xml.test.TestParserSupport; import org.x4o.xml.test.TestParserSupport;
import org.x4o.xml.test.swixml.SwiXmlParserSupport2;
import org.x4o.xml.test.swixml.SwiXmlParserSupport3; import org.x4o.xml.test.swixml.SwiXmlParserSupport3;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -51,6 +53,13 @@ public class EldDocTest extends TestCase {
return result; return result;
} }
public void testCelDoc() throws Exception {
X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter();
writer.setBasePath(getTempPath("junit-cel"));
writer.setLanguageParserSupport(EldParserSupportCore.class);
writer.execute();
}
public void testEldDoc() throws Exception { public void testEldDoc() throws Exception {
X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter();
writer.setBasePath(getTempPath("junit-eld")); writer.setBasePath(getTempPath("junit-eld"));
@ -64,6 +73,13 @@ public class EldDocTest extends TestCase {
writer.setLanguageParserSupport(TestParserSupport.class); writer.setLanguageParserSupport(TestParserSupport.class);
writer.execute(); writer.execute();
} }
public void testSwiXml2Doc() throws Exception {
X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter();
writer.setBasePath(getTempPath("junit-swixml2"));
writer.setLanguageParserSupport(SwiXmlParserSupport2.class);
writer.execute();
}
public void testSwiXml3Doc() throws Exception { public void testSwiXml3Doc() throws Exception {
X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter(); X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter();