[jdom-interest] Finding syntactically-related children and parent Elements in XHTML

Costas Mantratzis cmantrat at ics.mq.edu.au
Mon May 2 10:51:06 PDT 2005


Yes, absolutely, that would work.

However in this case I would have to be the one to "teach" the system
(through the filter) what schema to follow.

I was wondering if such a schema understanding was already built-into one of
the many (x)HTML parsers out there and exposed through an interface for
validation.

I guess that beyond elements of tables and lists (and perhaps a few other
examples of explicit element relations that I might be forgetting right now)
there isn't a great need for such a feature since most other elements can
legally exist in a number of hierarchy combinations (i.e. an anchor A can
exist within a TD but also within a P on its own, outside a table)...

Costas Mantratzis

> -----Original Message-----
> From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu] 
> Sent: 03 May 2005 03:40 AM
> To: Costas Mantratzis
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] Finding syntactically-related 
> children and parent Elements in XHTML 
> 
> Would implementing a custom org.jdom.filter.Filter and using
> getDescendants(Filter) work?
> 
> Brad
> 
> "Costas Mantratzis" writes:
> 
> > Hello everyone.
> > 
> > Just picking your brains on something you might have come 
> across while
> > playing with JDOM, JTidy or similar components...
> > 
> > I'm trying to get my algorithm to understand which elements are
> > syntactically directly related to their parents in an XHTML 
> structure.
> > 
> > For example, I want the system to know that all TD and TR 
> elements are
> > directly related to their TABLE parent (i.e. they can't 
> exist without it)
> > where as for example a P element within a TD is not 
> "syntactically directly"
> > related to its TD or TR or TABLE parents (i.e. a P can be 
> found on its own
> > within the XHTML document without always requiring TD to be 
> its parent
> > element).
> > 
> > I was wondering if such a relation is easily detectable 
> using something like
> > JDOM, Jtidy etc.?
> > 
> > I've been experimenting with getDescendants() and 
> getChildren() methods but
> > both of them return every child or descendant regardless of 
> the direct
> > syntactic relation it may have with its parents...
> > 
> > Just wondering if you've ever come across such an issue or 
> can think of a
> possible solution...
> > 
> > Been busting my head all day to try to find a "clean" way 
> of doing this...
> > 
> > C.
> > 
> > _______________________________________________
> > To control your jdom-interest membership:
> > 
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
rhost.com
> 



More information about the jdom-interest mailing list