Changed global element configurator to seperate interface, fixed few

javadoc warnings and worked on elddoc html output and added
more descriptions in eld.
This commit is contained in:
Willem Cazander 2012-11-18 06:15:24 +01:00
parent e94bb5ffe8
commit 9b286c7fbf
15 changed files with 203 additions and 120 deletions

View file

@ -355,10 +355,10 @@ public class X4ODebugWriter {
}
/**
* Todo move after xpath support
* @param element
* @param buff
* @return
* Todo move after xpath support.
* @param element The element.
* @param buff The buffer.
* @return Returns the buffer of the builf path.
*/
private StringBuffer getElementPath(Element element,StringBuffer buff) {
if (element.getParent()==null) {

View file

@ -150,6 +150,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
namespace.setId(CEL_CORE);
namespace.setUri(CEL_CORE_URI);
namespace.setSchemaUri(CEL_CORE_XSD_URI);
namespace.setSchemaResource(CEL_CORE_XSD_FILE);
@ -189,6 +190,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e);
}
namespace.setId(CEL_ROOT);
namespace.setUri(CEL_ROOT_URI);
namespace.setSchemaUri(CEL_ROOT_XSD_URI);
namespace.setSchemaResource(CEL_ROOT_XSD_FILE);
@ -285,6 +287,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
ec.addElementParent("", "configurator");
ec.addElementParent("", "elementInterface");
ec.addElementParent("", "element");
ec.addElementParent("", "attribute");
elementClassList.add(ec);
ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class);

View file

