Return-Path: Delivered-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Received: (qmail 76423 invoked from network); 26 Nov 2009 06:40:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Nov 2009 06:40:55 -0000 Received: (qmail 30129 invoked by uid 500); 26 Nov 2009 06:40:55 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 30038 invoked by uid 500); 26 Nov 2009 06:40:54 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 30026 invoked by uid 99); 26 Nov 2009 06:40:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Nov 2009 06:40:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Nov 2009 06:40:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9148C23888D1; Thu, 26 Nov 2009 06:40:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r884411 - /lucene/solr/trunk/src/java/org/apache/solr/request/XMLWriter.java Date: Thu, 26 Nov 2009 06:40:30 -0000 To: solr-commits@lucene.apache.org From: noble@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091126064030.9148C23888D1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: noble Date: Thu Nov 26 06:40:30 2009 New Revision: 884411 URL: http://svn.apache.org/viewvc?rev=884411&view=rev Log: SOLR-1592 Modified: lucene/solr/trunk/src/java/org/apache/solr/request/XMLWriter.java Modified: lucene/solr/trunk/src/java/org/apache/solr/request/XMLWriter.java URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/request/XMLWriter.java?rev=884411&r1=884410&r2=884411&view=diff ============================================================================== --- lucene/solr/trunk/src/java/org/apache/solr/request/XMLWriter.java (original) +++ lucene/solr/trunk/src/java/org/apache/solr/request/XMLWriter.java Thu Nov 26 06:40:30 2009 @@ -188,15 +188,80 @@ /** Writes the XML attribute name/val. A null val means that the attribute is missing. */ public void writeAttr(String name, String val) throws IOException { + writeAttr(name, val, true); + } + + public void writeAttr(String name, String val, boolean escape) throws IOException{ if (val != null) { writer.write(' '); writer.write(name); writer.write("=\""); + if(escape){ + XML.escapeAttributeValue(val, writer); + } else { + writer.write(val); + } XML.escapeAttributeValue(val, writer); writer.write('"'); } } + /**Writes a tag with attributes + * + * @param tag + * @param attributes + * @param closeTag + * @param escape + * @throws IOException + */ + public void startTag(String tag, Map attributes, boolean closeTag, boolean escape) throws IOException { + if (doIndent) indent(); + writer.write('<'); + writer.write(tag); + if(!attributes.isEmpty()) { + for (Map.Entry entry : attributes.entrySet()) { + writeAttr(entry.getKey(), entry.getValue(), escape); + } + } + if (closeTag) { + writer.write("/>"); + } else { + writer.write('>'); + } + } + + /**Write a complete tag w/ attributes and cdata (the cdata is not enclosed in $lt;!CDATA[]!> + * @param tag + * @param attributes + * @param cdata + * @param escapeCdata + * @param escapeAttr + * @throws IOException + */ + public void writeCdataTag(String tag, Map attributes, String cdata, boolean escapeCdata, boolean escapeAttr) throws IOException { + if (doIndent) indent(); + writer.write('<'); + writer.write(tag); + if (!attributes.isEmpty()) { + for (Map.Entry entry : attributes.entrySet()) { + writeAttr(entry.getKey(), entry.getValue(), escapeAttr); + } + } + writer.write('>'); + if (cdata != null && cdata.length() > 0) { + if (escapeCdata) { + XML.escapeCharData(cdata, writer); + } else { + writer.write(cdata, 0, cdata.length()); + } + } + writer.write("'); + } + + + public void startTag(String tag, String name, boolean closeTag) throws IOException { if (doIndent) indent();