Author: alexsmirnov
Date: 2007-07-09 20:31:28 -0400 (Mon, 09 Jul 2007)
New Revision: 1557
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
Log:
packages and classes refactor in the "impl" project
Merge configurable XML filter from ajax4jsf 1.1.2
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java 2007-07-10 00:17:10 UTC
(rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java 2007-07-10 00:31:28 UTC
(rev 1557)
@@ -21,7 +21,7 @@
package org.ajax4jsf;
-import org.ajax4jsf.framework.ajax.xmlfilter.TidyFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.ConfigurableFilter;
/**
* Proxy for resource/ajax xml parsing filter.
@@ -29,6 +29,6 @@
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:29 $
*
*/
-public class Filter extends TidyFilter {
+public class Filter extends ConfigurableFilter {
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -60,6 +60,8 @@
private static final String REDIRECTED = "org.ajax4jsf.view.REDIRECTED";
+ public static final String VIEW_ID_KEY = "org.ajax4jsf.VIEW_ID";
+
/**
* @param parent
*/
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -385,6 +385,9 @@
}
// Mark as processed.
requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
+ // Save viewId for a parser selection
+ requestMap.put(
+ AjaxViewHandler.VIEW_ID_KEY,root.getViewId());
}
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -67,9 +67,12 @@
private static final String NAMESPACE_PARAMETER = "namespace";
private boolean forcexml = false;
+
private static final String FORCEXML_PARAMETER = "forceparser";
+ private static final String INIT_PARAMETER_PREFIX =
"org.ajax4jsf.xmlfilter.";
+
public BaseFilter filter;
public void setFilter(BaseFilter filter) {
@@ -81,14 +84,10 @@
log.debug("init XML filter service with class "
+ this.getClass().getName());
}
- if ("false".equalsIgnoreCase(config
- .getInitParameter(FORCEXML_PARAMETER))) {
- this.forcexml = false;
- }
- if ("true"
- .equalsIgnoreCase(config.getInitParameter(FORCEXML_PARAMETER))) {
- this.forcexml = true;
- }
+ String forceXmlParameter = config
+ .getInitParameter(FORCEXML_PARAMETER);
+ setupForceXml(forceXmlParameter);
+ forceXmlParameter =
config.getServletContext().getInitParameter(INIT_PARAMETER_PREFIX+FORCEXML_PARAMETER);
setMimetype((String) nz(config.getInitParameter(MIME_TYPE_PARAMETER),
"text/xml"));
setPublicid((String) nz(config.getInitParameter(PUBLICID_PARAMETER),
@@ -100,6 +99,19 @@
}
/**
+ * @param forceXmlParameter
+ */
+ private void setupForceXml(String forceXmlParameter) {
+ if ("false".equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = false;
+ }
+ if ("true"
+ .equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = true;
+ }
+ }
+
+ /**
* Perform filter chain with xml parsing and transformation. Subclasses
* must implement concrete HTML to XML parsing, nesseasary
* transformations and serialization.
@@ -125,6 +137,7 @@
.setAttribute(RESPONSE_WRAPPER_ATTRIBUTE,
servletResponseWrapper);
chain.doFilter(request, servletResponseWrapper);
+ String viewId = (String) request.getAttribute(AjaxViewHandler.VIEW_ID_KEY);
HtmlParser parser = null;
// setup response
// Redirect in AJAX request - convert to special response recognized by
@@ -203,7 +216,7 @@
String outputEncoding = "UTF-8";
String contentType = getMimetype() + ";charset=" + outputEncoding;
response.setContentType(contentType);
- parser = getParser(getMimetype(), true);
+ parser = getParser(getMimetype(), true, viewId);
if (null == parser) {
throw new ServletException(Messages.getMessage(
Messages.PARSER_NOT_INSTANTIATED_ERROR, contentType));
@@ -231,7 +244,7 @@
&& null != characterEncoding) {
contentType += ";charset=" + characterEncoding;
}
- parser = getParser(contentType, false);
+ parser = getParser(contentType, false, viewId);
response.setContentType(contentType);
}
// null or unsupported content type
@@ -332,7 +345,7 @@
protected abstract void reuseParser(HtmlParser parser);
- protected abstract HtmlParser getParser(String mimetype, boolean isAjax);
+ protected abstract HtmlParser getParser(String mimetype, boolean isAjax, String
viewId);
/**
* @param publicid
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -149,7 +149,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
+ * @see
org.ajax4jsf.framework.resource.ResourceContext#setHeader(java.lang.String,
* java.lang.String)
*/
public void setHeader(String name, String value) {
@@ -159,7 +159,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String,
+ * @see
org.ajax4jsf.framework.resource.ResourceContext#setIntHeader(java.lang.String,
* int)
*/
public void setIntHeader(String name, int value) {
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConfigurableFilter extends BaseFilter {
+
+ /**
+ *
+ */
+ public ConfigurableFilter() {
+ xmlFilter = new ConfigurableXMLFilter();
+ xmlFilter.setFilter(this);
+ }
+
+}
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -0,0 +1,237 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.EmptyStackException;
+import java.util.Properties;
+import java.util.regex.PatternSyntaxException;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.ajax.xmlfilter.nekko.NekkoParser;
+import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyParser;
+import org.ajax4jsf.io.parser.FastHtmlParser;
+import org.apache.commons.collections.ArrayStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConfigurableXMLFilter extends BaseXMLFilter {
+
+ private static final Log log = LogFactory
+ .getLog(ConfigurableXMLFilter.class);
+
+ private static final String PARSERS_LIST_PARAMETER =
"org.ajax4jsf.xmlparsers";
+
+ private static final String VIEW_ID_PATTERN_PARAMETER =
"org.ajax4jsf.xmlparser.";
+
+ /**
+ * map of the parsers names and viewId patterns for all parser type.
+ */
+ private ParserConfig parsers = new TidyParserConfig();
+
+ // private ParserConfig passParserConfig = new PassParserConfig();
+
+ public void init(FilterConfig config) throws ServletException {
+ super.init(config);
+ ServletContext servletContext = config.getServletContext();
+ String parsersParameter = servletContext
+ .getInitParameter(PARSERS_LIST_PARAMETER);
+ if (null != parsersParameter) {
+ configureParsers(servletContext, parsersParameter);
+ }
+ }
+
+ /**
+ * @param servletContext
+ * @param parsersParameter
+ * @throws ServletException
+ */
+ public void configureParsers(ServletContext servletContext,
+ String parsersParameter) throws ServletException {
+ String[] parsersNames = parsersParameter.split("\\s*,\\s*");
+ for (int i = parsersNames.length - 1; i >= 0; i--) {
+ String parserName = parsersNames[i];
+ ParserConfig parserConfig;
+ if ("TIDY".equals(parserName)) {
+ parserConfig = new TidyParserConfig();
+ } else if ("NEKO".equals(parserName)) {
+ parserConfig = new NekoParserConfig();
+ } else if ("PASS".equals(parserName)) {
+ parserConfig = new PassParserConfig();
+ } else {
+ throw new ServletException(
+ "Unknown XML parser type in config parameter "
+ + parserName);
+ }
+ parserConfig.setNext(parsers);
+ if (null != servletContext) {
+ try {
+ String parserViewPattern = servletContext
+ .getInitParameter(VIEW_ID_PATTERN_PARAMETER
+ + parserName);
+ parserConfig.setPatterns(parserViewPattern);
+
+ } catch (PatternSyntaxException e) {
+ throw new ServletException("Invalid pattern for a parser "
+ + parserName + " :" + e.getMessage());
+ }
+ }
+ parsers = parserConfig;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter#getParser(java.lang.String,
+ * boolean, java.lang.String)
+ */
+ protected HtmlParser getParser(String mimetype, boolean isAjax,
+ String viewId) {
+ HtmlParser parser = null;
+ if (isAjax || isForcexml()) {
+ parser = parsers.getParser(viewId, mimetype);
+ } else if (mimetype.startsWith("text/html")
+ || mimetype.startsWith("application/xhtml+xml")) {
+ parser = new FastHtmlParser();
+ }
+ return parser;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter#reuseParser(org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser)
+ */
+ protected void reuseParser(HtmlParser parser) {
+ parsers.reuseParser(parser);
+
+ }
+
+ private static final int STACK_SIZE = 100;
+
+ private ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
+
+ private class NekoParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ NekkoParser parser;
+ try {
+ synchronized (_xhtmlParsersPool) {
+ parser = (NekkoParser) _xhtmlParsersPool.pop();
+ }
+ } catch (EmptyStackException e) {
+ parser = new NekkoParser();
+ parser.setPublicId(getPublicid());
+ parser.setSystemid(getSystemid());
+ parser.setNamespace(getNamespace());
+ // If tidy not handle all requests, disable reorganising
+ // of html
+ // parser.setMoveElements(isForcexml());
+ }
+ // TODO - set header scripts/styles filter.
+ return parser;
+ }
+
+ boolean storeParser(HtmlParser parser) {
+ if (null != parser && parser instanceof NekkoParser) {
+ synchronized (_xhtmlParsersPool) {
+ if (_xhtmlParsersPool.size() < STACK_SIZE) {
+ ((NekkoParser) parser).reset();
+ _xhtmlParsersPool.push(parser);
+ }
+
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private class TidyParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ // TODO Auto-generated method stub
+ TidyParser tidyParser = new TidyParser(getTidyProperties());
+ tidyParser.setMoveElements(isForcexml());
+ tidyParser.setMime(mime);
+ return tidyParser;
+ }
+
+ }
+
+ private class PassParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ return new FastHtmlParser();
+ }
+
+ }
+
+ private Properties _tidyProperties;
+
+ private Properties getTidyProperties() {
+ if (null == _tidyProperties) {
+ _tidyProperties = new Properties();
+ InputStream defaultprops = null;
+ InputStream props = null;
+ try {
+ defaultprops = TidyParser.class
+ .getResourceAsStream("tidy.properties");
+ if (null != defaultprops) {
+ _tidyProperties.load(defaultprops);
+ if (log.isDebugEnabled()) {
+ log.debug("default tidy parser properties loaded");
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug("No default tidy parser properties found");
+ }
+
+ // Second part - user-defined properties.
+ props = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("tidy.properties");
+ if (null != props) {
+ _tidyProperties.load(props);
+ if (log.isDebugEnabled()) {
+ log.debug("application-specific tidy parser properties loaded");
+ }
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages
+ .getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
+ } finally {
+ if (null != props) {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ if (null != defaultprops) {
+ try {
+ defaultprops.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ }
+ }
+ return _tidyProperties;
+ }
+
+ public ParserConfig getParsers() {
+ return parsers;
+ }
+
+}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -66,4 +66,6 @@
*/
public abstract void setViewState(String viewState);
+ public abstract boolean setMime(String mimeType);
+
}
\ No newline at end of file
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+abstract class ParserConfig {
+
+ private static final Pattern[] ALL_VIEWS_PATTERN = { Pattern.compile(".*")
};
+
+ private static final Pattern SEPARATOR_PATTERN =
Pattern.compile("\\s*,\\s*");
+
+ private Pattern[] patterns = ALL_VIEWS_PATTERN;
+
+ private ParserConfig next;
+
+ protected abstract HtmlParser createParser(String mimetype);
+
+ boolean storeParser(HtmlParser parser) {
+ return false;
+ }
+
+ HtmlParser getParser(String viewId, String mimetype) {
+ HtmlParser result = null;
+ for (int i = 0; i < patterns.length && null == result; i++) {
+ Matcher matcher = patterns[i].matcher(viewId);
+ if (matcher.matches()) {
+ result = createParser(mimetype);
+ }
+ }
+ if (null == result && null != next) {
+ result = next.getParser(viewId, mimetype);
+ }
+ return result;
+ }
+
+ public void reuseParser(HtmlParser parser) {
+ if (!storeParser(parser) && null != next) {
+ next.reuseParser(parser);
+ }
+ }
+
+ public ParserConfig getNext() {
+ return next;
+ }
+
+ public void setNext(ParserConfig next) {
+ this.next = next;
+ }
+
+ public void setPatterns(String patternsString) {
+ if (null != patternsString) {
+ String[] split = SEPARATOR_PATTERN.split(patternsString);
+ patterns = new Pattern[split.length];
+ for (int i = 0; i < split.length; i++) {
+ patterns[i]=Pattern.compile(split[i].trim());
+ }
+ }
+ }
+
+ public Pattern[] getPatterns() {
+ return patterns;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -108,7 +108,8 @@
*/
public NekkoParser() {
_parser=new HtmlSAXParser(getHtmlConfig());
- Properties properties =
OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
+// Properties properties =
OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
+ Properties properties =
OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
// properties.put("encoding",_encoding);
_serializer = SerializerFactory.getSerializer(properties);
// serializer.setOutputStream(output);
@@ -641,4 +642,8 @@
_systemid = systemid;
}
+ public boolean setMime(String mimeType) {
+ return false;
+ }
+
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -36,7 +36,7 @@
public NekkoXMLFilter() {}
- protected HtmlParser getParser(String mimetype, boolean isAjax) {
+ protected HtmlParser getParser(String mimetype, boolean isAjax, String viewId) {
HtmlParser parser = null;
if( isAjax ){
parser = getXmlParser();
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -40,7 +40,6 @@
import org.ajax4jsf.org.w3c.tidy.TidyMessageListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.NoOpLog;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -323,7 +322,9 @@
// setup html output
tidy.setXHTML(false);
tidy.setXmlOut(false);
- // TODO - auto doctype ?
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as ordinary HTML");
+ }
return true;
}
}
@@ -333,6 +334,9 @@
// setup xhtml output
tidy.setXHTML(true);
tidy.setXmlOut(false);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as XHTML");
+ }
return true;
}
}
@@ -345,6 +349,9 @@
tidy.setXmlPi(true);
tidy.setEscapeCdata(false);
tidy.setNumEntities(true);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as XML");
+ }
return true;
}
}
@@ -385,7 +392,7 @@
* @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setDoctype(java.lang.String)
*/
public void setDoctype(String doctype) {
- tidy.setDocType(doctype);
+ tidy.setDocType("omit");//doctype);
}
/*
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -66,7 +66,7 @@
* @param string Encodings for parser
* @return
*/
- protected HtmlParser getParser(String mime, boolean isAjax) {
+ protected HtmlParser getParser(String mime, boolean isAjax, String viewId) {
// For non-ajax, parse only html types !
if (isAjax || mime.startsWith("text/html") ||
mime.startsWith("application/xhtml+xml")) {
if(isAjax || isForcexml()){
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2007-07-10
00:17:10 UTC (rev 1556)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2007-07-10
00:31:28 UTC (rev 1557)
@@ -56,6 +56,8 @@
private String viewState;
+ private String mimeType;
+
public void parse(Reader in, Writer out) throws IOException {
boolean haveHtml = false;
boolean haveHead = false;
@@ -163,7 +165,7 @@
private void writeToHead(Writer out, boolean haveHtml, boolean haveHead)
throws IOException {
if (!haveHead && !haveHtml) {
- out.write("<html>");
+ out.write("<html
xmlns=\"http://www.w3.org/1999/xhtml\">");
}
if (!haveHead) {
out.write("<head>");
@@ -252,4 +254,9 @@
this.viewState = viewState;
}
+
+ public boolean setMime(String mimeType) {
+ this.mimeType=mimeType;
+ return true;
+ }
}