@ -52,7 +52,7 @@ public class AttributeFromBodyConfigurator extends AbstractElementConfigurator {
throw new ElementConfiguratorException(this,"name attribute is empty.");
}
if (bodyType==null) {
bodyType = "characters";
bodyType = ElementType.characters.name();
}
String value = null;
if ("characters".equals(bodyType)) {

View file

@ -138,7 +138,7 @@ public abstract class AbstractElementLanguageModule extends AbstractElementMetaB
}
/**
* @see org.x4o.xml.element.ElementLanguageModule#addGlobalElementConfigurator(ElementConfigurator)
* @see org.x4o.xml.element.ElementLanguageModule#addElementConfiguratorGlobal(ElementConfiguratorGlobal)
*/
public void addElementConfiguratorGlobal(ElementConfiguratorGlobal elementConfigurator) {
if (elementConfigurator==null) {

View file

@ -125,8 +125,7 @@ public class AttributeMap<K,V> implements Map<K,V> {
/**
* Gets the value of the attributes. uses the uri if not null.
*
* @param name
* The name of the attributes.
* @param name The name of the attributes.
* @return The value of the attribute.
*/
private String getValue(String name) {
@ -140,9 +139,8 @@ public class AttributeMap<K,V> implements Map<K,V> {
}
/**
* @see getValue(String name)
* @param key
* The name of the attribute.
* Gets the attribute value.
* @param key The name of the attribute.
* @return The value of the attribute.
*/
private String getValue(Object key) {

View file

@ -7,7 +7,7 @@
ModuleName: Core Element Languag Module
Namespaces: 2
Namespace: http://cel.x4o.org/xml/ns/cel-core
Created on: Sun Nov 18 03:27:37 CET 2012
Created on: Sun Nov 18 05:10:55 CET 2012
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:this="http://cel.x4o.org/xml/ns/cel-core"
@ -18,14 +18,14 @@
</choice>
<attribute name="uri" type="string" use="required"/>
<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="schemaPrefix" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
<complexType name="descriptionType">
<simpleContent>
@ -43,13 +43,13 @@
</choice>
<attribute name="objectClass" type="string"/>
<attribute name="elementClass" type="string"/>
<attribute name="tag" type="string"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="autoAttributes" type="boolean"/>
<attribute name="schemaContentComplex" type="boolean"/>
<attribute name="schemaContentMixed" type="boolean"/>
<attribute name="id" type="string"/>
<attribute name="tag" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
<complexType name="configuratorGlobalType">
<choice minOccurs="0" maxOccurs="unbounded"/>
@ -75,6 +75,7 @@
<complexType name="attributeType">
<choice minOccurs="0" maxOccurs="unbounded">
<element name="classConverter" type="this:classConverterType"/>
<element name="description" type="this:descriptionType"/>
</choice>
<attribute name="name" type="string"/>
<attribute name="objectConverter" type="string"/>
@ -83,8 +84,8 @@
<attribute name="runBeanFill" type="boolean"/>
<attribute name="required" type="boolean"/>
<attribute name="defaultValue" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
<complexType name="classConverterType">
<choice minOccurs="0" maxOccurs="unbounded"/>
@ -105,8 +106,8 @@
<element name="description" type="this:descriptionType"/>
</choice>
<attribute name="interfaceClass" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
<complexType name="elementParentType">
<choice minOccurs="0" maxOccurs="unbounded"/>

View file

@ -7,7 +7,7 @@
ModuleName: Core Element Languag Module
Namespaces: 2
Namespace: http://cel.x4o.org/xml/ns/cel-root
Created on: Sun Nov 18 03:27:37 CET 2012
Created on: Sun Nov 18 05:10:55 CET 2012
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cel-core="http://cel.x4o.org/xml/ns/cel-core"
@ -27,8 +27,8 @@
<attribute name="sourceResource" type="string"/>
<attribute name="elementLanguageModuleLoader" type="string"/>
<attribute name="providerName" type="string"/>
<attribute name="id" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
</element>
</schema>

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition
Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-conv
Created on: Sun Nov 18 03:32:55 CET 2012
Created on: Sun Nov 18 05:06:09 CET 2012
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:this="http://eld.x4o.org/xml/ns/eld-conv"

View file

@ -7,7 +7,7 @@
ModuleName: Element Language Definition
Namespaces: 3
Namespace: http://eld.x4o.org/xml/ns/eld-lang
Created on: Sun Nov 18 03:32:55 CET 2012
Created on: Sun Nov 18 05:06:09 CET 2012
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
@ -20,12 +20,12 @@
</choice>
<attribute name="uri" type="string" use="required"/>
<attribute name="name" type="string"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="elementNamespaceInstanceProvider" type="string"/>
<attribute name="schemaUri" type="string"/>
<attribute name="schemaResource" type="string"/>
<attribute name="schemaPrefix" type="string"/>
<attribute name="languageRoot" type="boolean"/>
<attribute name="prefixMapping" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
@ -53,11 +53,11 @@
</choice>
<attribute name="objectClass" type="string"/>
<attribute name="elementClass" type="string"/>
<attribute name="tag" type="string"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="autoAttributes" type="boolean"/>
<attribute name="schemaContentComplex" type="boolean"/>
<attribute name="schemaContentMixed" type="boolean"/>
<attribute name="schemaContentBase" type="string"/>
<attribute name="tag" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
@ -121,14 +121,15 @@
<element ref="conv:urlConverter"/>
<element name="attributeAlias" type="this:attributeAliasType"/>
<element name="bean" type="this:beanType"/>
<element name="description" type="this:descriptionType"/>
</choice>
<attribute name="name" type="string"/>
<attribute name="defaultValue" type="string"/>
<attribute name="runResolveEL" type="boolean"/>
<attribute name="objectConverter" type="string"/>
<attribute name="runConverters" type="boolean"/>
<attribute name="runBeanFill" type="boolean"/>
<attribute name="objectConverter" type="string"/>
<attribute name="runResolveEL" type="boolean"/>
<attribute name="required" type="boolean"/>
<attribute name="defaultValue" type="string"/>
<attribute name="description" type="string"/>
<attribute name="id" type="string"/>
</complexType>
@ -176,7 +177,12 @@
<attribute name="namespaceUri" type="string"/>
<anyAttribute/>
</complexType>
<element name="namespace" type="this:namespaceType"/>
<element name="namespace" type="this:namespaceType">
<annotation>
<documentation xml:lang="en">Defines an namespace for the language.
</documentation>
</annotation>
</element>
<element name="description" type="this:descriptionType">
<annotation>
<documentation xml:lang="en">An ELD elementDescription field which lets you type text like this one in xml characters instead of an attribute.
@ -189,7 +195,12 @@
</documentation>
</annotation>
</element>
<element name="element" type="this:elementType"/>
<element name="element" type="this:elementType">
<annotation>
<documentation xml:lang="en">The xml element.
</documentation>
</annotation>
</element>
<element name="attributeAlias" type="this:attributeAliasType">
<annotation>
<documentation xml:lang="en">Defines an alias for an attribute name.
@ -226,7 +237,12 @@
</documentation>
</annotation>
</element>
<element name="attribute" type="this:attributeType"/>
<element name="attribute" type="this:attributeType">
<annotation>
<documentation xml:lang="en">XML Element Attribute tag.
</documentation>
</annotation>
</element>
<element name="bindingHandler" type="this:bindingHandlerType">
<annotation>
<documentation xml:lang="en">Define an className in bean.class for an ElementBindingHandler interface.
@ -245,7 +261,12 @@
</documentation>
</annotation>
</element>
<element name="elementInterface" type="this:elementInterfaceType"/>
<element name="elementInterface" type="this:elementInterfaceType">
<annotation>
<documentation xml:lang="en">Config element objects by java interface.
</documentation>
</annotation>
</element>
<element name="elementParent" type="this:elementParentType">
<annotation>
<documentation xml:lang="en">Adds an parent element tag for xsd

View file

@ -52,7 +52,9 @@
>
<!-- Root Element for nice namespace'ing -->
<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>
</attribute>
<description>The module root element.</description>
</element>
</namespace>
@ -68,55 +70,89 @@
<!-- First copy some core elements over from parent config -->
<element tag="namespace" objectClass="${parentLanguageConfiguration.defaultElementNamespaceContext}">
<attribute name="uri" required="true"/>
<description>Defines an namespace for the language.</description>
<attribute name="uri" required="true">
<description>The namespace id.</description>
</attribute>
</element>
<element tag="element" objectClass="${parentLanguageConfiguration.defaultElementClass}">
<description>The xml element.</description>
<attribute name="objectClass">
<description>The class of the wrapped object.</description>
<classConverter/>
</attribute>
<attribute name="elementClass">
<attribute name="elementClass">
<description>An custom element class to config object.</description>
<classConverter/>
</attribute>
</element>
<element tag="elementInterface" objectClass="${parentLanguageConfiguration.defaultElementInterface}">
<attribute name="id" required="true"/>
<description>Config element objects by java interface.</description>
<attribute name="id" required="true">
<description>The interface id.</description>
</attribute>
<attribute name="interfaceClass" required="true">
<description>The interface class.</description>
<classConverter/>
</attribute>
</element>
<element tag="attribute" objectClass="${parentLanguageConfiguration.defaultElementClassAttribute}"/>
<element tag="attribute" objectClass="${parentLanguageConfiguration.defaultElementClassAttribute}">
<description>XML Element Attribute tag.</description>
</element>
<!-- Create some support elements to make language readable. -->
<element tag="bindingHandler" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementBindingHandler interface.</description>
<attribute name="id" required="true"/>
<attribute name="bean.class" required="true"/>
<attribute name="id" required="true">
<description>The binding handler id.</description>
</attribute>
<attribute name="bean.class" required="true">
<description>The class of the binding handler.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
<elementParent tag="elementInterface"/>
</element>
<element tag="attributeHandler" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementAttributeHandler.</description>
<attribute name="id" required="true"/>
<attribute name="bean.class" required="true"/>
<attribute name="attributeName" required="true"/>
<attribute name="id" required="true">
<description>The atttribute handler id.</description>
</attribute>
<attribute name="bean.class" required="true">
<description>The class of the attribute handler.</description>
</attribute>
<attribute name="attributeName" required="true">
<description>The xml attribute name.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
</element>
<element tag="configuratorGlobal" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementConfiguratorGlobal.</description>
<attribute name="id" required="true"/>
<attribute name="bean.class" required="true"/>
<attribute name="configAction"/>
<attribute name="id" required="true">
<description>The global element configurator id.</description>
</attribute>
<attribute name="bean.class" required="true">
<description>The class of the element configurator.</description>
</attribute>
<attribute name="configAction">
<description>If set to true then run in config phase.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
</element>
<element tag="configurator" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an className in bean.class for an ElementConfigurator.</description>
<attribute name="id" required="true"/>
<attribute name="bean.class" required="true"/>
<attribute name="configAction"/>
<attribute name="id" required="true">
<description>The element configurator id.</description>
</attribute>
<attribute name="bean.class" required="true">
<description>The class of the global element configurator.</description>
</attribute>
<attribute name="configAction">
<description>If set to true then run in config phase.</description>
</attribute>
<elementParent tag="elementInterface"/>
<elementParent tag="element"/>
</element>
@ -129,6 +165,7 @@
<elementParent tag="configurator"/>
<elementParent tag="elementInterface"/>
<elementParent tag="element"/>
<elementParent tag="attribute"/>
<elementParent tag="attributeFromBody"/>
<elementParent tag="classBindingHandler"/>
</element>
@ -139,48 +176,69 @@
<element tag="elementParent" elementClass="org.x4o.xml.eld.lang.ElementClassAddParentElement">
<description>Adds an parent element tag for xsd</description>
<elementParent tag="element"/>
<attribute name="tag"/>
<attribute name="namespaceUri"/>
<attribute name="tag">
<description>The parent tag to have object for.</description>
</attribute>
<attribute name="namespaceUri">
<description>The element namespace uri if non local.</description>
</attribute>
</element>
<element tag="elementSkipPhase" elementClass="org.x4o.xml.eld.lang.SkipPhaseElement">
<description>Adds an phase to skip to the parent element.</description>
<attribute name="name" required="true"/>
<attribute name="name" required="true">
<description>The name of the phase to skip.</description>
</attribute>
<elementParent tag="element"/>
</element>
<element tag="attributeHandlerNextAttribute" elementClass="org.x4o.xml.eld.lang.NextAttributeElement">
<description>Defines the parameter order.</description>
<attribute name="attributeName" required="true"/>
<attribute name="attributeName" required="true">
<description>The attribute name to run after this attribute.</description>
</attribute>
<elementParent tag="attributeHandler"/>
<elementParent tag="bean"/>
</element>
<element tag="attributeAlias" elementClass="org.x4o.xml.eld.lang.AttributeAliasElement">
<description>Defines an alias for an attribute name.</description>
<attribute name="name" required="true"/>
<attribute name="name" required="true">
<description>The alias name to add to the attribute.</description>
</attribute>
<elementParent tag="attribute"/>
</element>
<element tag="attributeFromBody" objectClass="org.x4o.xml.eld.lang.AttributeFromBodyConfigurator" autoAttributes="false">
<description>Defines an alias for an attribute name.</description>
<attribute name="name" required="true"/>
<attribute name="id" required="true"/>
<attribute name="bodyType"/>
<attribute name="id" required="true">
<description>The id for this configurator.</description>
</attribute>
<attribute name="name" required="true">
<description>The attribute name to fill the value.</description>
</attribute>
<attribute name="bodyType">
<description>See org.x4o.xml.element.Element.ElementType for options defaults to 'characters'.</description>
</attribute>
</element>
<element tag="classBindingHandler" objectClass="org.x4o.xml.eld.lang.ElementRefectionBindingHandler"
autoAttributes="false"
>
<description>Lets you dynamicly bind to object togecher.</description>
<attribute name="id" required="true"/>
<attribute name="id" required="true">
<description>The id for this binding handler.</description>
</attribute>
<attribute name="parentClass">
<description>The parent class.</description>
<classConverter/>
</attribute>
<attribute name="childClass">
<description>The child class.</description>
<classConverter/>
</attribute>
<attribute name="method">
<description>The method name of the method used to add the child to the parent.</description>
</attribute>
</element>
@ -190,7 +248,9 @@
<element tag="bean" elementClass="org.x4o.xml.eld.lang.BeanElement">
<!-- BIG NOTE: maybe beanElement most go to meta to have clean impl. -->
<description>Loads bean into the Element</description>
<attribute name="bean.class"/>
<attribute name="bean.class">
<description>The class name of the the class to load.</description>
</attribute>
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
<elementParent tag="elementInterface"/>
<elementParent tag="element"/>
@ -204,11 +264,14 @@
schemaResource="eld-conv-1.0.xsd"
schemaPrefix="conv"
name="Element Attribute Converters"
id="eld-conv"
>
<!-- Config all converters, move ? -->
<element tag="beanConverter" elementClass="org.x4o.xml.eld.lang.BeanElement">
<description>Define an loadable in bean.class for an ObjectConverter.</description>
<attribute name="bean.class"/>
<attribute name="bean.class">
<description>The class name of the converter to load.</description>
</attribute>
<elementParent tag="attribute" uri="http://eld.x4o.org/xml/ns/eld-lang"/>
<!-- todo: make converter which loads converter so xsd is correct. -->
</element>
@ -224,17 +287,20 @@
<element tag="enumConverter" objectClass="org.x4o.xml.conv.text.EnumConverter" />
<element tag="stringSplitConverter" objectClass="org.x4o.xml.conv.text.StringSplitConverter">
<attribute name="classTo" required="true"><classConverter/></attribute>
<attribute name="split" required="true"/>
<attribute name="splitSize" required="true"/>
<attribute name="singleToMethod"/>
<attribute name="useNativeType"/>
<attribute name="classTo" required="true">
<description>The class name to convert the string to.</description>
<classConverter/>
</attribute>
<attribute name="split" required="true" description="The split regex."/>
<attribute name="splitSize" required="true" description="The split value expected size."/>
<attribute name="singleToMethod" description="Shortcut to use only this method for the 'to' convert."/>
<attribute name="useNativeType" description="Set to true to convert to native data type."/>
</element>
<element tag="stringSplitConverterStep" objectClass="org.x4o.xml.conv.text.StringSplitConverterStep">
<attribute name="fromMethod" required="true"/>
<attribute name="toMethod" required="false"/>
<attribute name="fromOrder" required="true"/>
<attribute name="toOrder" required="true"/>
<attribute name="fromMethod" required="true" description="The convert 'from' method step."/>
<attribute name="toMethod" required="false" description="The convert 'to' method step."/>
<attribute name="fromOrder" required="true" description="The convert 'from' order."/>
<attribute name="toOrder" required="true" description="The convert 'to' order."/>
</element>
</namespace>
</root:module>

View file

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

View file

@ -91,7 +91,6 @@ public class EmptyXmlTest extends TestCase {
try {
parser.parseResource("tests/empty-xml/empty-xml.xml");
} catch (SAXException e) {
e.printStackTrace();
boolean hasError = e.getMessage().contains("Premature end of file."); // java6+ sax message
if (hasError==false) {
hasError = e.getMessage().contains("A well-formed document requires a root element."); // xercesImpl sax message