Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 24226 invoked from network); 16 Nov 2006 01:12:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Nov 2006 01:12:24 -0000 Received: (qmail 73965 invoked by uid 500); 16 Nov 2006 01:12:32 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 73868 invoked by uid 500); 16 Nov 2006 01:12:32 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 73857 invoked by uid 99); 16 Nov 2006 01:12:31 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Nov 2006 17:12:31 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Nov 2006 17:12:21 -0800 Received: from ajax.apache.org (localhost [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 16104D4972 for ; Thu, 16 Nov 2006 01:12:00 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: commons-dev@jakarta.apache.org Date: Thu, 16 Nov 2006 01:11:59 -0000 Message-ID: <20061116011159.10590.74903@ajax.apache.org> Subject: [Jakarta-commons Wiki] Update of "Digester/FAQ" by SimonKitching X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification. The following page has been changed by SimonKitching: http://wiki.apache.org/jakarta-commons/Digester/FAQ The comment on the change is: Add info about extracting nested XML as a string ------------------------------------------------------------------------------ It might be possible to create a custom "filtering" rule that has a child rule, and fires that child rule only when the appropriate conditions are set. There - are no examples of such a solution, however. + are no examples of such a solution, however. A possible solution is to perform an XSLT transform to filter out or rename elements that match certain conditions before using Digester to process the document. @@ -422, +422 @@ If you are aware of other solutions to this issue, please add that information here. + == How do I get some xml nested within a tag as a literal string? == + + It is frequently asked how some XML (esp. XHTML) nested within a document can be extracted + as a string, eg to extract the contents of the "body" tag below as a string: + + {{{ +
+ An article about something + +

Some xhtml data

+

Some more xhtml data

+ +
+ }}} + + If you can modify the above to wrap the desired text as a CDATA section then things are easy; Digester will simply treat that CDATA block + as a single string: + + {{{ +
+ An article about something + + Some xhtml data

+

Some more xhtml data

+ ]]> + +
+ }}} + + If this can't be done then you need to use a !NodeCreateRule to create a DOM node representing the body tag and its children, then + serialise that DOM node back to text. + + Remember that Digester is just a layer on top of a standard XML parser, and standard XML parsers have no option to just stop parsing + input at a specific element - unless it knows that the contents of that element is a block of characters (CDATA). + --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org