By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

Trees in XML

P: n/a
Hi,

I want to use tree-like structures in my program. All of them are
provided by user in config files. Tree's are looking like this:

AND
|
+--OR
| +--something
| +--something
|
+--OR
|
+--AND
| +--something
| +--something
|
+--something

AND's and OR's can be nested very deeply. It will be better if trees can
be non-binary.

The question is if it is possible to define it in XML. Namely if it is
capable of such dependencies in tags (recurrency?) ?

i.e.

<and>
<or>
<something>
<something>
</or>
<or>
<and>
<something>
<something>
</and>
<something>
</or>
</and>
sincerely
wojtek
Oct 22 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a

"Wojtek" <ad********@o2.pla écrit dans le message de news:
ff**********@news.pwr.wroc.pl...
Hi,

I want to use tree-like structures in my program. All of them are provided
by user in config files. Tree's are looking like this:

AND
|
+--OR
| +--something
| +--something
|
+--OR
|
+--AND
| +--something
| +--something
|
+--something

AND's and OR's can be nested very deeply. It will be better if trees can
be non-binary.

The question is if it is possible to define it in XML. Namely if it is
capable of such dependencies in tags (recurrency?) ?
recursivity ? yes you can do as much as you want with XML.
>
i.e.

<and>
<or>
<something>
<something>
</or>
<or>
<and>
<something>
<something>
</and>
<something>
</or>
</and>
I would rather use an operator element, with a kind attribute such as:
<operator kind="and">
<operator kind="or">
</operator>
<operator kind="or">
</operator>
</operator>

it will let more room to add new operators later, without changing your
nodes.
Armel
Oct 22 '07 #2

P: n/a
hi,

can you tell us more about your project ? if you have to express boolean
operations, you certainly have to evaluate them
it seems that you try to invente the wheel :)

Wojtek a écrit :
Hi,

I want to use tree-like structures in my program. All of them are
provided by user in config files. Tree's are looking like this:

AND
|
+--OR
| +--something
| +--something
|
+--OR
|
+--AND
| +--something
| +--something
|
+--something

AND's and OR's can be nested very deeply. It will be better if trees can
be non-binary.

The question is if it is possible to define it in XML. Namely if it is
capable of such dependencies in tags (recurrency?) ?

i.e.

<and>
<or>
<something>
<something>
</or>
<or>
<and>
<something>
<something>
</and>
<something>
</or>
</and>
sincerely
wojtek

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
Oct 22 '07 #3

P: n/a
Wojtek wrote:
I want to use tree-like structures in my program.
Slightly OT, but related:
Is there a standard (or roughly standard) DTD/schema
for genealogical trees?

Oct 22 '07 #4

P: n/a
Timothy Murphy wrote:
Is there a standard (or roughly standard) DTD/schema
for genealogical trees?
I'd start by asking the Church of Latter Day Saints. Seriously;
geneology is a serious interest of theirs and for years they were
offering the best software for the purpose; if they've adopted XML,
they've probably done a good job with it.

(No, I'm not a member of that church; I've just heard their software
recommended by everyone who has had an interest in this topic.)
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 22 '07 #5

P: n/a
Wojtek wrote:
The question is if it is possible to define it in XML. Namely if it is
capable of such dependencies in tags (recurrency?) ?
Certainly. Both DTDs and schemas are perfectly capable of expressing
recursive data structures. See any good XML tutorial.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 22 '07 #6

P: n/a
In article <47**********************@news.orange.fr>,
Armel Asselin <ar**********@hotmail.comwrote:
><and>
<or>
<something>
[...]
>I would rather use an operator element, with a kind attribute such as:
<operator kind="and">
<operator kind="or">
</operator>
<operator kind="or">
</operator>
</operator>
>it will let more room to add new operators later, without changing your
nodes.
You don't have to change the nodes. You just have to invent new
element names and use them. Why is it better to invent new attribute
values rather than new element names?

True, you could write a DTD that accepted any value for kind
attributes, but that would be at the expense of error checking.

And for readability <andis far superior to <operator kind="and">.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Oct 23 '07 #7

P: n/a
Philippe Poulard napisa³(a):
hi,

can you tell us more about your project ? if you have to express boolean
operations, you certainly have to evaluate them
it seems that you try to invente the wheel :)
I'm writing filter for Snort security alerts. It should provide us with
possibility of defining conditions for this filtering. I think that most
powerful method will need tree-like stucture to allow defining any
logical combination of such elements as:

destination=deimos
port=21
source=86.XX.XX.XX
type=shellcode
date=monday..friday
and so on

Now we can say to drop alerts comming from my computer to mail server
which includes binaries, but track all binaries send every other way.

wojtek


Oct 24 '07 #8

P: n/a
....and I want to parse XML, build suitable objects with conjunctions in
nodes and rules in leaves.

My filter will evaluate top node, it will evaluate its children (or only
one of them, depending on condition and values) etc...

wojtek
Oct 24 '07 #9

P: n/a
On 24 , 15:26, Wojtek <adunREM...@o2.plwrote:
...and I want to parse XML, build suitable objects with conjunctions in
nodes and rules in leaves.

My filter will evaluate top node, it will evaluate its children (or only
one of them, depending on condition and values) etc...

wojtek
hi

Oct 25 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.