commit b1db8ddb595d15b0331fcba92c3ae82c70045944 Author: Christian P. MOMON Date: Fri Jan 12 06:35:01 2007 +0100 First commit. diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..783c08a --- /dev/null +++ b/build.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..e6bfbf4 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,12 @@ + +V_003: 12/03/2006 + - add build.xml file + - Vue class rename Presenter + - debug of object tag + - add webappPath capability + +V_004: 12/05/2006 + - + +20061214, cpm, import dans snv sur https://www.ocmland.org/svn/Xid + diff --git a/dist/xid.jar b/dist/xid.jar new file mode 100644 index 0000000..4b5fbe2 Binary files /dev/null and b/dist/xid.jar differ diff --git a/lib/activation.jar b/lib/activation.jar new file mode 100644 index 0000000..db4b1fb Binary files /dev/null and b/lib/activation.jar differ diff --git a/lib/log4j-1.2.14.jar b/lib/log4j-1.2.14.jar new file mode 100644 index 0000000..6251307 Binary files /dev/null and b/lib/log4j-1.2.14.jar differ diff --git a/lib/mail.jar b/lib/mail.jar new file mode 100644 index 0000000..eb2269d Binary files /dev/null and b/lib/mail.jar differ diff --git a/lib/servlet-api.jar b/lib/servlet-api.jar new file mode 100644 index 0000000..dd326d3 Binary files /dev/null and b/lib/servlet-api.jar differ diff --git a/resources/xhtml-lat1.ent b/resources/xhtml-lat1.ent new file mode 100644 index 0000000..ffee223 --- /dev/null +++ b/resources/xhtml-lat1.ent @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/xhtml-special.ent b/resources/xhtml-special.ent new file mode 100644 index 0000000..cead4e8 --- /dev/null +++ b/resources/xhtml-special.ent @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/xhtml-symbol.ent b/resources/xhtml-symbol.ent new file mode 100644 index 0000000..63c2abf --- /dev/null +++ b/resources/xhtml-symbol.ent @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/xhtml1-frameset.dtd b/resources/xhtml1-frameset.dtd new file mode 100644 index 0000000..1a00936 --- /dev/null +++ b/resources/xhtml1-frameset.dtd @@ -0,0 +1,1235 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/xhtml1-transitional.dtd b/resources/xhtml1-transitional.dtd new file mode 100644 index 0000000..e22581b --- /dev/null +++ b/resources/xhtml1-transitional.dtd @@ -0,0 +1,1210 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/xid/Attributes.java b/src/xid/Attributes.java new file mode 100644 index 0000000..a283778 --- /dev/null +++ b/src/xid/Attributes.java @@ -0,0 +1,70 @@ +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 (); + } + + + /* + * + */ + 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/ParserErrorHandler.java b/src/xid/ParserErrorHandler.java new file mode 100644 index 0000000..83b0e3e --- /dev/null +++ b/src/xid/ParserErrorHandler.java @@ -0,0 +1,159 @@ +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 new file mode 100644 index 0000000..db7a98b --- /dev/null +++ b/src/xid/Presenter.java @@ -0,0 +1,1029 @@ +/* + * + */ +package xid; +import java.util.*; +import java.io.*; +import javax.xml.parsers.*; +import javax.xml.validation.Schema; +import org.xml.sax.*; +import org.w3c.dom.*; +/** + * + */ +public class Presenter +{ + static protected org.apache.log4j.Logger log; + + static + { + log = org.apache.log4j.Logger.getLogger (Presenter.class.getName ()); + } + + protected String webappPath; + protected String sourceFileName; + protected long sourceFileTime; + protected Document doc; + + /* + * + */ + public Presenter () + { + this.webappPath = null; + this.sourceFileName = null; + this.sourceFileTime = 0; + this.doc = null; + } + + + /* + * + */ + public Presenter (String webappPath, String fileName) + { + this.webappPath = webappPath; + this.sourceFileName = fileName; + this.sourceFileTime = 0; + this.doc = null; + } + + + /* + * + */ + public String getWebappPath () + { + String result; + + result = this.webappPath; + + // + return (result); + } + + + /* + * + */ + 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 (TagsData datas, 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, this.webappPath, errorOutput); + + // + return (result); + } + + + /* + * + */ + 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, webappPath, errorOutput); + } + + // + return (result); + } + + + /* + * + */ + static public StringBuffer doXid (Document doc, TagsData datas, String webappPath, StringBuffer errorOutput) + { + StringBuffer result; + + result = Presenter.process (doc, datas, webappPath, errorOutput); + + // + return (result); + } + + /* + * + */ + static public StringBuffer doXid (String html, TagsData datas, String webappPath, StringBuffer errorOutput) + { + StringBuffer result; + + Document doc = null; + + + result = Presenter.process (doc, datas, 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 protected StringBuffer processChildren (Node node, TagsData datas, String webappPath, StringBuffer errorOutput) + { + StringBuffer result; + + result = new StringBuffer (); + + NodeList children = node.getChildNodes(); + + if (children == null) + { + result.append (" "); + } + else + { + int childrenCount = children.getLength (); + + for (int i = 0; i < childrenCount; i++) + { + result.append (process (children.item(i), datas, webappPath, errorOutput)); + } + } + + // + return (result); + } + + + + /** + * Includes another HSP file into the current page. + * + * @param node + * @param attrMap + * @param idAttr + */ + static protected StringBuffer processObjectTag (Node node, NamedNodeMap attrMap, Node idAttr, TagsData datas, 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, webappPath, errorOutput); + } + else + { + log.info ("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) + { + result.append ("unable to build the file tree"); + log.info ("unable to build the file tree"); + } + + // Extract the 'body' section. + Node body = null; + try + { + NodeList nodes = childDoc.getElementsByTagName ("body"); + + if (nodes.getLength () == 0) + { + result.append ("no body tag in include html"); + log.info ("no body tag in include html"); + } + else + { + body = nodes.item(0); + } + } + catch (Exception e) + { + result.append ("error getting child"); + log.info ("error getting child"); + } + + // Process the body child as part of the primary tree. + 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, webappPath, errorOutput)); + } + } + + // + result.append (""); + } + log.info ("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, + TagsData datas, + String webappPath, + StringBuffer errorOutput) + { + StringBuffer result; + result = new StringBuffer (); + + String tag = node.getNodeName(); + String idValue = idAttr.getNodeValue(); + + log.info ("tag=" + tag); + + // Get data of this id. + TagData data = datas.get (idAttr.getNodeValue ()); + String theClass; + if (data == null) + { + theClass = null; + } + else + { + theClass = data.getAttributes ().getAttribute ("class"); + } + + if ((theClass == null) || + (!theClass.equals ("xid:nodisplay"))) + { + if ((tag.equals ("a")) || + (tag.equals ("b")) || + (tag.equals ("div")) || + (tag.equals ("em")) || + (tag.equals ("p")) || + (tag.equals ("span"))) + { + // Open the tag. + result.append ('<'); + result.append (node.getNodeName()); + + // Build the tag attributes. + result.append (processAttributes (attrs, data)); + //result.append (attributesFromNode (attrs)); + //result.append (attributesFromTagData (data)); + + result.append ('>'); + + // Insert data. + if ((data == null) || + (data.display ().equals (""))) + { + result.append (processChildren (node, datas, webappPath, errorOutput)); + } + else + { + result.append (data.display ()); + } + + // Close the tag. + result.append ("'); + } + else if (tag.equals("img")) + { + // Possibility to merge with previous case if
is a correct tag. + + // Open the tag. + result.append ("<"); + result.append (node.getNodeName()); + + // Build the tag attributes. + result.append (processAttributes (attrs, data)); + //result.append (attributesFromNode (attrs)); + //result.append (attributesFromTagData (data)); + + result.append ("/>"); + } + else if (tag.equals("textarea")) + { + result.append ("[textarea]"); + } + else if (tag.equals("select")) + { + result.append ("[select]"); + } + else if (tag.equals("input")) + { + result.append ("[input]"); + } + else if (tag.equals("table")) + { + result.append ("[table]"); + } + else if (tag.equals("tbody")) + { + result.append ("[tbody]"); + } + else if (tag.equals("object")) + { + result.append (processObjectTag (node, attrs, idAttr, datas, webappPath, errorOutput)); + } + else + { + log.info ("Id on <" + tag + "> not supported."); + } + } + + // + log.info ("Exit"); + return (result); + } + + + + /** + * Recursive method that processes a node and any child nodes. + * + */ + static protected StringBuffer process (Node node, TagsData datas, String webappPath, StringBuffer errorOutput) + { + log.info ("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.info ("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.info ("case Node.DOCUMENT_NODE"); + DocumentType dt = ((Document) node).getDoctype(); + 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, webappPath, errorOutput)); + + break; + } + + case Node.ELEMENT_NODE: + { + log.info ("case Node.ELEMENT_NODE"); + + NamedNodeMap attrs = node.getAttributes (); + Node idAttr = attrs.getNamedItem ("id"); + + if (idAttr != null) + { + result.append (Presenter.processElementWithId (node, attrs, idAttr, datas, webappPath, errorOutput)); + } + else + { + result.append (Presenter.processElementBasically (node, datas, webappPath, errorOutput)); + } + + break; + } + + // handle entity reference nodes + case Node.ENTITY_REFERENCE_NODE: + { + log.info ("case Node.ENTITY_REFERENCE_NODE"); + + result.append ('&'); + result.append (node.getNodeName()); + result.append (';'); + break; + } + + // print cdata sections + case Node.CDATA_SECTION_NODE: + { + log.info ("case Node.CDATA_SECTION_NODE"); + + result.append (""); + + break; + } + + // print text + case Node.TEXT_NODE: + { + log.info ("case Node.TEXTE_NODE"); + result.append (restoreEntities (new StringBuffer(node.getNodeValue()))); + break; + } + + // print processing instruction + case Node.PROCESSING_INSTRUCTION_NODE: + { + log.info ("Node.PROCESSING_INSTRUCTION_NODE"); + + result.append (" 0)) + { + result.append (' '); + result.append (data); + } + result.append ("?>"); + break; + } + } + } + } + + // + //log.info ("result=" + result); + log.info ("Exit"); + return (result); + } + + + /* + */ + static StringBuffer processElementBasically (Node node, TagsData datas, String webappPath, StringBuffer errorOutput) + { + StringBuffer result; + result = new StringBuffer (); + + // Open the tag. + result.append ('<'); + result.append (node.getNodeName()); + + // Build the tag attributes. + NamedNodeMap attrs = node.getAttributes (); + if (attrs != null) + { + for (int i = 0; i < attrs.getLength(); i++) + { + Attr attr = (Attr) attrs.item(i); + result.append (' '); + result.append (attr.getNodeName()); + result.append ("=\""); + result.append (restoreEntities(new StringBuffer(attr.getNodeValue()))); + result.append ("\""); + } + + + // + NodeList children = node.getChildNodes(); + if (children == null) + { + result.append(" />"); + } + else + { + int childrenCount = children.getLength (); + + if (childrenCount == 0) + { + result.append(" />"); + } + else + { + result.append('>'); + + for (int i = 0; i < childrenCount; i++) + { + result.append (process (children.item(i), datas, webappPath, errorOutput)); + } + + result.append("'); + } + } + } + + + // + return (result); + } + + + + /* + * + */ + static protected Document fileToTree (String fileName, StringBuffer errorOutput) + { + Document result; + + File source = new File (fileName); + + if (source == null) + { + String errorMessage = "source file not defined (null)"; + errorOutput.append (errorMessage); + log.error (errorMessage); + result = null; + } + else if (!source.exists ()) + { + String errorMessage = "source file not found (" + fileName + ")"; + errorOutput.append (errorMessage); + log.error (errorMessage); + result = null; + } + else + { + 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.info ("schema=" + schema); + + // Parse the input file. + result = db.parse (fileName); + + if (errorHandler.hasError ()) + { + errorOutput.append (errorHandler.toString ()); + } + } + 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, TagData model) + { + 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 (model != null) + { + Attributes modelAttributes = model.getAttributes(); + + if (modelAttributes != null) + { + Iterator iterator = modelAttributes.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(); + result.append(" " + attribute.getKey () + "=\"" + attribute.getValue ()+ "\""); + } + + // + return (result); + } +} diff --git a/src/xid/TagData.java b/src/xid/TagData.java new file mode 100644 index 0000000..8e85d37 --- /dev/null +++ b/src/xid/TagData.java @@ -0,0 +1,110 @@ +package xid; + +import java.util.*; +import java.io.*; + +/** + * TagData class is used to hold application data and + * the business logic that operates on the data. + * + * The only requirement of a TagData 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 TagData, Text TagData and ... + * application may also implement it's own TagData classes. + * + */ +public abstract class TagData implements Serializable +{ + public enum MODE {REPLACE, APPEND, IGNORE}; + + protected Attributes attributes; + protected boolean excludeSection; + protected MODE displayMode = MODE.REPLACE; + + + /* + * + */ + public TagData () + { + attributes = null; + excludeSection = false; + displayMode = MODE.REPLACE; + } + + + /* + * + */ + public abstract String display(); + + + /* + * + */ + public void setDisplayMode(MODE displayMode) + { + this.displayMode = displayMode; + } + + + /* + * + */ + public MODE getDisplayMode() + { + MODE result; + + result = this.displayMode; + + return (result); + } + + /* + * ?? + */ + public String getValue() + { + return display(); + } + + + /* + * + */ + 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; + } + +} diff --git a/src/xid/TagsData.java b/src/xid/TagsData.java new file mode 100644 index 0000000..5cb5ee7 --- /dev/null +++ b/src/xid/TagsData.java @@ -0,0 +1,47 @@ +package xid; + +import java.util.*; +import java.io.*; + +/* + * + */ +public class TagsData extends HashMap +{ + /** + * + */ + public TagsData () + { + super (); + } + + + /* + * + */ + public void setId (String id, TagData data) + { + this.put (id, data); + } + + /* + * + */ + public TagData getId (String id) + { + TagData result; + + if (this.containsKey (id)) + { + result = this.get (id); + } + else + { + result = null; + } + + // + return (result); + } +} diff --git a/src/xid/TextTagData.java b/src/xid/TextTagData.java new file mode 100644 index 0000000..3bc920a --- /dev/null +++ b/src/xid/TextTagData.java @@ -0,0 +1,91 @@ +package xid; + +import java.io.*; + +/** + * This class can be used to set up text for display. + * + */ +public class TextTagData extends TagData implements Serializable +{ + private static final long serialVersionUID = -4117726979708043231L; + + protected String text; + + /** + * Constructs a TextTagData with the text supplied. + * + * @param text The text to be displayed. + */ + public TextTagData (String text) + { + super (); + this.text = text; + } + + + /* + * + */ + public TextTagData() + { + super(); + this.text = ""; + this.displayMode = MODE.IGNORE; + } + + + /** + * This method will be called by the View when it encounters + * an id for a TextTagData object. + */ + public String display () + { + String result; + + if (text == null) + { + result = ""; + } + else + { + result = this.text; + } + + // + return (result); + } + + + /** + * Allows the text content to be changed. + * @param text + */ + public void setText (String text) + { + this.text = text; + } + + + /** + * Returns the value as an int. + * + * @return The users input as an int or -1 if not a valid number. + */ + public int getValueAsInt() + { + int result; + + try + { + result = Integer.parseInt(text); + } + catch (NumberFormatException e) + { + result = -1; + } + + // + return (result); + } +} diff --git a/src/xid/testXid.html b/src/xid/testXid.html new file mode 100644 index 0000000..78a308e --- /dev/null +++ b/src/xid/testXid.html @@ -0,0 +1,79 @@ + + + + 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 new file mode 100644 index 0000000..9037424 --- /dev/null +++ b/src/xid/testXid.t @@ -0,0 +1,69 @@ + + + + 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 new file mode 100644 index 0000000..ffee223 --- /dev/null +++ b/src/xid/xhtml-lat1.ent @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/xid/xhtml-special.ent b/src/xid/xhtml-special.ent new file mode 100644 index 0000000..cead4e8 --- /dev/null +++ b/src/xid/xhtml-special.ent @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/xid/xhtml-symbol.ent b/src/xid/xhtml-symbol.ent new file mode 100644 index 0000000..63c2abf --- /dev/null +++ b/src/xid/xhtml-symbol.ent @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/xid/xhtml1-frameset.dtd b/src/xid/xhtml1-frameset.dtd new file mode 100644 index 0000000..1a00936 --- /dev/null +++ b/src/xid/xhtml1-frameset.dtd @@ -0,0 +1,1235 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/xid/xhtml1-transitional.dtd b/src/xid/xhtml1-transitional.dtd new file mode 100644 index 0000000..e22581b --- /dev/null +++ b/src/xid/xhtml1-transitional.dtd @@ -0,0 +1,1210 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp-examples/WEB-INF/classes/build.xml b/webapp-examples/WEB-INF/classes/build.xml new file mode 100644 index 0000000..9405f9d --- /dev/null +++ b/webapp-examples/WEB-INF/classes/build.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp-examples/WEB-INF/classes/log4j.properties b/webapp-examples/WEB-INF/classes/log4j.properties new file mode 100644 index 0000000..d23f58c --- /dev/null +++ b/webapp-examples/WEB-INF/classes/log4j.properties @@ -0,0 +1,9 @@ +# 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 new file mode 100644 index 0000000..9037424 --- /dev/null +++ b/webapp-examples/WEB-INF/classes/testXid.t @@ -0,0 +1,69 @@ + + + + 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 new file mode 100644 index 0000000..edb30be Binary files /dev/null and b/webapp-examples/WEB-INF/classes/xid/Test.class differ diff --git a/webapp-examples/WEB-INF/classes/xid/Test.java b/webapp-examples/WEB-INF/classes/xid/Test.java new file mode 100644 index 0000000..b9818ee --- /dev/null +++ b/webapp-examples/WEB-INF/classes/xid/Test.java @@ -0,0 +1,165 @@ +/* + * + */ +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"); + } + + + /* + * + */ + static public String extractBody (StringBuffer data) + { + String result = null; + + // Extraire le contenu du body. + String dataLowerCase = data.toString ().toLowerCase (); + + int startBody = dataLowerCase.indexOf ("") + 6; + 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, endBody).trim (); + } + + // + return (result); + } +} + +// //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/webapp-examples/WEB-INF/lib/activation.jar b/webapp-examples/WEB-INF/lib/activation.jar new file mode 100644 index 0000000..db4b1fb Binary files /dev/null and b/webapp-examples/WEB-INF/lib/activation.jar differ diff --git a/webapp-examples/WEB-INF/lib/log4j-1.2.14.jar b/webapp-examples/WEB-INF/lib/log4j-1.2.14.jar new file mode 100644 index 0000000..6251307 Binary files /dev/null and b/webapp-examples/WEB-INF/lib/log4j-1.2.14.jar differ diff --git a/webapp-examples/WEB-INF/lib/mail.jar b/webapp-examples/WEB-INF/lib/mail.jar new file mode 100644 index 0000000..eb2269d Binary files /dev/null and b/webapp-examples/WEB-INF/lib/mail.jar differ diff --git a/webapp-examples/WEB-INF/lib/servlet-api.jar b/webapp-examples/WEB-INF/lib/servlet-api.jar new file mode 100644 index 0000000..dd326d3 Binary files /dev/null and b/webapp-examples/WEB-INF/lib/servlet-api.jar differ diff --git a/webapp-examples/WEB-INF/lib/xid.jar b/webapp-examples/WEB-INF/lib/xid.jar new file mode 100644 index 0000000..4b5fbe2 Binary files /dev/null and b/webapp-examples/WEB-INF/lib/xid.jar differ diff --git a/webapp-examples/WEB-INF/web.xml b/webapp-examples/WEB-INF/web.xml new file mode 100644 index 0000000..b7eacff --- /dev/null +++ b/webapp-examples/WEB-INF/web.xml @@ -0,0 +1,35 @@ + + + + + + + XID TESTS + + Some tests on XID. + + + + + + + + + XidTest + xid.Test + + + XidTest + /test.xhtml + + + + + index.jsp + index.html + index.htm + + + diff --git a/webapp-examples/WEB-INF/web.xml.ori b/webapp-examples/WEB-INF/web.xml.ori new file mode 100644 index 0000000..4760079 --- /dev/null +++ b/webapp-examples/WEB-INF/web.xml.ori @@ -0,0 +1,249 @@ + + + + + + + + Servlet 2.4 Examples + + Servlet 2.4 Examples. + + + + + Servlet Mapped Filter + filters.ExampleFilter + + attribute + filters.ExampleFilter.SERVLET_MAPPED + + + + Path Mapped Filter + filters.ExampleFilter + + attribute + filters.ExampleFilter.PATH_MAPPED + + + + Request Dumper Filter + filters.RequestDumperFilter + + + + + Set Character Encoding + filters.SetCharacterEncodingFilter + + encoding + EUC_JP + + + + + Compression Filter + compressionFilters.CompressionFilter + + + compressionThreshold + 10 + + + debug + 0 + + + + + + Servlet Mapped Filter + invoker + + + Path Mapped Filter + /ledb-admin/* + + + + + + + + + + + + + listeners.ContextListener + + + listeners.SessionListener + + + + + + CompressionFilterTestServlet + compressionFilters.CompressionFilterTestServlet + + + HelloWorldExample + HelloWorldExample + + + RequestInfoExample + RequestInfoExample + + + RequestHeaderExample + RequestHeaderExample + + + RequestParamExample + RequestParamExample + + + CookieExample + CookieExample + + + SessionExample + SessionExample + + + + CompressionFilterTestServlet + /CompressionTest + + + HelloWorldExample + /servlet/HelloWorldExample + + + RequestInfoExample + /servlet/RequestInfoExample/* + + + RequestHeaderExample + /servlet/RequestHeaderExample + + + RequestParamExample + /servlet/RequestParamExample + + + CookieExample + /servlet/CookieExample + + + SessionExample + /servlet/SessionExample + + + + Example Security Constraint + + Protected Area + + /jsp/security/protected/* + + DELETE + GET + POST + PUT + + + + tomcat + role1 + + + + + + FORM + Example Form-Based Authentication Area + + /jsp/security/protected/login.jsp + /jsp/security/protected/error.jsp + + + + + + role1 + + + tomcat + + + + + + minExemptions + 1 + java.lang.Integer + + + foo/name1 + value1 + java.lang.String + + + foo/bar/name2 + true + java.lang.Boolean + + + name3 + 1 + java.lang.Integer + + + foo/name4 + 10 + java.lang.Integer + + + diff --git a/webapp-examples/aco.testXid.html b/webapp-examples/aco.testXid.html new file mode 100644 index 0000000..78a308e --- /dev/null +++ b/webapp-examples/aco.testXid.html @@ -0,0 +1,79 @@ + + + + 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/webapp-examples/index.html b/webapp-examples/index.html new file mode 100644 index 0000000..4cf657d --- /dev/null +++ b/webapp-examples/index.html @@ -0,0 +1,9 @@ + + + + XID Examples + + +XID tests and examples. + + diff --git a/webapp-examples/index.xhtml b/webapp-examples/index.xhtml new file mode 100644 index 0000000..4cf657d --- /dev/null +++ b/webapp-examples/index.xhtml @@ -0,0 +1,9 @@ + + + + XID Examples + + +XID tests and examples. + + diff --git a/webapp-examples/test.html b/webapp-examples/test.html new file mode 100644 index 0000000..56f40ec --- /dev/null +++ b/webapp-examples/test.html @@ -0,0 +1,17 @@ + + + + test XID + + + Test 01: Hello world.
+ Test 02: Hello world.
+ Test 03: Hello world.
+ Test 04: Hello world.
+ Test 05: Hello world.
+ Test 06: Hello world.
+ Test 07: gnu flottant.
+ Test 08: Result: Hello you there.
+ Test 09: Result: Hello you there.
+ + \ No newline at end of file diff --git a/webapp-examples/testXid.html b/webapp-examples/testXid.html new file mode 100644 index 0000000..84d6c5e --- /dev/null +++ b/webapp-examples/testXid.html @@ -0,0 +1,78 @@ + + + + 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/webapp-examples/xhtml-lat1.ent b/webapp-examples/xhtml-lat1.ent new file mode 100644 index 0000000..ffee223 --- /dev/null +++ b/webapp-examples/xhtml-lat1.ent @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp-examples/xhtml-special.ent b/webapp-examples/xhtml-special.ent new file mode 100644 index 0000000..cead4e8 --- /dev/null +++ b/webapp-examples/xhtml-special.ent @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp-examples/xhtml-symbol.ent b/webapp-examples/xhtml-symbol.ent new file mode 100644 index 0000000..63c2abf --- /dev/null +++ b/webapp-examples/xhtml-symbol.ent @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp-examples/xhtml1-frameset.dtd b/webapp-examples/xhtml1-frameset.dtd new file mode 100644 index 0000000..1a00936 --- /dev/null +++ b/webapp-examples/xhtml1-frameset.dtd @@ -0,0 +1,1235 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp-examples/xhtml1-transitional.dtd b/webapp-examples/xhtml1-transitional.dtd new file mode 100644 index 0000000..e22581b --- /dev/null +++ b/webapp-examples/xhtml1-transitional.dtd @@ -0,0 +1,1210 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +