Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 68768 invoked by uid 500); 8 Mar 2001 16:18:13 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 68711 invoked from network); 8 Mar 2001 16:18:04 -0000 Sender: skc@wasat.worldonline.fr Message-ID: <3AA7B0C8.B573E980@ivision.fr> Date: Thu, 08 Mar 2001 17:18:16 +0100 From: =?iso-8859-1?Q?S=E9bastien?= Koechlin Organization: IVision X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.16-22 i686) X-Accept-Language: fr, en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: [C1] Patch to make OmitXMLDeclaration a cocoon.properties' parameter Content-Type: multipart/mixed; boundary="------------AE9C2FDCFFEEF52E2F7163F5" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N --------------AE9C2FDCFFEEF52E2F7163F5 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit I'm working with a Cisco IP Phone with a buildin HTTP browser. This browser can read text/xml conforming to some specific DTDs, but it's parser is very light and can not handle Processing Instructions nor XML declaration. With this patch, it's possible to create an output type using XMLFormatter without having a XML declaration. I can not make this work with XHTMLFormatter nor HTMLFormatter but, I think, this is not really usefull. Is it OK to apply this patch to the repository ? -- S�bastien Koechlin - IVision - skoechlin@ivision.fr --------------AE9C2FDCFFEEF52E2F7163F5 Content-Type: text/plain; charset=us-ascii; name="xml-cocoon.omit-XML-declaration.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xml-cocoon.omit-XML-declaration.patch" ? build Index: src/org/apache/cocoon/cocoon.properties =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/cocoon.properties,v retrieving revision 1.53 diff -u -r1.53 cocoon.properties --- src/org/apache/cocoon/cocoon.properties 2001/03/08 01:57:03 1.53 +++ src/org/apache/cocoon/cocoon.properties 2001/03/08 15:36:43 @@ -268,6 +268,7 @@ # formatter.[type].preserve-space = [whether to preserve space or not] # formatter.[type].line-width = [page width, wrapping column] # formatter.[type].indent = [numbers of spaces for tag indenting] +# formatter.[type].omit-XML-declaration = [begin output with or not] # HTML 4.0 (strict) formatter.text/html.doctype-public = -//W3C//DTD HTML 4.0//EN Index: src/org/apache/cocoon/formatter/AbstractFormatter.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/formatter/AbstractFormatter.java,v retrieving revision 1.5 diff -u -r1.5 AbstractFormatter.java --- src/org/apache/cocoon/formatter/AbstractFormatter.java 2001/03/07 22:32:16 1.5 +++ src/org/apache/cocoon/formatter/AbstractFormatter.java 2001/03/08 15:36:50 @@ -66,6 +66,7 @@ implements Configurable, Formatter, Status, Cacheable { protected String statusMessage = "Abstract Formatter"; + protected String omitXMLDeclaration; protected String MIMEtype; protected String encoding; protected String doctypePublic; @@ -111,6 +112,8 @@ if (lineWidth != null) { format.setLineWidth(Integer.parseInt(lineWidth)); } + + omitXMLDeclaration = (String) conf.get("omit-XML-declaration"); } public String getEncoding() { @@ -157,6 +160,11 @@ if (lineWidth != null) { message.append("[ Line Width: "); message.append(lineWidth); + message.append(" ]
"); + } + if (omitXMLDeclaration != null) { + message.append("[ Omit XML Declaration: "); + message.append(omitXMLDeclaration); message.append(" ]
"); } message.append("
"); Index: src/org/apache/cocoon/formatter/HTMLFormatter.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/formatter/HTMLFormatter.java,v retrieving revision 1.7 diff -u -r1.7 HTMLFormatter.java --- src/org/apache/cocoon/formatter/HTMLFormatter.java 2001/03/01 16:05:39 1.7 +++ src/org/apache/cocoon/formatter/HTMLFormatter.java 2001/03/08 15:36:50 @@ -62,7 +62,7 @@ * have any semantic information about the document type being formatted, * this class handles tags like <br/> and transforms them to * HTML that non-XML-aware browsers can understand. Note that this creates - * markap that is non-well-formed XML. If you want to be able to send HTML + * markup that is non-well-formed XML. If you want to be able to send HTML * code to old-browser but still create well-formed XML, use the XHTMLFormatter * instead. * @@ -83,7 +83,11 @@ public void init(Configurations conf) { super.init(conf); format.setMethod(Method.HTML); - format.setOmitXMLDeclaration(true); + if( omitXMLDeclaration != null) { + format.setOmitXMLDeclaration(Boolean.valueOf(omitXMLDeclaration).booleanValue()); + } else { + format.setOmitXMLDeclaration(true); + }; } public void format(Document document, OutputStream stream, Dictionary p) throws Exception { Index: src/org/apache/cocoon/formatter/TextFormatter.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/formatter/TextFormatter.java,v retrieving revision 1.6 diff -u -r1.6 TextFormatter.java --- src/org/apache/cocoon/formatter/TextFormatter.java 2001/03/01 16:05:39 1.6 +++ src/org/apache/cocoon/formatter/TextFormatter.java 2001/03/08 15:36:51 @@ -77,7 +77,11 @@ public void init(Configurations conf) { super.init(conf); format.setMethod(Method.TEXT); - format.setOmitXMLDeclaration(true); + if( omitXMLDeclaration != null) { + format.setOmitXMLDeclaration(Boolean.valueOf(omitXMLDeclaration).booleanValue()); + } else { + format.setOmitXMLDeclaration(true); + }; } public void format(Document document, OutputStream stream, Dictionary p) throws Exception { Index: src/org/apache/cocoon/formatter/XHTMLFormatter.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/formatter/XHTMLFormatter.java,v retrieving revision 1.2 diff -u -r1.2 XHTMLFormatter.java --- src/org/apache/cocoon/formatter/XHTMLFormatter.java 2001/03/01 16:05:40 1.2 +++ src/org/apache/cocoon/formatter/XHTMLFormatter.java 2001/03/08 15:36:51 @@ -76,15 +76,19 @@ this.factory = SerializerFactory.getSerializerFactory(Method.XHTML); super.MIMEtype = "text/xhtml"; super.statusMessage = "XHTML Formatter"; - } - + } + public void init(Configurations conf) { super.init(conf); format.setMethod(Method.XHTML); - format.setOmitXMLDeclaration(true); - } - + if( omitXMLDeclaration != null) { + format.setOmitXMLDeclaration(Boolean.valueOf(omitXMLDeclaration).booleanValue()); + } else { + format.setOmitXMLDeclaration(true); + }; + } + public void format(Document document, OutputStream stream, Dictionary p) throws Exception { factory.makeSerializer(stream, format).asDOMSerializer().serialize(document); - } -} + } +} Index: src/org/apache/cocoon/formatter/XMLFormatter.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/formatter/XMLFormatter.java,v retrieving revision 1.6 diff -u -r1.6 XMLFormatter.java --- src/org/apache/cocoon/formatter/XMLFormatter.java 2001/03/01 16:05:41 1.6 +++ src/org/apache/cocoon/formatter/XMLFormatter.java 2001/03/08 15:36:51 @@ -64,7 +64,7 @@ public class XMLFormatter extends AbstractFormatter { SerializerFactory factory; - + public XMLFormatter () { this.factory = SerializerFactory.getSerializerFactory(Method.XML); super.MIMEtype = "text/xml"; @@ -74,7 +74,11 @@ public void init(Configurations conf) { super.init(conf); format.setMethod(Method.XML); - format.setOmitXMLDeclaration(false); + if( omitXMLDeclaration != null) { + format.setOmitXMLDeclaration(Boolean.valueOf(omitXMLDeclaration).booleanValue()); + } else { + format.setOmitXMLDeclaration(false); + }; } public void format(Document document, OutputStream stream, Dictionary p) throws Exception { --------------AE9C2FDCFFEEF52E2F7163F5 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org --------------AE9C2FDCFFEEF52E2F7163F5--