[jdom-interest] a question about node type
Grzegorz Kaczor
grzegorz.kaczor at computaris.com
Wed Dec 6 07:07:24 PST 2006
Hi,
instanceof is reflection and reflection is slow :).
Regards,
Grzegorz
Jason Hunter wrote:
> I would call
>
> Iterator itr = root.getDescendants(new ContentFilter(
> ContentFilter.TEXT | ContentFilter.CDATA))
>
> Then you'll get an iterator for all text and cdata nodes. I'm not
> 100% sure but I think you can safely do replace calls on that iterator.
>
> What's wrong w/ instanceof?
>
> -jh-
>
> Grzegorz Kaczor wrote:
>> Hello,
>>
>> JDOM is a very convenient interface to manipulate XML elements but I
>> think it lacks one useful functionality that is present in W3C DOM
>> implementation - a node type distinction available from Content class.
>>
>> Let's say I want to perform something for each node (and for each
>> type of node a different activity) - for example I want to replace
>> all lowercase 'a' letters to uppercase ones - in element text
>> content, in attribute values, in CDATA sections and so on (this is an
>> exemplary action). Do I have to use reflection for that?
>>
>> In W3C DOM I can use getNodeType() to distinguish node types and
>> perform the replace recursively. How can I do the same using JDOM and
>> not using 'instanceof'?
>>
>> Best Regards,
>> Grzegorz
>>
>>
>>
>> This email is subject to Computaris email terms of use:
>> http://www.computaris.com/email_terms.html
>> _______________________________________________
>> To control your jdom-interest membership:
>> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>>
>
--
Grzegorz Kaczor
Computaris Poland
Mobile: +48660742724
grzegorz.kaczor at computaris.com
This email is subject to Computaris email terms of use: http://www.computaris.com/email_terms.html
More information about the jdom-interest
mailing list