diff --git a/build.xml b/build.xml index 47c1d06..5bcff48 100644 --- a/build.xml +++ b/build.xml @@ -63,7 +63,7 @@ - + diff --git a/demo/XidDemo.java b/demo/XidDemo.java index b453616..26a0a09 100644 --- a/demo/XidDemo.java +++ b/demo/XidDemo.java @@ -1,37 +1,39 @@ -import java.util.*; -import java.io.*; +/** + * XidDemo + */ + import fr.devinsy.xid.*; /** * */ -class Demo +class XidDemo { - static private org.apache.log4j.Logger log; + static private org.apache.log4j.Logger logger; static { - // Initialize log. + // Initialize logger. org.apache.log4j.Logger log = null; org.apache.log4j.BasicConfigurator.configure (); log = org.apache.log4j.Logger.getRootLogger (); - //log.setLevel (org.apache.log4j.Level.INFO); - log.setLevel (org.apache.log4j.Level.INFO); + //logger.setLevel (org.apache.log4j.Level.INFO); + logger.setLevel (org.apache.log4j.Level.INFO); - log.info ("Enter"); + logger.info ("Enter"); // - log.info ("Set the log file format..."); + logger.info ("Set the log file format..."); // log = org.apache.log4j.Category.getInstance(Application.class.getName()); - log.info ("... done."); + logger.info ("... done."); - log.debug ("Exit"); - log = org.apache.log4j.Logger.getLogger (Demo.class); + logger.debug ("Exit"); + log = org.apache.log4j.Logger.getLogger (XidDemo.class); } diff --git a/src/xid/Attributes.java b/src/xid/Attributes.java deleted file mode 100644 index cad8b68..0000000 --- a/src/xid/Attributes.java +++ /dev/null @@ -1,79 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - - - -/** - * - * Note: no more AttrValue as in Brill, because the exception of style is managed - * in the attribute merging on the "style" string detection. - */ -public class Attributes extends HashMap -{ - /* - * - */ - public Attributes () - { - super (); - } - - - /* - * Useful for the merge attributes. - */ - public Attributes (Attributes attributes) - { - super (attributes); - } - - - /* - * - */ - public void setAttribute (String label, String value) - { - this.put (label, value); - } - - - /* - * Add a value to an existing value. This is useful to the 'style' attribute. - * - */ - public void appendAttribute (String label, String value) - { - if (this.containsKey (label)) - { - this.put (label, this.get (label) + value); - } - else - { - this.put (label, value); - } - } - - - /* - * - */ - public String getAttribute (String label) - { - String result; - - if (this.containsKey (label)) - { - result = this.get (label); - } - else - { - result = null; - } - - // - return (result); - } - -} diff --git a/src/xid/Data.java b/src/xid/Data.java deleted file mode 100644 index 7d312e8..0000000 --- a/src/xid/Data.java +++ /dev/null @@ -1,383 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/* - * - */ -public class Data -{ - protected IdsDataById idsDataById; - protected TagsDataById tagsDataById; - - - /** - * - */ - public Data () - { - this.idsDataById = new IdsDataById (); - this.tagsDataById = new TagsDataById (); - } - - - /** - * - */ - public IdsDataById getIdsDataById () - { - IdsDataById result; - - result = this.idsDataById; - - // - return (result); - } - - - /** - * - */ - public TagsDataById getTagsDataById () - { - TagsDataById result; - - result = this.tagsDataById; - - // - return (result); - } - - - /** - * - */ - public IdData getIdData (String id) - { - IdData result; - - // Be sure that IdData is existing and get item. - result = (IdData) this.idsDataById.getId (id); - - if (result == null) - { - this.idsDataById.setId (id, new IdData ()); - - result = (IdData) this.idsDataById.getId (id); - } - - - // - return (result); - } - - - /** - * - */ - public IdData getIdData (String id, int line) - { - IdData result; - - // Be sure that IdsData are existing. - IdsDataByIndex tags = (IdsDataByIndex) this.idsDataById.getId (id); - if (tags == null) - { - this.idsDataById.setId (id, new IdsDataByIndex ()); - - tags = (IdsDataByIndex) this.idsDataById.getId (id); - } - - // Be sure that lines are existing. - int nbLines = tags.size (); - for (int nLine = nbLines; nLine < line + 1; nLine++) - { - tags.add (nLine, new IdData ()); - } - - // Get item. - result = (IdData) tags.elementAt (line); - - // - return (result); - } - - - /** - * - */ - public IdData getIdData (String id, int line, String column) - { - IdData result; - - // Be sure that IdsData are existing. - IdsDataByIndex tags = (IdsDataByIndex) this.idsDataById.getId (id); - if (tags == null) - { - this.idsDataById.setId (id, new IdsDataByIndex ()); - - tags = (IdsDataByIndex) this.idsDataById.getId (id); - } - - // Be sure that lines are existing. - int nbLines = tags.size (); - for (int nLine = nbLines; nLine < line + 1; nLine++) - { - tags.add (nLine, new IdsDataById ()); - } - - // Get item. - IdsDataById lineData = (IdsDataById) tags.elementAt (line); - - result = (IdData) lineData.get (column); - - if (result == null) - { - lineData.put (column, new IdData ()); - - result = (IdData) lineData.get (column); - } - - // - return (result); - } - - - /** - * - */ - public void setIterationStrategy (String id, IdData.IterationStrategy strategy) - { - IdData tag = (IdData) this.getIdData (id); - - tag.setIterationStrategy (strategy); - } - - - - /** - * - */ - public void setContent (String id, String content) - { - if (id.startsWith ("<")) - { - String tagName = id.substring (1, id.length () - 1); - - TagData tag = this.tagsDataById.getId (tagName); - if (tag == null) - { - tag = new TagData (); - this.tagsDataById.setId (tagName, tag); - } - - tag.setContent (content); - } - else - { - IdData idData = this.getIdData (id); - - idData.setContent (content); - } - } - - - /** - * - */ - public void setContent (String id, int content) - { - setContent (id, (new Integer (content)).toString ()); - } - - - /** - * - */ - public void setContent (String id, int line, String content) - { - IdData tag = this.getIdData (id, line); - - tag.setContent (content); - } - - - /** - * - */ - public void setContent (String id, int line, int content) - { - setContent (id, line, (new Integer (content)).toString ()); - } - - - /** - * - */ - public void setContent (String id, int line, String column, String content) - { - IdData tag = this.getIdData (id, line, column); - - tag.setContent (content); - } - - - /** - * - */ - public void setContent (String id, int line, String column, int content) - { - setContent (id, line, column, (new Integer (content)).toString ()); - } - - - /** - * - */ - public void setAttribute (String id, String label, String value) - { - if (id.startsWith ("<")) - { - String tagName = id.substring (1, id.length () - 1); - - TagData tag = this.tagsDataById.getId (tagName); - if (tag == null) - { - tag = new TagData (); - this.tagsDataById.setId (tagName, tag); - } - - tag.getAttributes ().setAttribute (label, value); - } - else - { - IdData tag = this.getIdData (id); - - tag.getAttributes ().setAttribute (label, value); - } - } - - - /** - * - */ - public void setAttribute (String id, String label, int value) - { - setAttribute (id, label, (new Integer (value)).toString ()); - } - - - /** - * - */ - public void setAttribute (String id, int line, String label, String value) - { - IdData tag = this.getIdData (id, line); - - tag.getAttributes ().setAttribute (label, value); - } - - - /** - * - */ - public void setAttribute (String id, int line, String label, int value) - { - setAttribute (id, line, label, (new Integer (value)).toString ()); - } - - - /** - * - */ - public void setAttribute (String id, int line, String column, String label, String value) - { - IdData tag = this.getIdData (id, line, column); - - tag.getAttributes ().setAttribute (label, value); - } - - - /** - * - */ - public void setAttribute (String id, int line, String column, String label, int value) - { - setAttribute (id, line, column, label, (new Integer (value)).toString ()); - } - - - /** - * - */ - public void appendAttribute (String id, int line, String column, String label, String value) - { - org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger (Data.class); - - - IdData tag = this.getIdData (id, line, column); - - tag.getAttributes ().appendAttribute (label, value); - } - - - /** - * - */ - public void appendAttribute (String id, String label, String value) - { - IdData tag = this.getIdData (id); - - tag.getAttributes ().appendAttribute (label, value); - } - - - /** - * - */ - public void appendAttribute (String id, String label, int value) - { - appendAttribute (id, label, (new Integer (value)).toString ()); - } - - - /** - * - */ - public void appendContent (String id, int line, String value) - { - IdData tag = this.getIdData (id, line); - - tag.appendContent (value); - } - - - /** - * - */ - public void appendContent (String id, int line, int value) - { - appendContent (id, line, (new Integer (value)).toString ()); - } - - - /** - * - */ - public void appendContent (String id, int line, String column, String value) - { - IdData tag = this.getIdData (id, line, column); - - tag.appendContent (value); - } - - - /** - * - */ - public void appendContent (String id, int line, String column, int value) - { - appendContent (id, line, column, (new Integer (value)).toString ()); - } -} diff --git a/src/xid/DomPresenter.java b/src/xid/DomPresenter.java deleted file mode 100644 index bb2d242..0000000 --- a/src/xid/DomPresenter.java +++ /dev/null @@ -1,196 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; -import javax.xml.parsers.*; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import org.xml.sax.*; -import org.w3c.dom.*; -/** - * - */ -public class DomPresenter extends Presenter -{ - static final public char INDEX_SEPARATOR = '_'; - - static protected org.apache.log4j.Logger log; - static - { - log = org.apache.log4j.Logger.getLogger (DomPresenter.class); - } - - static protected String staticRootPath; - static - { - staticRootPath = null; - } - - - protected String webappPath; - protected Document doc; - - /* - * - */ - public DomPresenter () - { - this.webappPath = Presenter.staticRootPath; - this.doc = null; - } - - - /* - * - */ - public DomPresenter (Document doc) - { - this.webappPath = Presenter.staticRootPath; - this.doc = doc; - DomPresenter.addMetaTag (this.doc, "generator", "XID 0.0"); - } - - - /* - * - */ - public DomPresenter (String webappPath, Document doc) - { - if ((webappPath == null) || (webappPath.equals (""))) - { - this.webappPath = Presenter.staticRootPath; - } - else - { - this.webappPath = webappPath; - } - - this.doc = doc; - DomPresenter.addMetaTag (this.doc, "generator", "XID 0.0"); - } - - - /* - * - */ - public String getWebappPath () - { - String result; - - result = this.webappPath; - - // - return (result); - } - - /* - * - */ - public void setWebappPath (String path) - { - this.webappPath = path; - } - - - /** - * - */ - public Document getDom () - { - Document result; - - result = this.doc; - - // - return (result); - } - - - /** - * - */ - public void setDom (Document doc) - { - this.doc = doc; - } - - - /* - * - */ - public void setSource (Document doc) - { - this.doc = doc; - - Presenter.addMetaTag (this.doc, "generator", "XID 0.0"); - } - - - /* - * - */ - public Object getSource () - { - Object result; - - result = this.doc; - - // - return (result); - } - - - /* - * - */ - public StringBuffer doXid (Data datas, StringBuffer errorOutput) - { - return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput)); - } - - /* - * - */ - public StringBuffer doXid (IdsDataById datas, TagsDataById tagsData, StringBuffer errorOutput) - { - StringBuffer result; - - if (this.doc == null) - { - String errorMessage = "source not defined"; - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - else - { - // Build the web page. - result = Presenter.doXid (this.doc, datas, tagsData, this.webappPath, errorOutput); - } - - // - return (result); - } - - - /* - * Xid a file with data. - */ - static public StringBuffer doXid (Document doc, IdsDataById datas, String webappPath, StringBuffer errorOutput) - { - return (doXid (doc, datas, null, webappPath, errorOutput)); - } - - /* - * Xid a file with data. - */ - static public StringBuffer doXid (Document doc, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - result = Presenter.process (doc, datas, tagsData, webappPath, errorOutput); - - // - return (result); - } -} diff --git a/src/xid/FilePresenter.java b/src/xid/FilePresenter.java deleted file mode 100644 index 2adbe82..0000000 --- a/src/xid/FilePresenter.java +++ /dev/null @@ -1,170 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; -import javax.xml.parsers.*; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import org.xml.sax.*; -import org.w3c.dom.*; -/** - * - */ -public class FilePresenter extends DomPresenter -{ - static protected org.apache.log4j.Logger log; - static - { - log = org.apache.log4j.Logger.getLogger (FilePresenter.class); - } - - protected String sourceFileName; - protected long sourceFileTime; - - /* - * - */ - public FilePresenter () - { - this.webappPath = Presenter.staticRootPath; - this.sourceFileName = null; - this.sourceFileTime = 0; - this.doc = null; - } - - - /* - * - */ - public FilePresenter (String fileName) - { - this.webappPath = Presenter.staticRootPath; - this.sourceFileName = fileName; - this.sourceFileTime = 0; - this.doc = null; - } - - - /* - * - */ - public FilePresenter (String webappPath, String fileName) - { - if ((webappPath == null) || (webappPath.equals (""))) - { - this.webappPath = Presenter.staticRootPath; - } - else - { - this.webappPath = webappPath; - } - this.sourceFileName = fileName; - this.sourceFileTime = 0; - this.doc = null; - } - - - /* - * - */ - public void setSource (String fileName) - { - this.sourceFileName = fileName; - this.sourceFileTime = 0; - this.doc = null; - } - - - /* - * - */ - public String getSource () - { - String result; - - result = this.sourceFileName; - - // - return (result); - } - - - /* - * - */ - public StringBuffer doXid (Data datas, StringBuffer errorOutput) - { - return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput)); - } - - - /* - * - */ - public StringBuffer doXid (IdsDataById datas, TagsDataById tagsData, StringBuffer errorOutput) - { - StringBuffer result; - - String sourceFilePath = this.webappPath + File.separator + this.sourceFileName; - - // Get the good tree. - File source = new File (sourceFilePath); - - if (source == null) - { - String errorMessage = "source file not defined"; - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - else if (!source.exists ()) - { - String errorMessage = "source file defined but not found (" + sourceFilePath + ")"; - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - else if ((this.doc == null) || - (this.sourceFileTime != source.lastModified ())) - { - this.sourceFileTime = source.lastModified (); - this.doc = Presenter.fileToTree (sourceFilePath, errorOutput); - - if (this.doc != null) - { - Presenter.addMetaTag (doc, "generator", "XID 0.0"); - } - } - - // Build the web page. - result = Presenter.doXid (doc, datas, tagsData, this.webappPath, errorOutput); - - // - return (result); - } - - - /* - * Xid a file without data. - */ - static public StringBuffer doXid (String fileName, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - Document doc = Presenter.fileToTree (fileName, errorOutput); - - if (doc == null) - { - result = null; - } - else - { - Presenter.addMetaTag (doc, "generator", "XID 0.0"); - - result = Presenter.doXid (doc, null, null, webappPath, errorOutput); - } - - // - return (result); - } -} diff --git a/src/xid/IdData.java b/src/xid/IdData.java deleted file mode 100644 index 708e8bb..0000000 --- a/src/xid/IdData.java +++ /dev/null @@ -1,177 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/** - * IdData class is used to hold application data and - * the business logic that operates on the data. - * - * The only requirement of a IdData class is that it must implement a - * display method. The display method must return a text representation - * of the data, suitable for display in a web page. - * - * XID provides a User Input IdData, Text IdData and ... - * application may also implement it's own IdData classes. - * - */ -public class IdData implements Serializable, IdDataCore -{ - public enum IterationStrategy {ONLY_FIRST_ROW, ONLY_FIRST_TWO_ROWS, ONLY_ROWS_WITH_ID, ONLY_ROWS_WITHOUT_ID, ALL_ROWS} - - protected IterationStrategy iterationStrategy; - - - public enum MODE {REPLACE, APPEND, IGNORE}; - - protected Attributes attributes; - protected boolean excludeSection; - protected MODE displayMode = MODE.REPLACE; - protected String content; - - /* - * - */ - public IdData () - { - this.attributes = null; - this.excludeSection = false; - this.displayMode = MODE.REPLACE; - this.content = null; - this.iterationStrategy = IterationStrategy.ALL_ROWS; - } - - - /* - * - */ - public IdData (String text) - { - this.attributes = null; - this.excludeSection = false; - this.displayMode = MODE.REPLACE; - this.content = text; - this.iterationStrategy = IterationStrategy.ALL_ROWS; - } - - - /* - * - */ - public String display () - { - String result; - - result = this.content; - - // - return (result); - } - - - /* - * - */ - public void setContent (String text) - { - this.content = text; - } - - - /* - * - */ - public void appendContent (String text) - { - if (this.content == null) - { - this.content = text; - } - else - { - this.content += text; - } - } - - - /* - * - */ - public void setDisplayMode(MODE displayMode) - { - this.displayMode = displayMode; - } - - - /* - * - */ - public MODE getDisplayMode() - { - MODE result; - - result = this.displayMode; - - return (result); - } - - - /* - * - */ - public Attributes getAttributes () - { - Attributes result; - - if (this.attributes == null) - { - this.attributes = new Attributes (); - } - - result = this.attributes; - - // - return (result); - } - - - /* - * - */ - public void setExcludeSection(boolean excludeSection) - { - this.excludeSection = excludeSection; - } - - - /* - * - */ - public boolean getExcludeSection() - { - return excludeSection; - } - - - /** - * - */ - public void setIterationStrategy (IterationStrategy strategy) - { - this.iterationStrategy = strategy; - } - - - /** - * - */ - public IterationStrategy getIterationStrategy () - { - IterationStrategy result; - - result = this.iterationStrategy; - - // - return (result); - } -} diff --git a/src/xid/IdDataCore.java b/src/xid/IdDataCore.java deleted file mode 100644 index 5fa290c..0000000 --- a/src/xid/IdDataCore.java +++ /dev/null @@ -1,18 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/* - * Xid uses three class to describe data: - * - TagData - * - TagsData - * - TagsDataById - * Others class that doesn't extends these won't be use by Xid. - * - * This interface helps to express this fact. - * - */ -public interface IdDataCore -{ -} diff --git a/src/xid/IdsDataById.java b/src/xid/IdsDataById.java deleted file mode 100644 index e9f1d1c..0000000 --- a/src/xid/IdsDataById.java +++ /dev/null @@ -1,40 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/* - * - */ -public class IdsDataById extends HashMap implements IdDataCore -{ - /* - * - */ - public IdsDataById () - { - super (); - } - - /* - * - */ - public void setId (String id, IdDataCore data) - { - this.put (id, data); - } - - /* - * - */ - public IdDataCore getId (String id) - { - IdDataCore result; - - result = this.get (id); - - // - return (result); - } - -} diff --git a/src/xid/IdsDataByIndex.java b/src/xid/IdsDataByIndex.java deleted file mode 100644 index 5466783..0000000 --- a/src/xid/IdsDataByIndex.java +++ /dev/null @@ -1,18 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/* - * - */ -public class IdsDataByIndex extends Vector implements IdDataCore -{ - /** - * - */ - public IdsDataByIndex () - { - super (); - } -} diff --git a/src/xid/ParserErrorHandler.java b/src/xid/ParserErrorHandler.java deleted file mode 100644 index 83b0e3e..0000000 --- a/src/xid/ParserErrorHandler.java +++ /dev/null @@ -1,159 +0,0 @@ -package xid; - -import org.xml.sax.*; -import java.util.*; - -/** - * Extract from org.xml.sax Interface ErrorHandler: - * "If a SAX application needs to implement customized error handling, - * it must implement this interface and then register an instance with - * the XML reader using the setErrorHandler method. The parser will - * then report all errors and warnings through this interface." - * - */ -public class ParserErrorHandler implements ErrorHandler -{ - Vector messages; - int fatalErrorsCount; - int errorsCount; - int warningCount; - - public ParserErrorHandler () - { - fatalErrorsCount = 0; - errorsCount = 0; - warningCount = 0; - messages = new Vector (); - } - - - /** - * - */ - public int fatalErrorsCount () - { - int result; - - result = this.fatalErrorsCount; - - // - return (result); - } - - /** - * - */ - public int errorsCount () - { - int result; - - result = this.errorsCount; - - // - return (result); - } - - /** - * - */ - public int warningCount () - { - int result; - - result = this.warningCount; - - // - return (result); - } - - /** - * - */ - public int allErrorsCount () - { - int result; - - result = fatalErrorsCount () + errorsCount () + warningCount (); - - // - return (result); - } - - /** - * - */ - public boolean hasError () - { - boolean result; - - if (allErrorsCount () == 0) - { - result = false; - } - else - { - result = true; - } - - // - return (result); - } - - - /** - * Called by the XML parser to handle fatal errors. - * @param ex Parse Excpetion. Contains the warning text and the line number. - */ - public void error (SAXParseException exception) - { - String message = "Error at line " + exception.getLineNumber() + " : " + exception.getMessage(); - - this.errorsCount += 1; - this.messages.add (message); - } - - /** - * Called by the XML parser to handle fatal errors. - * @param ex Parse Excpetion. Contains the error text and the line number. - * When a fatal parse error occurs, the parse does not return a document. - */ - public void fatalError (SAXParseException exception) - { - String message = "Fatal error at line " + exception.getLineNumber() + " : " + exception.getMessage(); - - this.fatalErrorsCount += 1; - this.messages.add (message); - } - - /** - * Called by the XML parser to handle warnings. - * @param ex Parse Excpetion. Contains the warning text and the line number. - */ - public void warning(SAXParseException exception) - { - String message = "Warning at line " + exception.getLineNumber() + " : " + exception.getMessage(); - - this.warningCount += 1; - this.messages.add (message); - } - - - /** - * - */ - public String toString () - { - StringBuffer result; - - result = new StringBuffer (); - - for (String message : messages) - { - result.append (message); - result.append ('\n'); - } - - // - return (result.toString ()); - } -} diff --git a/src/xid/Presenter.java b/src/xid/Presenter.java deleted file mode 100644 index 60f5517..0000000 --- a/src/xid/Presenter.java +++ /dev/null @@ -1,1330 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; -import javax.xml.parsers.*; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import org.xml.sax.*; -import org.w3c.dom.*; -/** - * - */ -public class Presenter -{ - static final public char INDEX_SEPARATOR = '_'; - - static protected org.apache.log4j.Logger log; - static - { - log = org.apache.log4j.Logger.getLogger (Presenter.class); - } - - static protected String staticRootPath; - static - { - staticRootPath = null; - } - - - /* - * - */ - static public void setStaticRootPath (String path) - { - Presenter.staticRootPath = path; - } - - - /* - * - */ - static public String getStaticRootPath () - { - String result; - - result = Presenter.staticRootPath; - - // - return (result); - } - - /* - * Xid a file with data. - */ - static public StringBuffer doXid (Document doc, IdsDataById datas, String webappPath, StringBuffer errorOutput) - { - return (doXid (doc, datas, null, webappPath, errorOutput)); - } - - /* - * Xid a file with data. - */ - static public StringBuffer doXid (Document doc, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - result = Presenter.process (doc, datas, tagsData, webappPath, errorOutput); - - // - return (result); - } - - - /* - * - */ - static public String getClassAttributeValue (Node node) - { - String result; - - NamedNodeMap attributes = node.getAttributes (); - if (attributes == null) - { - result = null; - } - else - { - Node nameAttribute = attributes.getNamedItem ("class"); - - if (nameAttribute == null) - { - result = null; - } - else - { - result = nameAttribute.getNodeValue (); - } - } - - // - return (result); - } - - - /** - * - */ - static public Attributes mergeAttributes (Attributes target, Attributes source) - { - Attributes result; - - // - if (target == null) - { - result = source; - } - else if (source == null) - { - result = target; - } - else - { - result = new Attributes (target); - - Iterator iterator = source.entrySet().iterator(); - - while (iterator.hasNext()) - { - Map.Entry attribute = (Map.Entry) iterator.next(); - - String currentValue = target.get (attribute.getKey ()); - - if (currentValue == null) - { - result.put (attribute.getKey (), attribute.getValue ()); - } - else if (attribute.getKey ().equals ("style")) - { - result.put (attribute.getKey (), currentValue + attribute.getValue ()); - } - else - { - result.put (attribute.getKey (), attribute.getValue ()); - } - } - } - - // - return (result); - } - - /* - * - */ - static protected StringBuffer processChildren (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - result = processChildren (node, datas, tagsData, webappPath, "", errorOutput); - - // - return (result); - } - - - /* - * - */ - static protected StringBuffer processChildren (Node node, - IdsDataById datas, - TagsDataById tagsData, - String webappPath, - String suffix, - StringBuffer errorOutput) - { - StringBuffer result; - result = new StringBuffer (); - - // Get the iteration strategy. - IdData.IterationStrategy strategy; - - NamedNodeMap attributes = node.getAttributes (); - if (attributes == null) - { - strategy = IdData.IterationStrategy.ALL_ROWS; - } - else - { - Node id = attributes.getNamedItem ("id"); - - if (id == null) - { - strategy = IdData.IterationStrategy.ALL_ROWS; - } - else - { - IdDataCore dataCore = datas.getId (id.getNodeValue ()); - if (dataCore == null) - { - strategy = IdData.IterationStrategy.ALL_ROWS; - } - else if (dataCore instanceof IdData) - { - IdData data = (IdData) dataCore; - strategy = data.getIterationStrategy (); - } - else - { - strategy = IdData.IterationStrategy.ALL_ROWS; - } - } - } - - - // Iterate. - NodeList children = node.getChildNodes(); - int childrenCount = children.getLength (); - - switch (strategy) - { - case ONLY_FIRST_ROW: - int lineCounter = 0; - for (int childIndex = 0; childIndex < childrenCount; childIndex++) - { - if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE) - { - lineCounter += 1; - if (lineCounter == 1) - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - else - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - break; - - case ONLY_FIRST_TWO_ROWS: - lineCounter = 0; - for (int childIndex = 0; childIndex < childrenCount; childIndex++) - { - if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE) - { - lineCounter += 1; - - if ((lineCounter == 1) || (lineCounter == 2)) - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - else - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - break; - - case ONLY_ROWS_WITH_ID: - for (int childIndex = 0; childIndex < childrenCount; childIndex++) - { - if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE) - { - NamedNodeMap attrs2 = children.item (childIndex).getAttributes (); - - if ((attrs2 != null) && - (attrs2.getNamedItem ("id") != null)) - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - else - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - break; - - case ONLY_ROWS_WITHOUT_ID: - for (int childIndex = 0; childIndex < childrenCount; childIndex++) - { - if (children.item (childIndex).getNodeType () == Node.ELEMENT_NODE) - { - NamedNodeMap attrs2 = children.item (childIndex).getAttributes (); - if ((attrs2 == null) || - (attrs2.getNamedItem ("id") == null)) - { - result.append (process (children.item(childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - else - { - result.append (process (children.item (childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - } - break; - - case ALL_ROWS: - for (int childIndex = 0; childIndex < childrenCount; childIndex++) - { - result.append (process (children.item(childIndex), datas, tagsData, webappPath, suffix, errorOutput)); - } - break; - } - - // - return (result); - } - - - - /** - * Includes another file into the current page. - * - * @param node - * @param attrMap - * @param idAttr - */ - static protected StringBuffer processObjectTag (Node node, - NamedNodeMap attrMap, - Node idAttr, - IdsDataById datas, - TagsDataById tagsData, - String webappPath, - StringBuffer errorOutput) - { - StringBuffer result; - - result = new StringBuffer (); - - // Find codetype. - String codetype; - if (attrMap == null) - { - codetype = null; - } - else if (attrMap.getNamedItem ("codetype") == null) - { - codetype = null; - } - else - { - codetype = attrMap.getNamedItem ("codetype").getNodeValue (); - } - - // Check tag requirements. - if ((attrMap == null) || - (codetype == null) || - (!codetype.equals ("application/xid")) || - (attrMap.getNamedItem ("data") == null)) - { - // STU: do default action. - Presenter.processElementBasically (node, datas, tagsData, webappPath, errorOutput); - } - else - { - log.debug ("object action"); - result.append (""); - - // Build the file name. - String htmlFileName = webappPath + attrMap.getNamedItem ("data").getNodeValue (); - - - // Load file in tree. - Document childDoc = null; - try - { - childDoc = fileToTree (htmlFileName, errorOutput); - } - catch (Exception ex) - { - errorOutput.append ("unable to build the file tree"); - log.debug ("unable to build the file tree"); - } - - // Extract the 'body' section. - Node body = null; - try - { - NodeList nodes = childDoc.getElementsByTagName ("body"); - - if (nodes.getLength () == 0) - { - errorOutput.append ("no body tag in include html"); - log.debug ("no body tag in include html"); - } - else - { - body = nodes.item(0); - } - } - catch (Exception e) - { - errorOutput.append ("error getting child"); - log.debug ("error getting child"); - } - - // Process the body child as part of the primary tree. - if (body == null) - { - errorOutput.append ("xid object body empty."); - } - else - { - NodeList bodyChildren = body.getChildNodes (); - - if (bodyChildren != null) - { - int childCount = bodyChildren.getLength (); - for (int childCounter = 0; childCounter < childCount; childCounter++) - { - result.append (process (bodyChildren.item (childCounter), datas, tagsData, webappPath, errorOutput)); - } - } - } - - // - result.append (""); - } - log.debug ("end of object action"); - // - return (result); - } - - - - /** - * Processes a node that has dynamic content. Calls the appropriate code - * generator method, depending on the tag. - * - * @param node - * Current node. - * @param attrs - * The tag attributes. - * @param idAttr - * The ID. - */ - static protected StringBuffer processElementWithId (Node node, - NamedNodeMap attrs, - Node idAttr, - IdsDataById datas, - String webappPath, - StringBuffer errorOutput) - - { - StringBuffer result; - - result = processElementWithId (node, attrs, idAttr, datas, null, "", webappPath, errorOutput); - - // - return (result); - } - - - /** - * Processes a node that has dynamic content. Calls the appropriate code - * generator method, depending on the tag. - * - * @param node - * Current node. - * @param attrs - * The tag attributes. - * @param idAttr - * The ID. - */ - static protected StringBuffer processElementWithId (Node node, - NamedNodeMap attrs, - Node idAttr, - IdsDataById datas, - TagsDataById tagsData, - String webappPath, - String suffix, - StringBuffer errorOutput) - { - StringBuffer result; - result = new StringBuffer (); - - String tag = node.getNodeName(); - - if (tag.equals ("object")) - { - result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput)); - } - else - { - String idValue = idAttr.getNodeValue(); - - log.debug ("tag=" + tag); - - // Get data of this id. - IdDataCore dataCore = datas.get (idAttr.getNodeValue ()); - - if (dataCore == null) - { - result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput)); - } - else if (dataCore instanceof IdData) - { - IdData data = (IdData) dataCore; - - String theClass; - if (data == null) - { - theClass = null; - } - else - { - theClass = data.getAttributes ().getAttribute ("class"); - } - - if ((theClass == null) || - (!theClass.equals ("xid:nodisplay"))) - { - // Open the tag. - result.append ("<"); - result.append (node.getNodeName()); - - // Build attributes. - Attributes tagAttributes; - if (tagsData == null) - { - tagAttributes = null; - } - else - { - TagData tagData = tagsData.getId (node.getNodeName ()); - if (tagData == null) - { - tagAttributes = null; - } - else - { - tagAttributes = tagData.getAttributes (); - } - } - - result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, suffix)); - - if ((node.getChildNodes () == null) && - ((data == null) || (data.display () == null))) - { - // Close the tag. - result.append (" />"); - } - else - { - result.append ('>'); - - // CHANGED, cpm: - - // Insert data. - if ((data == null) || - (data.display () == null)) - { - result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput)); - } - else - { - result.append (data.display ()); - } - - // Close the tag. - result.append ("'); - } - } - } - else if (dataCore instanceof IdsDataByIndex) - { - IdsDataByIndex tags = (IdsDataByIndex) dataCore; - - int nbLines = tags.size (); - for (int nLine = 0; nLine < nbLines; nLine++) - { - if (tags.elementAt (nLine) instanceof IdData) - { - IdData data = (IdData) tags.elementAt (nLine); - - // Open the tag. - result.append ("<"); - result.append (node.getNodeName()); - - // Build attributes. - Attributes tagAttributes; - if (tagsData == null) - { - tagAttributes = null; - } - else - { - TagData tagData = tagsData.getId (node.getNodeName ()); - if (tagData == null) - { - tagAttributes = null; - } - else - { - tagAttributes = tagData.getAttributes (); - } - } - - result.append (processAttributes (attrs, data.getAttributes (), tagAttributes, Integer.toString (nLine))); - - if ((node.getChildNodes () == null) && - ((data == null) || (data.display () == null))) - { - // Close the tag. - result.append (" />\n"); - } - else - { - result.append ('>'); - - - // CHANGED, cpm - - // Insert data. - if ((data == null) || (data.display () == null)) - { - result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput)); - } - else - { - result.append (data.display ()); - } - - // Close the tag. - result.append ("\n"); - } - } - else - { - // Manage a Hashmap. - IdsDataById data = (IdsDataById) tags.elementAt (nLine); - - result.append (Presenter.processElementWithId (node, attrs, idAttr, data, tagsData, webappPath, Integer.toString (nLine), errorOutput)); - result.append ('\n'); - } - } - } - else - { - log.warn ("Unknow type of IdDataId"); - } - } - - // - log.debug ("Exit"); - return (result); - } - - - - /** - * - */ - static protected StringBuffer process (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - result = Presenter.process (node, datas, tagsData, webappPath, "", errorOutput); - - // - return (result); - } - - - /** - * Recursive method that processes a node and any child nodes. - * - */ - static protected StringBuffer process (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, String suffix, StringBuffer errorOutput) - { - log.debug ("Enter"); - String TRANSITIONAL_DTD = "xhtml1-transitional.dtd"; - String TRANSITIONAL_DOCTYPE = "\n"; - - StringBuffer result; - result = new StringBuffer (); - - // Is there anything to do? - if (node != null) - { - log.debug ("nodeName=" + node.getNodeName ()); - // Find the name attribute value. - String name; - name = getClassAttributeValue (node); - - if ((name == null) || - ((name != null) && - (!name.equals ("xid:nodisplay")))) - { - int type = node.getNodeType(); - switch (type) - { - case Node.DOCUMENT_NODE: - { - log.debug ("case Node.DOCUMENT_NODE"); - DocumentType dt = ((Document) node).getDoctype(); - - if (dt != null) - { - String publicId = dt.getPublicId(); - String systemId = dt.getSystemId(); - - if (systemId.equals(TRANSITIONAL_DTD)) - { - result.append(TRANSITIONAL_DOCTYPE); - } - - // Log.write(Log.TRACE,"publicId = " + publicId); - // Log.write(Log.TRACE,"systemId = " + systemId); - } - - result.append (Presenter.process (((Document) node).getDocumentElement(), datas, tagsData, webappPath, suffix, errorOutput)); - - break; - } - - case Node.ELEMENT_NODE: - { - log.debug ("case Node.ELEMENT_NODE"); - - NamedNodeMap attrs = node.getAttributes (); - Node idAttr = attrs.getNamedItem ("id"); - - if (idAttr != null) - { - result.append (Presenter.processElementWithId (node, - attrs, - idAttr, - datas, - tagsData, - webappPath, - suffix, - errorOutput)); - } - else - { - - String tag = node.getNodeName(); - - if (tag.equals ("object")) - { - result.append (processObjectTag (node, attrs, idAttr, datas, tagsData, webappPath, errorOutput)); - } - else - { - result.append (Presenter.processElementBasically (node, datas, tagsData, webappPath, suffix, errorOutput)); - } - } - - break; - } - - // handle entity reference nodes - case Node.ENTITY_REFERENCE_NODE: - { - log.debug ("case Node.ENTITY_REFERENCE_NODE"); - - result.append ('&'); - result.append (node.getNodeName()); - result.append (';'); - break; - } - - // print cdata sections - case Node.CDATA_SECTION_NODE: - { - log.debug ("case Node.CDATA_SECTION_NODE"); - - result.append (""); - - break; - } - - // print text - case Node.TEXT_NODE: - { - log.debug ("case Node.TEXTE_NODE"); - result.append (restoreEntities (new StringBuffer(node.getNodeValue()))); - break; - } - - // print processing instruction - case Node.PROCESSING_INSTRUCTION_NODE: - { - log.debug ("Node.PROCESSING_INSTRUCTION_NODE"); - - result.append (" 0)) - { - result.append (' '); - result.append (data); - } - result.append ("?>"); - break; - } - } - } - } - - // - //log.info ("result=" + result); - log.debug ("Exit"); - return (result); - } - - - /* - * - */ - static StringBuffer processElementBasically (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - result = processElementBasically (node, datas, tagsData, webappPath, "", errorOutput); - - // - return (result); - } - - - /* - * - */ - static StringBuffer processElementBasically (Node node, IdsDataById datas, TagsDataById tagsData, String webappPath, String suffix, StringBuffer errorOutput) - { - StringBuffer result; - result = new StringBuffer (); - - // Open the tag. - result.append ('<'); - result.append (node.getNodeName()); - - // Build the tag attributes. - Attributes tagAttributes; - if (tagsData == null) - { - tagAttributes = null; - } - else - { - TagData tagData = tagsData.getId (node.getNodeName ()); - if (tagData == null) - { - tagAttributes = null; - } - else - { - tagAttributes = tagData.getAttributes (); - } - } - - result.append (processAttributes (node.getAttributes (), - tagAttributes, - null, - suffix)); - - // - if (node.getChildNodes () == null) - { - result.append(" />"); - } - else - { - result.append('>'); - - result.append (processChildren (node, datas, tagsData, webappPath, suffix, errorOutput)); - - result.append("'); - } - - - // - return (result); - } - - - - /* - * - */ - static protected Document buildTree (InputStream source, StringBuffer errorOutput) - { - Document result; - - try - { - // Create a DocumentBuilderFactory and configure it. - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance (); - - // Set various configuration options. - dbf.setValidating (true); - dbf.setIgnoringComments (true); - dbf.setIgnoringElementContentWhitespace (false); - dbf.setCoalescing (false); - - // Keep entity references as they are. - dbf.setExpandEntityReferences(false); - - // Create a DocumentBuilder that satisfies the constraints - // specified by the DocumentBuilderFactory. - DocumentBuilder db = dbf.newDocumentBuilder (); - - ParserErrorHandler errorHandler; - errorHandler = new ParserErrorHandler(); - - // Set the error handler. - db.setErrorHandler (errorHandler); - - Schema schema = db.getSchema (); - log.debug ("schema=" + schema); - - // Parse the input file. - result = db.parse (source); - - if (errorHandler.hasError ()) - { - errorOutput.append (errorHandler.toString ()); - } - else - { - DomPresenter.addMetaTag (result, "generator", "XID 0.0"); - } - } - catch (ParserConfigurationException exception) - { - String errorMessage = "Parser configuration exception: " + exception.getMessage (); - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - catch (SAXException exception) - { - String errorMessage = "Error during SAX parsing: " + exception.getMessage (); - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - catch (IOException exception) - { - String errorMessage = "IOError during parsing." + exception.getMessage (); - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - - // - return (result); - } - - - - - /* - * - */ - static protected void addMetaTag (Document doc, String name, String content) - { - // Find head tag. - - Node headNode = Presenter.findHeadNode (doc); - - Node metaNode = doc.createElement ("meta"); - - NamedNodeMap attrMap = metaNode.getAttributes(); - Node attrNode = doc.createAttribute("name"); - attrMap.setNamedItem(attrNode); - attrNode.setNodeValue(name); - - attrNode = doc.createAttribute("content"); - attrMap.setNamedItem(attrNode); - attrNode.setNodeValue(content); - headNode.insertBefore(metaNode, headNode.getFirstChild()); - } - - - /** - * Finds the node containing the <head> tag. - * - * @param node - * Document node. - * @return The head tag node - */ - static protected Node findHeadNode (Node node) - { - Node headNode = null; - - int type = node.getNodeType(); - switch (type) - { - // print document - case Node.DOCUMENT_NODE: - { - headNode = findHeadNode(((Document) node).getDocumentElement()); - break; - } - - case Node.ELEMENT_NODE: - { - String tag = node.getNodeName(); - - if ("head".equals(tag)) - { - headNode = node; - break; - } - - NodeList children = node.getChildNodes(); - int numChildren = 0; - - if (children != null) - numChildren = children.getLength(); - - for (int i = 0; i < numChildren; i++) - { - headNode = findHeadNode(children.item(i)); - if (headNode != null) - break; - } - break; - } - } - return headNode; - } - - - /** - * Any ampersand lt;, ampersand gt; and ampersand amp; sequences in text - * nodes get read in as symbols. This method converts them back to entities. - * - * @param s String that is to have the entities restored.. - * @return The processed string. - */ - static public String restoreEntities (StringBuffer s) - { - String result; - - if (s == null) - { - result = null; - } - else - { - StringBuffer str = new StringBuffer(); - - int len = (s != null) ? s.length() : 0; - for (int i = 0; i < len; i++) - { - char ch = s.charAt(i); - switch (ch) - { - case '<': - { - str.append("<"); - break; - } - - case '>': - { - str.append(">"); - break; - } - - case '&': - { - str.append("&"); - break; - } - - default: - { - str.append(ch); - } - } - } - result = str.toString (); - } - - - // - return (result); - } - - - /** - * Get the text for an element. Converts new lines to spaces. - * - * @param node - */ - static protected String getElementText (Node node) - { - String result; - result = ""; // Grrrr, Java ... - - NodeList children = node.getChildNodes(); - if (children == null) - { - result = ""; - } - else - { - boolean ended = false; - int childCounter = 0; - int childCount = children.getLength (); - while (!ended) - { - if (childCounter >= childCount) - { - ended = true; - result = ""; - } - else - { - Node child = children.item (childCounter); - if (child.getNodeType () == Node.TEXT_NODE) - { - result = newLinesToSpaces (child.getNodeValue ()); // STU (+=, newLines...) - ended = true; - } - else - { - childCounter += 1; - } - } - } - } - - // - return (result); - } - - - /** - * Converts New Line characters to spaces. This is used when for example - * the text in a div tag goes over serveral lines. - * - * @param text String - * @return String - */ - static protected String newLinesToSpaces (String text) - { - StringBuffer result = new StringBuffer (text); - - for (int i = 0; i < result.length(); i++) - { - if (result.charAt (i) == '\n') - { - result.setCharAt (i,' '); - } - } - - // - return (result.toString()); - } - - - /* - * - */ - static protected StringBuffer processAttributes (NamedNodeMap attrs, Attributes dataAttributes, Attributes namedDataAttributes, String suffix) - { - StringBuffer result; - - result = processAttributes (attrs, mergeAttributes (dataAttributes, namedDataAttributes), suffix); - - // - return (result); - } - - - /* - * - */ - static protected StringBuffer processAttributes (NamedNodeMap attrs, Attributes dataAttributes) - { - StringBuffer result; - - result = processAttributes (attrs, dataAttributes, ""); - - // - return (result); - } - - - /* - * - */ - static protected StringBuffer processAttributes (NamedNodeMap attrs) - { - StringBuffer result; - - result = processAttributes (attrs, null, null, ""); - - // - return (result); - } - - - /* - * - */ - static protected StringBuffer processAttributes (NamedNodeMap attrs, Attributes dataAttributes, String suffix) - { - StringBuffer result; - - result = new StringBuffer (); - - // Build the original attributes list. - HashMap mergedAttributes; - mergedAttributes = new HashMap (); - for (int attributeCounter = 0; attributeCounter < attrs.getLength(); attributeCounter++) - { - Attr attr = (Attr) attrs.item (attributeCounter); - mergedAttributes.put (attr.getNodeName(), attr.getNodeValue ()); - } - - - // Put model attributes in the merged attributes list. - if (dataAttributes != null) - { - Iterator iterator = dataAttributes.entrySet().iterator(); - - while (iterator.hasNext()) - { - Map.Entry attribute = (Map.Entry) iterator.next(); - - if (mergedAttributes.containsKey (attribute.getKey ())) - { - if (attribute.getKey ().equalsIgnoreCase ("style")) - { - mergedAttributes.put (attribute.getKey (), mergedAttributes.get (attribute.getKey ()) + attribute.getValue ()); - } - else - { - mergedAttributes.put (attribute.getKey (), attribute.getValue ()); - } - } - else - { - mergedAttributes.put (attribute.getKey (), attribute.getValue ()); - } - } - } - - // Display the attributes - Iterator iterator = mergedAttributes.entrySet().iterator(); - while (iterator.hasNext ()) - { - Map.Entry attribute = (Map.Entry) iterator.next(); - - if ((attribute.getKey ().equals ("id")) && (suffix.length () != 0)) - { - result.append(" " + attribute.getKey () + "=\"" + attribute.getValue () + Presenter.INDEX_SEPARATOR + suffix + "\""); - } - else - { - result.append(" " + attribute.getKey () + "=\"" + attribute.getValue ()+ "\""); - } - } - - // - return (result); - } - - - /* - * - */ - static public String extractBodyContent (StringBuffer data) - { - String result = null; - - // Extract the body content. - String dataLowerCase = data.toString ().toLowerCase (); - - int startBody = dataLowerCase.indexOf (""); - int endBody = dataLowerCase.indexOf (""); - - // Note: as failed search is improbable, no care about complexity - // in failed search case. - if ((startBody == -1) || (endBody == -1)) - { - result = null; - } - else - { - result = data.substring (startBody + 6, endBody).trim (); - } - - // - return (result); - } - - - /* - * Define in Presnter cause needs this possibility. - */ - static protected Document fileToTree (String fileName, StringBuffer errorOutput) - { - Document result; - - try - { - result = buildTree (new FileInputStream (new File (fileName)), errorOutput); - } - catch (IOException exception) - { - String errorMessage = "IOError during parsing." + exception.getMessage (); - errorOutput.append (errorMessage); - log.error (errorMessage); - result = null; - } - - // - return (result); - } -} diff --git a/src/xid/StringPresenter.java b/src/xid/StringPresenter.java deleted file mode 100644 index c82fb4c..0000000 --- a/src/xid/StringPresenter.java +++ /dev/null @@ -1,198 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; -import javax.xml.parsers.*; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import org.xml.sax.*; -import org.w3c.dom.*; -/** - * - */ -public class StringPresenter extends DomPresenter -{ - static protected org.apache.log4j.Logger log; - static - { - log = org.apache.log4j.Logger.getLogger (StringPresenter.class); - } - - protected String html; - - /* - * - */ - public StringPresenter () - { - super (); - this.webappPath = Presenter.staticRootPath; - this.doc = null; - this.html = null; - } - - - /* - * - */ - public StringPresenter (String html) - { - this.webappPath = Presenter.staticRootPath; - this.doc = null; - this.html = html; - } - - - /* - * - */ - public StringPresenter (String webappPath, String html) - { - if ((webappPath == null) || (webappPath.equals (""))) - { - this.webappPath = Presenter.staticRootPath; - } - else - { - this.webappPath = webappPath; - } - this.doc = null; - this.html = html; - } - - - /* - * - */ - public void setSource (String html) - { - this.html = html; - this.doc = null; - } - - - /* - * - */ - public String getSource () - { - String result; - - result = this.html; - - // - return (result); - } - - - /* - * - */ - public StringBuffer doXid (Data datas, StringBuffer errorOutput) - { - return (doXid (datas.getIdsDataById (), datas.getTagsDataById (), errorOutput)); - } - - /* - * - */ - public StringBuffer doXid (IdsDataById datas, TagsDataById tagsData, StringBuffer errorOutput) - { - StringBuffer result; - - if (this.doc == null) - { - // Build doc from this.html. - String htmlSource; - if ((this.html.startsWith ("")) || - (this.html.startsWith (""))) - { - htmlSource = html; - } - else - { - htmlSource = "\n" + html + ""; - } - - // StringBufferInputStream is deprecated so we use another solution. - // (see http://www.developpez.net/forums/archive/index.php/t-14101.html). - doc = buildTree (new ByteArrayInputStream (htmlSource.getBytes ()), errorOutput); - } - - StringBuffer htmlTarget; - htmlTarget = Presenter.doXid (doc, datas, tagsData, this.webappPath, errorOutput); - - if (htmlTarget == null) - { - result = null; - } - else if ((this.html.startsWith ("")) || - (this.html.startsWith (""))) - { - result = htmlTarget; - } - else - { - String bodyContent = extractBodyContent (htmlTarget); - - if (bodyContent == null) - { - result = null; - } - else - { - result = new StringBuffer (bodyContent); - } - } - - // - return (result); - } - - - /* - * - */ - static public StringBuffer doXid (String html, Data datas, StringBuffer errorOutput) - { - return (doXid (html, datas.getIdsDataById (), datas.getTagsDataById (), "", errorOutput)); - } - - - /* - * - */ - static public StringBuffer doXid (String html, Data datas, String webappPath, StringBuffer errorOutput) - { - return (doXid (html, datas.getIdsDataById (), datas.getTagsDataById (), webappPath, errorOutput)); - } - - - /* - * Xid a string with html in. - */ - static public StringBuffer doXid (String html, IdsDataById datas, String webappPath, StringBuffer errorOutput) - { - return (doXid (html, datas, null, webappPath, errorOutput)); - } - - - /* - * Xid a string with html in. - */ - static public StringBuffer doXid (String html, IdsDataById datas, TagsDataById tagsData, String webappPath, StringBuffer errorOutput) - { - StringBuffer result; - - StringPresenter presenter = new StringPresenter (webappPath, html); - - result = presenter.doXid (datas, tagsData, errorOutput); - - // - return (result); - } -} diff --git a/src/xid/TagData.java b/src/xid/TagData.java deleted file mode 100644 index 66b54f6..0000000 --- a/src/xid/TagData.java +++ /dev/null @@ -1,36 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/** - * IdData class is used to hold application data and - * the business logic that operates on the data. - * - * The only requirement of a IdData class is that it must implement a - * display method. The display method must return a text representation - * of the data, suitable for display in a web page. - * - * XID provides a User Input IdData, Text IdData and ... - * application may also implement it's own IdData classes. - * - */ -public class TagData extends IdData implements Serializable -{ - /* - * - */ - public TagData () - { - super (); - } - - - /* - * - */ - public TagData (String text) - { - super (text); - } -} diff --git a/src/xid/TagsDataById.java b/src/xid/TagsDataById.java deleted file mode 100644 index 8b7d47b..0000000 --- a/src/xid/TagsDataById.java +++ /dev/null @@ -1,40 +0,0 @@ -package xid; - -import java.util.*; -import java.io.*; - -/* - * - */ -public class TagsDataById extends HashMap -{ - /* - * - */ - public TagsDataById () - { - super (); - } - - /* - * - */ - public void setId (String id, TagData data) - { - this.put (id, data); - } - - /* - * - */ - public TagData getId (String id) - { - TagData result; - - result = this.get (id); - - // - return (result); - } - -} diff --git a/src/xid/testXid.html b/src/xid/testXid.html deleted file mode 100644 index 78a308e..0000000 --- a/src/xid/testXid.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - test - - - Test 01: No id attribute - XHTML: Hello world. - no Java code - Result: Hello world. - - Test 02: id attribute with empty model - XHTML: Hello world. - no Java code - Result: Hello world. - - - Test 03: model changing the text - XHTML: Hello world. - // Populate attributes of Test 03. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "totoClass"); - text.setText ("mummy"); - datas.put ("test03", text); - Result: Hello world. - - - Test 04: model changing title - XHTML: Hello world. - // Populate attributes of Test 04. - text = new TextModel (); - text.getAttributes ().setAttribute ("title", "another title"); - datas.put ("test04", text); - Result: Hello world. - - - Test 05: model adding style attributes - XHTML: Hello world. - // Populate attributes of Test 05. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test05", text); - Result: Hello world. - - - Test 06: model appending style attributes - XHTML: Hello world. - // Populate attributes of Test 06. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test06", text); - Result: Hello world. - - - Test 07: image - XHTML: A picture pinguoin flottant. - // Populate attributes of Test 07. - text = new TextModel (); - text.getAttributes ().setAttribute ("width", "50%"); - datas.put ("test07", text); - Result: A picture pinguoin flottant. - - - Test 08: xhtml source contains no display order in a tag. - XHTML: Hello you there. - Result: Hello you there. - - - Test 09: dynamic addition of the nodisplay order. - XHTML: Hello you there. - Result: Hello you there. - - - \ No newline at end of file diff --git a/src/xid/testXid.t b/src/xid/testXid.t deleted file mode 100644 index 9037424..0000000 --- a/src/xid/testXid.t +++ /dev/null @@ -1,69 +0,0 @@ - - - - test - - - Test 01: No id attribute - XHTML: Hello world. - no Java code - Result: Hello world. - - Test 02: id attribute with empty model - XHTML: Hello world. - no Java code - Result: Hello world. - - - Test 03: model changing the text - XHTML: Hello world. - // Populate attributes of Test 03. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "totoClass"); - text.setText ("mummy"); - datas.put ("test03", text); - Result: Hello world. - - - Test 04: model changing title - XHTML: Hello world. - // Populate attributes of Test 04. - text = new TextModel (); - text.getAttributes ().setAttribute ("title", "another title"); - datas.put ("test04", text); - Result: Hello world. - - - Test 05: model adding style attributes - XHTML: Hello world. - // Populate attributes of Test 05. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test05", text); - Result: Hello world. - - - Test 06: model appending style attributes - XHTML: Hello world. - // Populate attributes of Test 06. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test06", text); - Result: Hello world. - - - Test 07: image - XHTML: A picture pinguoin flottant. - // Populate attributes of Test 07. - text = new TextModel (); - text.getAttributes ().setAttribute ("width", "50%"); - datas.put ("test07", text); - Result: A picture pinguoin flottant. - - - \ No newline at end of file diff --git a/src/xid/xhtml-lat1.ent b/src/xid/xhtml-lat1.ent deleted file mode 100644 index ffee223..0000000 --- a/src/xid/xhtml-lat1.ent +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/xid/xhtml-special.ent b/src/xid/xhtml-special.ent deleted file mode 100644 index cead4e8..0000000 --- a/src/xid/xhtml-special.ent +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/xid/xhtml-symbol.ent b/src/xid/xhtml-symbol.ent deleted file mode 100644 index 63c2abf..0000000 --- a/src/xid/xhtml-symbol.ent +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/xid/xhtml1-frameset.dtd b/src/xid/xhtml1-frameset.dtd deleted file mode 100644 index 1a00936..0000000 --- a/src/xid/xhtml1-frameset.dtd +++ /dev/null @@ -1,1235 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/xid/xhtml1-transitional.dtd b/src/xid/xhtml1-transitional.dtd deleted file mode 100644 index e22581b..0000000 --- a/src/xid/xhtml1-transitional.dtd +++ /dev/null @@ -1,1210 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/xid/test/Test.java b/test/xid/test/Test.java deleted file mode 100644 index b12acf6..0000000 --- a/test/xid/test/Test.java +++ /dev/null @@ -1,237 +0,0 @@ -package xid.test; - -import java.util.*; -import java.io.*; -import xid.*; - -/** - * - */ -class Test -{ - static private org.apache.log4j.Logger log; - - static - { - // Initialize log. - org.apache.log4j.Logger log = null; - - org.apache.log4j.BasicConfigurator.configure (); - - - log = org.apache.log4j.Logger.getRootLogger (); - //log.setLevel (org.apache.log4j.Level.INFO); - log.setLevel (org.apache.log4j.Level.INFO); - - log.info ("Enter"); - - // - log.info ("Set the log file format..."); - - - // log = org.apache.log4j.Category.getInstance(Application.class.getName()); - log.info ("... done."); - - log.debug ("Exit"); - log = org.apache.log4j.Logger.getLogger (Test.class.getName ()); - } - - - - /** - * - */ - public static String check (String title, StringBuffer source, String model) - { - String result; - - if (source.indexOf (model) == -1) - { - result = String.format ("%-40s -> KO <-", title) + "\nGet:\n" + source + "\nWaiting:\n" + model; - - } - else - { - result = String.format ("%-40s [ OK ] ", title); - } - - - // - return (result); - } - - public enum MONTHS {JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBRE, DECEMBRE}; - - /** - * - */ - public static void main(String[] args) - { - System.out.println("Automatic test action for Xid!"); - - - Data datas; - IdData tag; - - - String htmlSource; - StringBuffer html; - StringBuffer errorMessage; - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("name", "Superman"); - errorMessage = new StringBuffer (); - - html = StringPresenter.doXid ("
a name
", datas, errorMessage); - - System.out.println (check ("only content change", html, "
Superman
")); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("lastname", "Spiderman"); - datas.appendAttribute ("lastname", "style", "background: blue;"); - datas.appendAttribute ("lastname", "style", "foreground: red;"); - datas.setAttribute ("lastname", "class", "nameClass"); - - errorMessage = new StringBuffer (); - html = StringPresenter.doXid ("
a last name
", datas, errorMessage); - System.out.println (check ("content and attributes", html, "
Spiderman
")); - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("words", 0, "alpha"); - datas.setContent ("words", 1, "bravo"); - datas.setContent ("words", 2, "charlie"); - datas.setContent ("words", 3, "delta"); - datas.setContent ("words", 4, "echo"); - datas.setContent ("words", 5, "fox"); - - - errorMessage = new StringBuffer (); - html = StringPresenter.doXid ("
    \n
  • a word
  • \n
", datas, errorMessage); - - System.out.println (check ("list assertion 1", html, "
  • alpha
  • ")); - System.out.println (check ("list assertion 2", html, "
  • bravo
  • ")); - System.out.println (check ("list assertion 3", html, "
  • charlie
  • ")); - System.out.println (check ("list assertion 4", html, "
  • delta
  • ")); - System.out.println (check ("list assertion 5", html, "
  • echo
  • ")); - System.out.println (check ("list assertion 6", html, "
  • fox
  • ")); - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("identity", 0, "nom", "Jemba"); - datas.setContent ("identity", 0, "prenom", "Epo"); - datas.setContent ("identity", 1, "nom", "Momon"); - datas.setContent ("identity", 1, "prenom", "Christian"); - datas.setContent ("identity", 2, "nom", "Tronche"); - datas.setContent ("identity", 2, "prenom", "Christophe"); - - - errorMessage = new StringBuffer (); - StringBuffer source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append ("
    noidun nomun prenom
    "); - htmlSource = source.toString (); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - - System.out.println (check ("table 1 assertion 1", html, "noidJembaEpo")); - System.out.println (check ("table 1 assertion 2", html, "noidMomonChristian")); - System.out.println (check ("table 1 assertion 3", html, "noidTroncheChristophe")); - - /* - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("identity", 0, "nom", "Jemba"); - datas.setContent ("identity", 0, "prenom", "Epo"); - datas.setContent ("identity", 1, "nom", "Momon"); - datas.setContent ("identity", 1, "prenom", "Christian"); - datas.setContent ("identity", 2, "nom", "Tronche"); - datas.setContent ("identity", 2, "prenom", "Christophe"); - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); - - - errorMessage = new StringBuffer (); - source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append (" \n"); - source.append (" \n"); - source.append ("
    noidun nomun prenom
    noidun nomun prenom
    noidun nomun prenom
    "); - htmlSource = source.toString (); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"identity\", 0, \"nom\", \"Jemba\");"); - System.out.println ("datas.setContent (\"identity\", 0, \"prenom\", \"Epo\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"nom\", \"Momon\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"prenom\", \"Christian\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"nom\", \"Tronche\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"prenom\", \"Christophe\");"); - - System.out.println ("+"); - System.out.println (htmlSource); - System.out.println ("=>"); - - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_FIRST_ROW); - System.out.println ("ONLY_FIRST_ROW:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); - System.out.println ("ONLY_ROWS_WITH_ID:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - System.out.println ("ONLY_ROWS_WITHOUT_ID:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); - System.out.println ("ALL_ROWS:"); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - System.out.println (html); - - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setAttribute ("
    ", "class", "aDivClass"); - datas.setAttribute ("
    ", "style", "background-color: #000000;"); - datas.setAttribute ("number", "style", "background-color: #0000FF;"); - - errorMessage = new StringBuffer (); - source = new StringBuffer (); - source.append ("
    \n"); - source.append ("

    one

    \n"); - source.append ("
    \n"); - source.append ("
    \n"); - source.append ("

    three

    \n"); - source.append ("
    "); - htmlSource = source.toString (); - html = Presenter.doXid (htmlSource, datas, "", errorMessage); - - System.out.println (htmlSource); - System.out.println ("+"); - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setAttribute (\"
    \", \"class\", \"aDivClass\");"); - System.out.println ("datas.setAttribute (\"
    \", \"style\", \"background-color: #000000;\");"); - System.out.println ("datas.setAttribute (\"number\", \"style\", \"background-color: #0000FF;\");"); - - System.out.println ("=>"); - System.out.println (html); - */ - } -} diff --git a/webapp-examples/WEB-INF/classes/build.xml b/webapp-examples/WEB-INF/classes/build.xml deleted file mode 100644 index 9405f9d..0000000 --- a/webapp-examples/WEB-INF/classes/build.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/webapp-examples/WEB-INF/classes/log4j.properties b/webapp-examples/WEB-INF/classes/log4j.properties deleted file mode 100644 index d23f58c..0000000 --- a/webapp-examples/WEB-INF/classes/log4j.properties +++ /dev/null @@ -1,9 +0,0 @@ -# Log information (priority setting : DEBUG < INFO < WARN < ERROR) -# ################ -log4j.rootCategory = INFO, Writer -log4j.appender.Writer = org.apache.log4j.RollingFileAppender -log4j.appender.Writer.File = /var/log/tomcat5/xid-test.log -log4j.appender.Writer.MaxFileSize = 100000KB -log4j.appender.Writer.MaxBackupIndex = 10 -log4j.appender.Writer.layout = org.apache.log4j.PatternLayout -log4j.appender.Writer.layout.ConversionPattern = %d{ISO8601} - %-17t %-6p %-34c.%20M - %m%n diff --git a/webapp-examples/WEB-INF/classes/testXid.t b/webapp-examples/WEB-INF/classes/testXid.t deleted file mode 100644 index 9037424..0000000 --- a/webapp-examples/WEB-INF/classes/testXid.t +++ /dev/null @@ -1,69 +0,0 @@ - - - - test - - - Test 01: No id attribute - XHTML: Hello world. - no Java code - Result: Hello world. - - Test 02: id attribute with empty model - XHTML: Hello world. - no Java code - Result: Hello world. - - - Test 03: model changing the text - XHTML: Hello world. - // Populate attributes of Test 03. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "totoClass"); - text.setText ("mummy"); - datas.put ("test03", text); - Result: Hello world. - - - Test 04: model changing title - XHTML: Hello world. - // Populate attributes of Test 04. - text = new TextModel (); - text.getAttributes ().setAttribute ("title", "another title"); - datas.put ("test04", text); - Result: Hello world. - - - Test 05: model adding style attributes - XHTML: Hello world. - // Populate attributes of Test 05. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test05", text); - Result: Hello world. - - - Test 06: model appending style attributes - XHTML: Hello world. - // Populate attributes of Test 06. - text = new TextModel (); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test06", text); - Result: Hello world. - - - Test 07: image - XHTML: A picture pinguoin flottant. - // Populate attributes of Test 07. - text = new TextModel (); - text.getAttributes ().setAttribute ("width", "50%"); - datas.put ("test07", text); - Result: A picture pinguoin flottant. - - - \ No newline at end of file diff --git a/webapp-examples/WEB-INF/classes/xid/Test.class b/webapp-examples/WEB-INF/classes/xid/Test.class deleted file mode 100644 index edb30be..0000000 Binary files a/webapp-examples/WEB-INF/classes/xid/Test.class and /dev/null differ diff --git a/webapp-examples/WEB-INF/classes/xid/Test.java b/webapp-examples/WEB-INF/classes/xid/Test.java deleted file mode 100644 index 20c2945..0000000 --- a/webapp-examples/WEB-INF/classes/xid/Test.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - */ -package xid; -import java.io.*; -import java.text.*; -import java.util.*; -import javax.servlet.*; -import javax.servlet.http.*; -import xid.*; - -/** - * - */ -public class Test extends HttpServlet -{ - static private org.apache.log4j.Logger log; - - static - { - log = org.apache.log4j.Logger.getLogger (Test.class.getName()); - } - - - /** - * - */ - public void doPost (HttpServletRequest req, - HttpServletResponse res) - throws ServletException, IOException - { - doGet (req, res); - } - - - - /** - * - */ - public void doGet (HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException - { - log.info ("Enter"); - - Presenter xid = new Presenter (getServletContext ().getRealPath ("/"), "testXid.html"); - - // - TagsData datas = new TagsData (); - TextTagData text; - - // Populate attributes of Test 03. - text = new TextTagData (); - datas.put ("test03", text); - text.setText ("mummy"); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "totoClass"); - - - // Populate attributes of Test 04. - text = new TextTagData (); - text.getAttributes ().setAttribute ("title", "another title"); - datas.put ("test04", text); - - - // Populate attributes of Test 05. - text = new TextTagData (); - datas.put ("test05", text); - text.getAttributes ().appendAttribute ("style", "background: blue;"); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - - - // Populate attributes of Test 06. - text = new TextTagData (); - text.getAttributes ().appendAttribute ("style", "foreground: red;"); - text.getAttributes ().setAttribute ("class", "aClass"); - datas.put ("test06", text); - - - // Populate attributes of Test 07. - text = new TextTagData (); - text.getAttributes ().setAttribute ("width", "50%"); - datas.put ("test07", text); - - - // Populate attributes of Test 09. - text = new TextTagData (); - text.getAttributes ().setAttribute ("class", "xid:nodisplay"); - datas.put ("test09", text); - - - StringBuffer html; - StringBuffer errorMessage; - - errorMessage = new StringBuffer (); - html = xid.doXid (datas, errorMessage); - - - // Display page. - response.setContentType ("text/html"); - PrintWriter out = response.getWriter(); - - out.println (""); - out.println (""); - out.println ("XID TEST"); - out.println (""); - out.println (""); - - out.println ("
    "); - out.println ("XID TEST
    "); - - if (errorMessage.length () != 0) - { - out.println ("An error occured in Xid treatment.
    "); - out.println ("
    ");
    -	out.println (errorMessage);
    -	out.println ("
    "); - out.println ("
    "); - out.println ("
    " + Presenter.restoreEntities (html) + "
    "); - out.println ("
    "); - } - else - { - out.println ("
    " + Presenter.restoreEntities (html) + "
    "); - } - - out.println (""); - out.println (""); - - log.info ("Exit"); - } -} - -// //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/webapp-examples/WEB-INF/lib/xid.jar b/webapp-examples/WEB-INF/lib/xid.jar deleted file mode 100644 index 0235c43..0000000 Binary files a/webapp-examples/WEB-INF/lib/xid.jar and /dev/null differ diff --git a/webapp-examples/WEB-INF/web.xml b/webapp-examples/WEB-INF/web.xml index b7eacff..2dff563 100644 --- a/webapp-examples/WEB-INF/web.xml +++ b/webapp-examples/WEB-INF/web.xml @@ -1,20 +1,11 @@ - - - - - + + XID TESTS Some tests on XID. - - - - XidTest