Hi Vincent,
The ExtractHandler listens to SAX events in order to obtain a well-formed
XML fragment with the following semantic:
xmlInput.dropAllTags().substring(start, length).unDropAssociatedTags()
So basically you would create an instance like:
new ExtractHandler(0, 400)
in order to obtain an XML fragment with its inner text length of at most
400 characters, starting at position/character 0 in the source/input XML's
inner text. The ExtractHandler is currently used in
http://tinyurl.com/6pcn6e to obtain a preview of an XML (HTML, to be more
specific). Another use case I can think of is to paginate an XML source
(keeping pages well-formed).
To give you an example, the result of applying an ExtractHandler(3, 13) to:
<p>click <a href="realyLongURL"
title="Here">here</a> to view the result</p>
is:
<p>ck <a href="realyLongURL" title="Here">here</a>
to</p>
I'll improve the javadoc on Monday.
Thanks,
Marius
Hi Marius,
On Aug 4, 2008, at 10:10 AM, Marius Dumitru Florea wrote:
+1
You could also move there com.xpn.xwiki.util.ExtractHandler
Yes but before we do it could you tell me what it does. The javadoc
says:
" * Extracts a well-formed XML fragment by listening to SAX events."
But I don't understand what this means. The code is pretty complex and
I'm not sure what it does by looking at it quickly.
Thanks
-Vincent
> Hi,
>
> I'd like to create a new core module called xwiki-xml which contains
> xwiki utility classes to help parse XML.
> The first need I have is to put inside an Entity resolver so that
> DTDs
> can be resolved locally.
>
> The idea is to move the following files currently located in xwiki-
> core:
> * XWikiURIResolver
> * xhtml1-*.dtd (2 files)
> * xhtml-*.ent (3 files)
>
> I need this in the new rendering XHTML macro to support entities.
>
> In the future we could put there any generic code useful for handling
> XML (and for which we don't have any external framework to use of
> course).
>
> Here's my +1
>
> Thanks
> -Vincent
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs