From 8f2408a207e05b32dd0777f94be57416a332b62a Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Sun, 28 Apr 2013 12:07:37 +0200 Subject: [PATCH] Added providerHost in language module and remove name. Added default uri/schemaUri/etc on namespace contexts. Added default for id/tag of Element. Added attribute aliases to xsd output. Added name alias for id on namespace. Added tag alias for id on element. --- .../org/x4o/xml/eld/EldModuleLoaderCore.java | 21 +- .../xml/eld/lang/AttributeAliasElement.java | 2 +- .../lang/ElementClassAddParentElement.java | 2 +- .../eld/lang/ElementModuleBindingHandler.java | 42 +++ ...ElementNamespaceContextBindingHandler.java | 6 +- .../x4o/xml/eld/lang/SkipPhaseElement.java | 2 +- .../org/x4o/xml/eld/xsd/EldXsdXmlWriter.java | 146 ++++++---- .../x4o/xml/element/AbstractElementClass.java | 15 - .../AbstractElementNamespaceContext.java | 6 +- .../org/x4o/xml/element/ElementClass.java | 12 - .../java/org/x4o/xml/io/DefaultX4OWriter.java | 6 +- .../org/x4o/xml/io/sax/X4ODebugWriter.java | 11 +- .../org/x4o/xml/io/sax/X4OTagHandler.java | 8 +- .../xml/lang/AbstractX4OLanguageModule.java | 58 ++-- .../org/x4o/xml/lang/DefaultX4OLanguage.java | 2 +- .../org/x4o/xml/lang/X4OLanguageModule.java | 20 +- .../xml/lang/phase/X4OPhaseLanguageRead.java | 4 +- .../xml/lang/phase/X4OPhaseLanguageWrite.java | 4 +- .../resources/META-INF/cel/cel-core-1.0.xsd | 40 ++- .../resources/META-INF/cel/cel-root-1.0.xsd | 21 +- .../resources/META-INF/eld/eld-conv-1.0.xsd | 90 ++++-- .../resources/META-INF/eld/eld-lang-1.0.xsd | 262 ++++++++++++++---- .../main/resources/META-INF/eld/eld-lang.eld | 84 +++--- .../resources/META-INF/eld/eld-root-1.0.xsd | 43 ++- .../java/org/x4o/xml/io/X4OWriterTest.java | 6 +- .../META-INF/swixml/swixml-lang-2.0.eld | 27 +- .../META-INF/swixml/swixml-lang-3.0.eld | 61 ++-- .../resources/META-INF/test/test-lang.eld | 4 +- .../test/resources/META-INF/x4o-drivers.xml | 28 ++ .../tests/swixml/swixml-accelerator-3.0.xml | 4 +- .../org/x4o/xml/eld/doc/EldDocHtmlWriter.java | 41 ++- .../lang/meta/MetaLanguageSiblingLoader.java | 10 +- .../resources/META-INF/mtest/mtest-lang.eld | 2 + 33 files changed, 695 insertions(+), 395 deletions(-) diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java b/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java index 2382947..ae370ac 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.x4o.xml.conv.ObjectConverter; import org.x4o.xml.conv.text.ClassConverter; +import org.x4o.xml.eld.lang.AttributeAliasElement; import org.x4o.xml.eld.lang.BeanElement; import org.x4o.xml.eld.lang.DescriptionElement; import org.x4o.xml.eld.lang.ElementClassAddParentElement; @@ -61,8 +62,8 @@ import org.x4o.xml.lang.X4OLanguageModuleLoaderException; public class EldModuleLoaderCore implements X4OLanguageModuleLoader { private Logger logger = null; - private static final String PP_CEL_PROVIDER = "cel.x4o.org"; - private static final String PP_CEL_XMLNS = "http://"+PP_CEL_PROVIDER+"/xml/ns/"; + private static final String PP_CEL_PROVIDER_HOST = "cel.x4o.org"; + private static final String PP_CEL_XMLNS = "http://"+PP_CEL_PROVIDER_HOST+"/xml/ns/"; private static final String PP_CEL_XSD_FILE = "-1.0.xsd"; private static final String CEL_CORE = "cel-core"; private static final String CEL_ROOT = "cel-root"; @@ -107,6 +108,8 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { ElementNamespaceContext namespaceRoot = createNamespaceContext(language,CEL_ROOT,CEL_ROOT_URI,CEL_ROOT_XSD_URI,CEL_ROOT_XSD_FILE,CEL_ROOT); namespaceRoot.setLanguageRoot(true); // Only define single language root so xsd is (mostly) not cicle import. ElementClass rootElement = createElementClass(language,"module",language.getLanguageConfiguration().getDefaultElementLanguageModule(),ModuleElement.class,"The module tag is the root xml element for ELD language."); + rootElement.addElementClassAttribute(createElementClassAttribute(language,"id",true,null)); + rootElement.addElementClassAttribute(createElementClassAttribute(language,"providerHost",true,null)); namespaceRoot.addElementClass(rootElement); startAndAddNamespace(language,languageModule,namespaceRoot); } @@ -121,6 +124,12 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { ElementClass ec = null; namespace.addElementClass(createElementClass(language,"attribute",language.getLanguageConfiguration().getDefaultElementClassAttribute(),null,"Defines xml element attribute.")); + + ec = createElementClass(language,"attributeAlias",null,AttributeAliasElement.class,"Adds an attribute alias."); + ec.addElementClassAttribute(createElementClassAttribute(language,"name",true,null)); + ec.addElementParent(CEL_CORE_URI, "attribute"); + namespace.addElementClass(ec); + namespace.addElementClass(createElementClass(language,"classConverter",ClassConverter.class,null,"Converts string attribute to java class instance.")); ec = createElementClass(language,"namespace",language.getLanguageConfiguration().getDefaultElementNamespaceContext(),null,"Defines an xml namespace."); @@ -184,10 +193,10 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { private void configLanguageModule(X4OLanguageModule languageModule) { languageModule.setId("cel-module"); - languageModule.setName("Core Element Languag Module"); - languageModule.setProviderName(PP_CEL_PROVIDER); + languageModule.setProviderName("Core Element Languag Module"); + languageModule.setProviderHost(PP_CEL_PROVIDER_HOST); languageModule.setDescription("Core Element Language Module Loader"); - languageModule.setSourceResource(this.getClass().getSimpleName()); // todo check if oke. + languageModule.setSourceResource(this.getClass().getSimpleName()); //TODO: check if oke. } private void startAndAddNamespace(X4OLanguageLocal language,X4OLanguageModule languageModule,ElementNamespaceContext namespace) throws X4OLanguageModuleLoaderException { @@ -230,7 +239,7 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader { private ElementClass createElementClass(X4OLanguage language,String tag,Class objectClass,Class elementClass,String description) throws X4OLanguageModuleLoaderException { try { ElementClass result = (ElementClass)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementClass()); - result.setTag(tag); + result.setId(tag); result.setObjectClass(objectClass); result.setElementClass(elementClass); result.setDescription(description); diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/AttributeAliasElement.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/AttributeAliasElement.java index 4faaa02..495a1b6 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/AttributeAliasElement.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/AttributeAliasElement.java @@ -44,7 +44,7 @@ public class AttributeAliasElement extends AbstractElement { public void doElementEnd() throws ElementException { String alias = getAttributes().get("name"); if (alias==null) { - throw new ElementException("'name' attribute is not set on: "+getElementClass().getTag()); + throw new ElementException("'name' attribute is not set on: "+getElementClass().getId()); } if (getParent().getElementObject() instanceof ElementClassAttribute) { ((ElementClassAttribute)getParent().getElementObject()).addAttributeAlias(alias); diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementClassAddParentElement.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementClassAddParentElement.java index 82b6a33..41aaedf 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementClassAddParentElement.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementClassAddParentElement.java @@ -43,7 +43,7 @@ public class ElementClassAddParentElement extends AbstractElement { public void doElementEnd() throws ElementException { String tag = getAttributes().get("tag"); if (tag==null) { - throw new ElementException("'tag' attribute is not set on: "+getElementClass().getTag()); + throw new ElementException("'tag' attribute is not set on: "+getElementClass().getId()); } String namespaceUri = getAttributes().get("uri"); if (namespaceUri==null) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java index 23fdf03..19130fd 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java @@ -100,6 +100,48 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler< } if (childObject instanceof ElementNamespaceContext) { ElementNamespaceContext elementNamespaceContext = (ElementNamespaceContext)childObject; + + if (elementNamespaceContext.getId()==null) { + throw new NullPointerException("Can add ElementNamespaceContext without id."); + } + // TODO: no language here so move to EL default on eld attribute tag + if (elementNamespaceContext.getId()!=null) { + StringBuffer buf = new StringBuffer(30); + for (char c:elementNamespaceContext.getId().toLowerCase().toCharArray()) { + if (Character.isLetter(c)) {buf.append(c);} + if (Character.isDigit(c)) {buf.append(c);} + if ('-'==c) {buf.append(c);} + } + String id = buf.toString(); + elementNamespaceContext.setId(id); + } + if (elementNamespaceContext.getUri()==null) { + elementNamespaceContext.setUri( + "http://"+languageModule.getProviderHost()+ + "/xml/ns/"+x4oParsingContext.getLanguageName()+ + "-"+elementNamespaceContext.getId()); + } + if (elementNamespaceContext.getSchemaUri()==null) { + elementNamespaceContext.setSchemaUri( + "http://"+languageModule.getProviderHost()+ + "/xml/ns/"+x4oParsingContext.getLanguageName()+ + "-"+elementNamespaceContext.getId()+ + "-"+x4oParsingContext.getLanguageVersion()+ + ".xsd" + ); + } + if (elementNamespaceContext.getSchemaResource()==null) { + elementNamespaceContext.setSchemaResource( + x4oParsingContext.getLanguageName()+ + "-"+elementNamespaceContext.getId()+ + "-"+x4oParsingContext.getLanguageVersion()+ + ".xsd" + ); + } + if (elementNamespaceContext.getSchemaPrefix()==null) { + elementNamespaceContext.setSchemaPrefix(elementNamespaceContext.getId()); + } + try { elementNamespaceContext.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); } catch (Exception e) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java index 225554d..9b86965 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementNamespaceContextBindingHandler.java @@ -60,7 +60,11 @@ public class ElementNamespaceContextBindingHandler extends AbstractElementBindin */ public void bindChild(Element childElement,ElementNamespaceContext parent, Object childObject) throws ElementBindingHandlerException { if (childObject instanceof ElementClass) { - parent.addElementClass((ElementClass)childObject); + ElementClass elementClass = (ElementClass)childObject; + if (elementClass.getId()==null && elementClass.getObjectClass()!=null) { + elementClass.setId(elementClass.getObjectClass().getSimpleName()); // TODO: move to defaults layer + } + parent.addElementClass(elementClass); } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/SkipPhaseElement.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/SkipPhaseElement.java index a35a9b5..55750b7 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/SkipPhaseElement.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/SkipPhaseElement.java @@ -43,7 +43,7 @@ public class SkipPhaseElement extends AbstractElement { public void doElementEnd() throws ElementException { String phase = getAttributes().get("name"); if (phase==null) { - throw new ElementException("'name' attribute is not set on: "+getElementClass().getTag()); + throw new ElementException("'name' attribute is not set on: "+getElementClass().getId()); } if (getParent().getElementObject() instanceof ElementClass) { ((ElementClass)getParent().getElementObject()).addSkipPhase(phase); 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 d444f94..9a95153 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 @@ -38,7 +38,9 @@ import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementClassAttribute; 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.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguage; import org.xml.sax.SAXException; @@ -149,13 +151,11 @@ public class EldXsdXmlWriter { public void startSchema(ElementNamespaceContext ns) throws SAXException { xmlWriter.startDocument(); + writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE); + writeComment(COMMENT_SEPERATOR); + writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE); // this is a mess; - char[] msg; - msg = "\n".toCharArray(); - xmlWriter.ignorableWhitespace(msg,0,msg.length); - msg = COMMENT_SEPERATOR.toCharArray(); - xmlWriter.comment(msg,0,msg.length); String desc = "Automatic generated schema for language: "+language.getLanguageName(); int space = COMMENT_SEPERATOR.length()-desc.length()-(2*COMMENT_TEXT.length())-4; StringBuffer b = new StringBuffer(COMMENT_SEPERATOR.length()); @@ -168,17 +168,10 @@ public class EldXsdXmlWriter { } b.append(COMMENT_TEXT); b.append(" "); - - msg = "\n".toCharArray(); - xmlWriter.ignorableWhitespace(msg,0,msg.length); - msg = b.toString().toCharArray(); - xmlWriter.comment(msg,0,msg.length); - msg = "\n".toCharArray(); - xmlWriter.ignorableWhitespace(msg,0,msg.length); - msg = COMMENT_SEPERATOR.toCharArray(); - xmlWriter.comment(msg,0,msg.length); - msg = "\n".toCharArray(); - xmlWriter.ignorableWhitespace(msg,0,msg.length); + writeComment(b.toString()); + writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE); + writeComment(COMMENT_SEPERATOR); + writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE); X4OLanguageModule module = null; for (X4OLanguageModule elm:language.getLanguageModules()) { @@ -190,19 +183,15 @@ public class EldXsdXmlWriter { } b = new StringBuffer(COMMENT_SEPERATOR.length()); - b.append("\n\tProviderName:\t"); - b.append(module.getProviderName()); - b.append("\n\tModuleName:\t\t"); - b.append(module.getName()); - b.append("\n\tNamespaces:\t\t"); - b.append(module.getElementNamespaceContexts().size()); - b.append("\n\tNamespace:\t\t"); - b.append(ns.getUri()); - b.append("\n\tCreated on:\t\t"); - b.append(new Date()); + b.append("\n\tID:\t\t"); b.append(module.getId()); + b.append("\n\tProviderName:\t"); b.append(module.getProviderName()); + b.append("\n\tProviderHost:\t"); b.append(module.getProviderHost()); + b.append("\n\tNamespaces:\t\t"); b.append(module.getElementNamespaceContexts().size()); + b.append("\n\tUri:\t\t\t"); b.append(ns.getUri()); + b.append("\n\tUri schema:\t"); b.append(ns.getSchemaUri()); + b.append("\n\tCreated on:\t\t"); b.append(new Date()); b.append("\n"); - msg = b.toString().toCharArray(); - xmlWriter.comment(msg,0,msg.length); + writeComment(b.toString()); xmlWriter.startPrefixMapping("", SCHEMA_URI); @@ -234,6 +223,7 @@ public class EldXsdXmlWriter { public void endSchema() throws SAXException { xmlWriter.endElement (SCHEMA_URI, "schema" , ""); + writeIgnorableWhitespace(XMLConstants.CHAR_NEWLINE); xmlWriter.endDocument(); } @@ -241,13 +231,13 @@ public class EldXsdXmlWriter { AttributesImpl atts = new AttributesImpl(); if (nsWrite.getLanguageRoot()!=null && nsWrite.getLanguageRoot()) { - atts.addAttribute ("", "name", "", "", ec.getTag()); + atts.addAttribute ("", "name", "", "", ec.getId()); xmlWriter.startElement (SCHEMA_URI, "element", "", atts); // Only in the language root xsd there is an element. atts = new AttributesImpl(); xmlWriter.startElement (SCHEMA_URI, "complexType", "", atts); } else { - atts.addAttribute ("", "name", "", "", ec.getTag()+"Type"); + atts.addAttribute ("", "name", "", "", ec.getId()+"Type"); xmlWriter.startElement (SCHEMA_URI, "complexType", "", atts); } @@ -289,8 +279,15 @@ public class EldXsdXmlWriter { if (eca.getRequired()!=null && eca.getRequired()) { atts.addAttribute ("", "use", "", "", "required"); } - xmlWriter.startElement (SCHEMA_URI, "attribute", "", atts); - xmlWriter.endElement(SCHEMA_URI, "attribute", ""); + writeElementAttribute(eca,atts); + + for (String alias:eca.getAttributeAliases()) { + attrNames.add(alias); + atts = new AttributesImpl(); + atts.addAttribute ("", "name", "", "", alias); + atts.addAttribute ("", "type", "", "", "string"); + writeElementAttribute(null,atts); + } } for (X4OLanguageModule mod:language.getLanguageModules()) { @@ -299,16 +296,13 @@ public class EldXsdXmlWriter { atts = new AttributesImpl(); atts.addAttribute ("", "name", "", "", eah.getAttributeName()); atts.addAttribute ("", "type", "", "", "string"); - xmlWriter.startElement (SCHEMA_URI, "attribute", "", atts); - xmlWriter.endElement(SCHEMA_URI, "attribute", ""); + writeElementAttribute(eah,atts); } } if (ec.getAutoAttributes()!=null && ec.getAutoAttributes()==false) { // oke, reverse this if and rm whitespace. - char[] msg; - msg = " ".toCharArray(); - xmlWriter.ignorableWhitespace(msg,0,msg.length); + writeIgnorableWhitespace(" "); } else { @@ -374,8 +368,8 @@ public class EldXsdXmlWriter { List refElements = new ArrayList(20); for (ElementClass checkClass:ns.getElementClasses()) { List parents = checkClass.getElementParents(nsWrite.getUri()); - if (parents!=null && parents.contains(ecWrite.getTag())) { - refElements.add(checkClass.getTag()); + if (parents!=null && parents.contains(ecWrite.getId())) { + refElements.add(checkClass.getId()); continue; } if (checkClass.getObjectClass()==null) { @@ -383,8 +377,8 @@ public class EldXsdXmlWriter { } for (ElementInterface ei:language.findElementInterfaces(checkClass.getObjectClass())) { parents = ei.getElementParents(nsWrite.getUri()); - if (parents!=null && parents.contains(ecWrite.getTag())) { - refElements.add(checkClass.getTag()); + if (parents!=null && parents.contains(ecWrite.getId())) { + refElements.add(checkClass.getId()); break; } } @@ -395,7 +389,7 @@ public class EldXsdXmlWriter { Class checkObjectClass = checkClass.getObjectClass(); List b = language.findElementBindingHandlers(objectClass,checkObjectClass); if (b.isEmpty()==false) { - refElements.add(checkClass.getTag()); + refElements.add(checkClass.getId()); } } @@ -429,23 +423,57 @@ public class EldXsdXmlWriter { return; // is done in writeElementClass } AttributesImpl atts = new AttributesImpl(); - atts.addAttribute ("", "name", "", "", ec.getTag()); - atts.addAttribute ("", "type", "", "", "this:"+ec.getTag()+"Type"); - xmlWriter.startElement(SCHEMA_URI, "element", "", atts); // Only in the language root xsd there is an element. - - if (ec.getDescription()!=null) { - atts = new AttributesImpl(); - xmlWriter.startElement(SCHEMA_URI, "annotation", "", atts); - atts = new AttributesImpl(); - atts.addAttribute ("", "xml:lang", "", "", "en"); - xmlWriter.startElement(SCHEMA_URI, "documentation", "", atts); - char[] msg = ec.getDescription().toCharArray(); - xmlWriter.characters(msg,0,msg.length); - xmlWriter.endElement(SCHEMA_URI, "documentation", ""); - xmlWriter.endElement(SCHEMA_URI, "annotation", ""); - } - - + atts.addAttribute ("", "name", "", "", ec.getId()); + atts.addAttribute ("", "type", "", "", "this:"+ec.getId()+"Type"); + xmlWriter.startElement(SCHEMA_URI, "element", "", atts); + writeElementMetaBase(ec); xmlWriter.endElement(SCHEMA_URI, "element", ""); } + + private void writeElementAttribute(ElementMetaBase base,AttributesImpl atts) throws SAXException { + xmlWriter.startElement (SCHEMA_URI, "attribute", "", atts); + writeElementMetaBase(base); + xmlWriter.endElement(SCHEMA_URI, "attribute", ""); + } + + private void writeElementMetaBase(ElementMetaBase base) throws SAXException { + if (base==null) { + return; + } + if (base.getDescription()==null) { + return; + } + AttributesImpl atts = new AttributesImpl(); + xmlWriter.startElement(SCHEMA_URI, "annotation", "", atts); + atts = new AttributesImpl(); + atts.addAttribute ("", "xml:lang", "", "", "en"); + xmlWriter.startElement(SCHEMA_URI, "documentation", "", atts); + writeCharacters(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/AbstractElementClass.java b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementClass.java index 32b0407..5085561 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementClass.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementClass.java @@ -34,7 +34,6 @@ import java.util.List; */ public abstract class AbstractElementClass extends AbstractElementClassBase implements ElementClass { - private String tag = null; private Class objectClass = null; private Class elementClass = null; private Boolean autoAttributes = true; @@ -47,20 +46,6 @@ public abstract class AbstractElementClass extends AbstractElementClassBase impl skipPhases = new ArrayList(3); } - /** - * @see ElementClass#getTag() - */ - public String getTag() { - return tag; - } - - /** - * @see ElementClass#setTag(String) - */ - public void setTag(String tag) { - this.tag = tag; - } - /** * @see ElementClass#getElementClass() */ diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java index 176758a..cd17b50 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementNamespaceContext.java @@ -81,10 +81,10 @@ public abstract class AbstractElementNamespaceContext extends AbstractElementMet * @see org.x4o.xml.element.ElementNamespaceContext#addElementClass(org.x4o.xml.element.ElementClass) */ public void addElementClass(ElementClass elementClass) { - if (elementClass.getTag()==null) { - throw new NullPointerException("ElementClass not correctly configured getTag is null."); + if (elementClass.getId()==null) { + throw new NullPointerException("ElementClass not correctly configured getId is null."); } - elementClasses.put(elementClass.getTag(), elementClass); + elementClasses.put(elementClass.getId(), elementClass); } /** diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/ElementClass.java b/x4o-driver/src/main/java/org/x4o/xml/element/ElementClass.java index d3f4194..5377105 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/ElementClass.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/ElementClass.java @@ -33,19 +33,7 @@ import java.util.List; * @version 1.0 Aug 11, 2005 */ public interface ElementClass extends ElementClassBase { - - /** - * Gets the xml tag the Element should handle. - * @return the tag - */ - String getTag(); - /** - * Sets the XML tag the Element should handle. - * @param tag the tag to set - */ - void setTag(String tag); - /** * Gets the ElementClass. * @return the elementClass diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java index b6c3d83..10a0e0d 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java @@ -171,17 +171,17 @@ public class DefaultX4OWriter extends AbstractX4OWriter { } String elementUri = findElementUri(element); - writer.startElement(elementUri, element.getElementClass().getTag(), "", atts); + writer.startElement(elementUri, element.getElementClass().getId(), "", atts); for (Element e:element.getChilderen()) { writeTree(writer,e); } - writer.endElement(elementUri, element.getElementClass().getTag(), ""); + writer.endElement(elementUri, element.getElementClass().getId(), ""); } private String findElementUri(Element e) { for (X4OLanguageModule mod:getLanguageContext().getLanguage().getLanguageModules()) { for (ElementNamespaceContext c:mod.getElementNamespaceContexts()) { - ElementClass ec = c.getElementClass(e.getElementClass().getTag()); + ElementClass ec = c.getElementClass(e.getElementClass().getId()); if (ec!=null) { return c.getUri(); } 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 2dded38..6fbd130 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 @@ -220,8 +220,9 @@ public class X4ODebugWriter { for (X4OLanguageModule module:elementLanguage.getLanguage().getLanguageModules()) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "className", "", "", module.getClass().getName()); - atts.addAttribute ("", "name", "", "", module.getName()); + atts.addAttribute ("", "id", "", "", module.getId()); atts.addAttribute ("", "providerName", "", "", module.getProviderName()); + atts.addAttribute ("", "providerHost", "", "", module.getProviderHost()); if (module.getLanguageModuleLoader()==null) { atts.addAttribute ("", "elementLanguageModuleLoaderClassName", "", "", "null"); } else { @@ -366,12 +367,12 @@ public class X4ODebugWriter { private StringBuffer getElementPath(Element element,StringBuffer buff) { if (element.getParent()==null) { buff.append('/'); // root slash - buff.append(element.getElementClass().getTag()); + buff.append(element.getElementClass().getId()); return buff; } buff = getElementPath(element.getParent(),buff); buff.append('/'); - buff.append(element.getElementClass().getTag()); + buff.append(element.getElementClass().getId()); return buff; } @@ -435,7 +436,9 @@ public class X4ODebugWriter { private void debugElementClass(ElementClass elementClass) throws SAXException { AttributesImpl atts = new AttributesImpl(); - atts.addAttribute ("", "tag", "", "", elementClass.getTag()); + atts.addAttribute ("", "id", "", "", elementClass.getId()); + atts.addAttribute ("", "autoAttributes", "", "", ""+elementClass.getAutoAttributes()); + //atts.addAttribute ("", "schemaContentBase", "", "", ""+elementClass.getSchemaContentBase()); atts.addAttribute ("", "description", "", "", elementClass.getDescription()); atts.addAttribute ("", "objectClassName", "", "", ""+elementClass.getObjectClass()); atts.addAttribute ("", "className", "", "", elementClass.getClass().getName()); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java index 60587b1..9cd20d1 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OTagHandler.java @@ -182,7 +182,7 @@ public class X4OTagHandler extends DefaultHandler2 { logger.finest("XMLTAG-END: "+namespaceUri+":"+tag); } if (overrideSaxHandler!=null) { - if (overrideSaxElement.getElementClass().getTag().equals(tag)) { + if (overrideSaxElement.getElementClass().getId().equals(tag)) { overrideSaxHandler.endDocument(); overrideSaxHandler = null; overrideSaxElement = null; // elementStack code make sure doElementEnd is runned on override element. @@ -229,7 +229,7 @@ public class X4OTagHandler extends DefaultHandler2 { try { e.doCharacters(text); } catch (ElementException ee) { - throw new SAXParseException("Error while doCharacters element: '"+e.getElementClass().getTag()+"' "+ee.getMessage(),locator,ee); + throw new SAXParseException("Error while doCharacters element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee); } } @@ -254,7 +254,7 @@ public class X4OTagHandler extends DefaultHandler2 { try { e.doIgnorableWhitespace(text); } catch (ElementException ee) { - throw new SAXParseException("Error while doIgnorableWhitespace element: '"+e.getElementClass().getTag()+"' "+ee.getMessage(),locator,ee); + throw new SAXParseException("Error while doIgnorableWhitespace element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee); } } @@ -279,7 +279,7 @@ public class X4OTagHandler extends DefaultHandler2 { try { e.doComment(text); } catch (ElementException ee) { - throw new SAXParseException("Error while doComment element: '"+e.getElementClass().getTag()+"' "+ee.getMessage(),locator,ee); + throw new SAXParseException("Error while doComment element: '"+e.getElementClass().getId()+"' "+ee.getMessage(),locator,ee); } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java index 5116f60..51ff8a7 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java @@ -45,23 +45,15 @@ import org.x4o.xml.element.ElementNamespaceContext; public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase implements X4OLanguageModule { private Logger logger = null; - - private String name=null; private String providerName=null; + private String providerHost=null; private String sourceResource = null; - /** The globalAttribute handlers */ private List elementAttributeHandlers = null; - - /** The binding rules */ private List elementBindingHandlers = null; - private List elementConfiguratorGlobals = null; - private List elementInterfaces = null; - private Map elementNamespaceContexts = null; - private X4OLanguageModuleLoader elementLanguageModuleLoader = null; /** @@ -76,35 +68,35 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase elementInterfaces = new ArrayList(20); elementNamespaceContexts = new HashMap(10); } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - + /** * @return the providerName */ public String getProviderName() { return providerName; } - + /** * @param providerName the providerName to set */ public void setProviderName(String providerName) { this.providerName = providerName; } - + + /** + * @return the providerHost + */ + public String getProviderHost() { + return providerHost; + } + + /** + * @param providerHost the providerHost to set + */ + public void setProviderHost(String providerHost) { + this.providerHost = providerHost; + } + /** * @see org.x4o.xml.lang.X4OLanguageModule#addElementAttributeHandler(ElementAttributeHandler) */ @@ -208,20 +200,6 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase if (elementNamespaceContext.getUri()==null) { throw new NullPointerException("Can add ElementNamespaceContext without uri."); } - if (elementNamespaceContext.getId()==null) { - StringBuffer buf = new StringBuffer(30); - for (char c:elementNamespaceContext.getUri().toLowerCase().toCharArray()) { - if (Character.isLetter(c)) {buf.append(c);} - if (Character.isDigit(c)) {buf.append(c);} - } - String id = buf.toString(); - if (id.startsWith("http")) {id = id.substring(4);} - elementNamespaceContext.setId(id); - } - // TODO: no language here so move to EL default on eld attribute tag - //if (elementNamespaceContext.getSchemaUri()==null) { - // elementNamespaceContext.setSchemaUri(elementNamespaceContext.getUri()+elementNamespaceContext.) - //} logger.fine("Adding namespaceUri: "+elementNamespaceContext.getUri()); elementNamespaceContexts.put(elementNamespaceContext.getUri(), elementNamespaceContext); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java index b34bd94..540e4c8 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java @@ -140,7 +140,7 @@ public class DefaultX4OLanguage implements X4OLanguageLocal { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { try { - return nsContext.getElementNamespaceInstanceProvider().createElementInstance(context, ec.getTag()); + return nsContext.getElementNamespaceInstanceProvider().createElementInstance(context, ec.getId()); } catch (ElementNamespaceInstanceProviderException e) { throw new RuntimeException(e.getMessage(),e); // TODO: fix me } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java index 01254d7..01c9b36 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageModule.java @@ -41,16 +41,6 @@ import org.x4o.xml.element.ElementNamespaceContext; */ public interface X4OLanguageModule extends ElementMetaBase { - /** - * @return the Name. - */ - String getName(); - - /** - * @param name the module name to set. - */ - void setName(String name); - /** * @return the providerName. */ @@ -61,6 +51,16 @@ public interface X4OLanguageModule extends ElementMetaBase { */ void setProviderName(String providerName); + /** + * @return the providerHost + */ + public String getProviderHost(); + + /** + * @param providerHost the providerHost to set + */ + public void setProviderHost(String providerHost); + /** * Adds an ElementAttributeHandler. * @param elementAttributeHandler Adds an ElmentAttributeHandler. 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 e70e29f..e30d8aa 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 @@ -981,11 +981,11 @@ public class X4OPhaseLanguageRead { handler.startPrefixMapping(prefix, nameSpace); startedPrefix.add(prefix); } - handler.startElement (nameSpace, element.getElementClass().getTag(), "", atts); + handler.startElement (nameSpace, element.getElementClass().getId(), "", atts); for (Element e:element.getAllChilderen()) { printXML(e); } - handler.endElement (nameSpace, element.getElementClass().getTag(), ""); + handler.endElement (nameSpace, element.getElementClass().getId(), ""); } }; return result; 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 ac621e8..575bf01 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 @@ -144,7 +144,7 @@ public class X4OPhaseLanguageWrite { if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { - return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getTag()); + return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getId()); } } } @@ -154,7 +154,7 @@ public class X4OPhaseLanguageWrite { for (ElementNamespaceContext nsContext:modContext.getElementNamespaceContexts()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { - return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getTag()); + return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getId()); } } } diff --git a/x4o-driver/src/main/resources/META-INF/cel/cel-core-1.0.xsd b/x4o-driver/src/main/resources/META-INF/cel/cel-core-1.0.xsd index 312ca7b..7fd4215 100644 --- a/x4o-driver/src/main/resources/META-INF/cel/cel-core-1.0.xsd +++ b/x4o-driver/src/main/resources/META-INF/cel/cel-core-1.0.xsd @@ -1,13 +1,14 @@ - - - - + + + + - + @@ -44,7 +45,6 @@ - @@ -60,6 +60,11 @@ + + + + + @@ -77,17 +82,18 @@ + - - - - + + + + @@ -144,6 +150,12 @@ + + + Adds an attribute alias. + + + Define generic configurator for language. @@ -186,4 +198,4 @@ - \ No newline at end of file + diff --git a/x4o-driver/src/main/resources/META-INF/cel/cel-root-1.0.xsd b/x4o-driver/src/main/resources/META-INF/cel/cel-root-1.0.xsd index e1a3419..0a1983b 100644 --- a/x4o-driver/src/main/resources/META-INF/cel/cel-root-1.0.xsd +++ b/x4o-driver/src/main/resources/META-INF/cel/cel-root-1.0.xsd @@ -1,13 +1,14 @@ - - - - + + + + - + + - - \ No newline at end of file + diff --git a/x4o-driver/src/main/resources/META-INF/eld/eld-conv-1.0.xsd b/x4o-driver/src/main/resources/META-INF/eld/eld-conv-1.0.xsd index 0d47313..a02bff6 100644 --- a/x4o-driver/src/main/resources/META-INF/eld/eld-conv-1.0.xsd +++ b/x4o-driver/src/main/resources/META-INF/eld/eld-conv-1.0.xsd @@ -1,13 +1,15 @@ - - - - + + + + - + + + The class name of the converter to load. + + + @@ -42,10 +49,30 @@ - - - - + + + The convert 'to' method step. + + + + + + The convert 'from' order. + + + + + + The convert 'from' method step. + + + + + + The convert 'to' order. + + + @@ -61,11 +88,36 @@ - - - - - + + + Set to true to convert to native data type. + + + + + + Shortcut to use only this method for the 'to' convert. + + + + + + The split value expected size. + + + + + + The split regex. + + + + + + The class name to convert the string to. + + + @@ -98,4 +150,4 @@ - \ No newline at end of file + diff --git a/x4o-driver/src/main/resources/META-INF/eld/eld-lang-1.0.xsd b/x4o-driver/src/main/resources/META-INF/eld/eld-lang-1.0.xsd index 7146958..6bb0384 100644 --- a/x4o-driver/src/main/resources/META-INF/eld/eld-lang-1.0.xsd +++ b/x4o-driver/src/main/resources/META-INF/eld/eld-lang-1.0.xsd @@ -1,13 +1,15 @@ - - - - + + + + - + + + The namespace id. + + + - - + - + + @@ -39,7 +46,12 @@ - + + + The name of the phase to skip. + + + @@ -52,60 +64,145 @@ - - + + + The attribute id. (with tag as alias) + + + - + + + The class of the wrapped object. + + + + + + An custom element class to config object. + + + + - - + + + The alias name to add to the attribute. + + + - - - + + + The global element configurator id. + + + + + + The class of the element configurator. + + + + + + If set to true then run in config phase. + + + - - - + + + The element configurator id. + + + + + + The class of the global element configurator. + + + + + + If set to true then run in config phase. + + + - - - + + + See org.x4o.xml.element.Element.ElementType for options defaults to 'characters'. + + + + + + The id for this configurator. + + + + + + The attribute name to fill the value. + + + - - - + + + The xml attribute name. + + + + + + The atttribute handler id. + + + + + + The class of the attribute handler. + + + - + + + The attribute name to run after this attribute. + + + @@ -126,41 +223,86 @@ + + + The attribute id. (with name as alias) + + + - - - - - + - + + + + - - + + + The binding handler id. + + + + + + The class of the binding handler. + + + - + + + The class name of the the class to load. + + + - - - - - + + + The id for this binding handler. + + + + + + The child class. + + + + + + The parent class. + + + + + + The method name of the method used to get the childeren of the parent. + + + + + + The method name of the method used to add the child to the parent. + + + @@ -173,14 +315,34 @@ - - + + + The interface id. + + + + + + The interface class. + + + - - + + + The parent tag to have object for. + + + + + + The element namespace uri if non local parent. + + + @@ -279,4 +441,4 @@ - \ No newline at end of file + diff --git a/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld b/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld index a1dcfd1..2abb86f 100644 --- a/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld +++ b/x4o-driver/src/main/resources/META-INF/eld/eld-lang.eld @@ -28,8 +28,8 @@ xmlns="http://cel.x4o.org/xml/ns/cel-core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://cel.x4o.org/xml/ns/cel-root http://cel.x4o.org/xml/ns/cel-root-1.0.xsd" - name="Element Language Definition" - providerName="eld.x4o.org" + providerName="Element Language Definition" + providerHost="eld.x4o.org" id="eld-module" > The full element language definition(eld) which is used to define xml languages. @@ -52,11 +52,17 @@ id="eld-root" > Single root namespace so xsd schema generation works correct. - + + The module root element. The module id. - The module root element. + + The provider host like langx.someorg.domain for uri/etc defaults. + + + The provider name in normal en:lang. + @@ -71,24 +77,28 @@ Some basic language definitions and some helper tags. - + Defines an namespace for the language. - + The namespace id. - + The xml element. + + + The attribute id. (with tag as alias) + The class of the wrapped object. - + An custom element class to config object. - + Config element objects by java interface. The interface id. @@ -98,13 +108,17 @@ - + XML Element Attribute tag. + + + The attribute id. (with name as alias) + - + Define an className in bean.class for an ElementBindingHandler interface. The binding handler id. @@ -116,7 +130,7 @@ - + Define an className in bean.class for an ElementAttributeHandler. The atttribute handler id. @@ -130,7 +144,7 @@ - + Define an className in bean.class for an ElementConfiguratorGlobal. The global element configurator id. @@ -144,7 +158,7 @@ - + Define an className in bean.class for an ElementConfigurator. The element configurator id. @@ -159,7 +173,7 @@ - + An ELD elementDescription field which lets you type text like this one in xml characters instead of an attribute. @@ -177,7 +191,7 @@ - + Adds an parent element tag for xsd @@ -189,7 +203,7 @@ - + Adds an phase to skip to the parent element. The name of the phase to skip. @@ -197,7 +211,7 @@ - + Defines the parameter order. The attribute name to run after this attribute. @@ -206,7 +220,7 @@ - + Defines an alias for an attribute name. The alias name to add to the attribute. @@ -214,7 +228,7 @@ - + Defines an alias for an attribute name. The id for this configurator. @@ -227,7 +241,7 @@ - Lets you dynamicly bind to object togecher. @@ -253,7 +267,7 @@ - + Loads bean into the Element @@ -276,7 +290,7 @@ > Basic set of attribute value converters. - + Define an loadable in bean.class for an ObjectConverter. The class name of the converter to load. @@ -284,18 +298,18 @@ - - - - - - - - - - + + + + + + + + + + - + The class name to convert the string to. @@ -305,7 +319,7 @@ - + diff --git a/x4o-driver/src/main/resources/META-INF/eld/eld-root-1.0.xsd b/x4o-driver/src/main/resources/META-INF/eld/eld-root-1.0.xsd index 5c32da6..13072b7 100644 --- a/x4o-driver/src/main/resources/META-INF/eld/eld-root-1.0.xsd +++ b/x4o-driver/src/main/resources/META-INF/eld/eld-root-1.0.xsd @@ -1,13 +1,15 @@ - - - - + + + + - - - - + + + The module id. + + + + + + The provider name in normal en:lang. + + + + + + The provider host like langx.someorg.domain for uri/etc defaults. + + + + - \ No newline at end of file + 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 ec070fb..015b824 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 @@ -63,6 +63,8 @@ public class X4OWriterTest extends TestCase { writer.writeFile(root, outputFile); String text = new Scanner( outputFile ).useDelimiter("\\A").next(); + outputFile.delete(); + //System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath()); assertTrue(text.startsWith("")); assertTrue(text.contains("http://test.x4o.org/xml/ns/test-root")); @@ -71,10 +73,6 @@ public class X4OWriterTest extends TestCase { assertTrue(text.contains("privateIntegerTypeField=\"123\"")); assertTrue(text.contains("privateDoubleObjectField=\"123.45\"")); assertTrue(text.contains("privateStringObjectField=\"x4o\"")); - - //System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath()); - - outputFile.delete(); } public void testWriterSwiXmlOutput() throws Exception { diff --git a/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-2.0.eld b/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-2.0.eld index bcf1ef4..23e896f 100644 --- a/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-2.0.eld +++ b/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-2.0.eld @@ -29,8 +29,8 @@ 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="swixml2.test.x4o.org" - name="Swixml2 Language" + providerHost="swixml2.test.x4o.org" + providerName="Swixml2 Language" id="swixml2-module" > @@ -88,25 +88,12 @@ - - - + + + Single element in language root to create nice tree, for imports in xsd namespace aware generated files. + - + diff --git a/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-3.0.eld b/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-3.0.eld index d84ecc5..a63ea2a 100644 --- a/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-3.0.eld +++ b/x4o-driver/src/test/resources/META-INF/swixml/swixml-lang-3.0.eld @@ -29,8 +29,8 @@ 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="swixml3.test.x4o.org" - name="Swixml3 Language" + providerHost="swixml.x4o.org" + providerName="Swixml3 Language" id="swixml3-module" > @@ -83,29 +83,14 @@ - - - - + + + - - - - + + + + @@ -114,9 +99,9 @@ - - - + + + @@ -125,16 +110,16 @@ - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file 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 0b0a143..806d84f 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 @@ -29,8 +29,8 @@ 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="test.x4o.org" - name="Test Language" + providerName="test Language" + providerHost="test.x4o.org" id="test-module" > diff --git a/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml b/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml index 242a911..c652646 100644 --- a/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml +++ b/x4o-driver/src/test/resources/META-INF/x4o-drivers.xml @@ -29,6 +29,34 @@ xsi:schemaLocation="http://language.x4o.org/xml/ns/drivers http://language.x4o.org/xml/ns/drivers-1.0.xsd" > + diff --git a/x4o-driver/src/test/resources/tests/swixml/swixml-accelerator-3.0.xml b/x4o-driver/src/test/resources/tests/swixml/swixml-accelerator-3.0.xml index 14bc39d..f676f80 100644 --- a/x4o-driver/src/test/resources/tests/swixml/swixml-accelerator-3.0.xml +++ b/x4o-driver/src/test/resources/tests/swixml/swixml-accelerator-3.0.xml @@ -30,7 +30,7 @@ xsi:schemaLocation="http://test.x4o.org/xml/ns/test-root test-root-1.0.xsd" name="mainframe" size="800,600" title="SWIXML-X4O" plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel" defaultCloseOperation="3" > - + @@ -45,7 +45,7 @@ - + diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java index a15a9f9..4c24000 100644 --- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java +++ b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java @@ -191,7 +191,7 @@ public class EldDocHtmlWriter { List mods = context.getLanguage().getLanguageModules(); Collections.sort(mods,new ElementLanguageModuleComparator()); for (X4OLanguageModule mod:mods) { - printTableRowOverview(pw,toSafeUri(mod.getId())+"/index.html",mod.getId(),mod.getName()); + printTableRowOverview(pw,toSafeUri(mod.getId())+"/index.html",mod.getId(),mod.getDescription()); } printTableEnd(pw); printBottom(pw,""); @@ -279,11 +279,11 @@ public class EldDocHtmlWriter { pw.print("/"); pw.print(toSafeUri(node.namespace.getId())); pw.print("/"); - pw.print(toSafeUri(node.elementClass.getTag())); + pw.print(toSafeUri(node.elementClass.getId())); pw.print("/index.html\">"); pw.print(node.namespace.getId()); pw.print(":"); - pw.print(node.elementClass.getTag()); + pw.print(node.elementClass.getId()); pw.print("
\n"); List childs = findChilderen(node); @@ -303,7 +303,7 @@ public class EldDocHtmlWriter { for (ElementClass ec:ns.getElementClasses()) { TreeNode n=null; List tags = ec.getElementParents(node.namespace.getUri()); - if (tags!=null && tags.contains(node.elementClass.getTag())) { + if (tags!=null && tags.contains(node.elementClass.getId())) { n = new TreeNode(); n.context=node.context; n.module=mod; @@ -318,7 +318,7 @@ public class EldDocHtmlWriter { // 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.getTag())) { + if (eiTags!=null && eiTags.contains(node.elementClass.getId())) { n = new TreeNode(); n.context=node.context; n.module=mod; @@ -357,7 +357,7 @@ public class EldDocHtmlWriter { private boolean isInTree(TreeNode node,TreeNode checkNode) { if ( node.namespace.getUri().equals(checkNode.namespace.getUri()) && - node.elementClass.getTag().equals(checkNode.elementClass.getTag()) + node.elementClass.getId().equals(checkNode.elementClass.getId()) ) { return true; } @@ -376,7 +376,7 @@ public class EldDocHtmlWriter { List tags = node.elementClass.getElementParents(ns.getUri()); if (tags!=null) { for (ElementClass ec:ns.getElementClasses()) { - if (tags.contains(ec.getTag())) { + if (tags.contains(ec.getId())) { n = new TreeNode(); n.context=node.context; n.module=mod; @@ -394,7 +394,7 @@ public class EldDocHtmlWriter { 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.getTag())) { + if (eiTags!=null && eiTags.contains(ec.getId())) { n = new TreeNode(); n.context=node.context; n.module=mod; @@ -439,7 +439,7 @@ public class EldDocHtmlWriter { String pathPrefix = "../"; try { printHeader(pw,"Overview ("+mod.getId()+")",pathPrefix); - printPageTitle(pw,"Module",mod.getName(),mod.getDescription()); + printPageTitle(pw,"Module",mod.getProviderName(),mod.getDescription()); String pathPrefixModule = pathPrefix+toSafeUri(mod.getId())+"/"; @@ -469,7 +469,7 @@ public class EldDocHtmlWriter { List ecs = ns.getElementClasses(); Collections.sort(ecs,new ElementClassComparator()); for (ElementClass ec:ecs) { - printTableRowOverview(pw,toSafeUri(ec.getTag())+"/index.html",ec.getTag(),ec.getDescription()); + printTableRowOverview(pw,toSafeUri(ec.getId())+"/index.html",ec.getId(),ec.getDescription()); } printTableEnd(pw); printBottom(pw,pathPrefix); @@ -496,11 +496,11 @@ public class EldDocHtmlWriter { public void writeElement(File basePath,ElementClass ec,ElementNamespaceContext ns,X4OLanguageModule mod,X4OLanguageContext context) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getTag(),"index.html"); + PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getId(),"index.html"); String pathPrefix = "../../../"; try { - printHeader(pw,"Tag ("+ec.getTag()+")",pathPrefix); - printPageTitle(pw,"Tag",ec.getTag(),ec.getDescription()); + printHeader(pw,"Tag ("+ec.getId()+")",pathPrefix); + printPageTitle(pw,"Tag",ec.getId(),ec.getDescription()); TreeNode node = new TreeNode(); node.context=context; @@ -522,11 +522,11 @@ public class EldDocHtmlWriter { pw.print("/"); pw.print(toSafeUri(n.namespace.getId())); pw.print("/"); - pw.print(toSafeUri(n.elementClass.getTag())); + pw.print(toSafeUri(n.elementClass.getId())); pw.print("/index.html\">"); pw.print(n.namespace.getId()); pw.print(":"); - pw.print(n.elementClass.getTag()); + pw.print(n.elementClass.getId()); pw.print("\n"); } pw.print("\n"); @@ -547,11 +547,11 @@ public class EldDocHtmlWriter { pw.print("/"); pw.print(toSafeUri(n.namespace.getId())); pw.print("/"); - pw.print(toSafeUri(n.elementClass.getTag())); + pw.print(toSafeUri(n.elementClass.getId())); pw.print("/index.html\">"); pw.print(n.namespace.getId()); pw.print(":"); - pw.print(n.elementClass.getTag()); + pw.print(n.elementClass.getId()); pw.print("\n"); } pw.print("\n"); @@ -561,7 +561,6 @@ public class EldDocHtmlWriter { printTableStart(pw,"Element Properties"); printTableRowSummary(pw,"id",""+ec.getId()); - printTableRowSummary(pw,"tag",""+ec.getTag()); printTableRowSummary(pw,"objectClass",""+ec.getObjectClass()); printTableRowSummary(pw,"elementClass",""+ec.getElementClass()); printTableRowSummary(pw,"autoAttributes",""+ec.getAutoAttributes()); @@ -640,7 +639,7 @@ public class EldDocHtmlWriter { } public void writeElementConfigurator(File basePath,ElementConfigurator conf,X4OLanguageModule mod,ElementNamespaceContext ns,ElementClass ec) throws IOException { - PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getTag(),"conf",conf.getId()+".html"); + PrintWriter pw = createPrintWriter(basePath,mod.getId(),ns.getId(),ec.getId(),"conf",conf.getId()+".html"); String pathPrefix = "../../../../"; try { printHeader(pw,"Interface Configurator ("+conf.getId()+")",pathPrefix); @@ -1036,13 +1035,13 @@ public class EldDocHtmlWriter { class TreeNodeComparator implements Comparator { public int compare(TreeNode o1,TreeNode o2) { - return o1.elementClass.getTag().compareTo(o2.elementClass.getTag()); + return o1.elementClass.getId().compareTo(o2.elementClass.getId()); } } class ElementClassComparator implements Comparator { public int compare(ElementClass o1,ElementClass o2) { - return o1.getTag().compareTo(o2.getTag()); + return o1.getId().compareTo(o2.getId()); } } } diff --git a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/MetaLanguageSiblingLoader.java b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/MetaLanguageSiblingLoader.java index bca64f1..2f51c79 100644 --- a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/MetaLanguageSiblingLoader.java +++ b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/MetaLanguageSiblingLoader.java @@ -44,6 +44,12 @@ public class MetaLanguageSiblingLoader implements X4OLanguageModuleLoaderSibling /** Defines the version of the meta x4o language. */ public static final String META_LANGUAGE_VERSION = "1.0"; + /** Defines the identifier of the meta x4o language host. */ + public static final String META_LANGUAGE_HOST = "meta.x4o.org"; + + /** Defines the identifier of the meta x4o language host. */ + public static final String META_LANGUAGE_DESCRIPTION = "X4O Meta XML Language Module."; + /** * Loads an ElementLanguageModule. * @param language The ElementLanguage to load for. @@ -53,9 +59,9 @@ public class MetaLanguageSiblingLoader implements X4OLanguageModuleLoaderSibling */ public void loadLanguageModule(X4OLanguageLocal language,X4OLanguageModule languageModule) throws X4OLanguageModuleLoaderException { languageModule.setId(META_LANGUAGE); - languageModule.setName(META_LANGUAGE); + languageModule.setProviderHost(META_LANGUAGE_HOST); languageModule.setProviderName(MetaLanguageSiblingLoader.class.getSimpleName()); - languageModule.setDescription("X4O Meta Language"); + languageModule.setDescription(META_LANGUAGE_DESCRIPTION); } /** diff --git a/x4o-meta/src/test/resources/META-INF/mtest/mtest-lang.eld b/x4o-meta/src/test/resources/META-INF/mtest/mtest-lang.eld index 5fc3628..1767be9 100644 --- a/x4o-meta/src/test/resources/META-INF/mtest/mtest-lang.eld +++ b/x4o-meta/src/test/resources/META-INF/mtest/mtest-lang.eld @@ -40,6 +40,7 @@ schemaPrefix="mroot" name="MTest Root Namespace" languageRoot="true" + id="mroot" > @@ -53,6 +54,7 @@ schemaResource="mtest-lang-1.0.xsd" schemaPrefix="mlang" name="MTest Language Namespace" + id="mlang" >