Trees in XML

W

Wojtek

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
 
A

Armel Asselin

Wojtek said:
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
 
P

Philippe Poulard

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 !
 
T

Timothy Murphy

Wojtek said:
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?
 
J

Joseph Kesselman

Timothy said:
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.)
 
J

Joseph Kesselman

Wojtek said:
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.
 
R

Richard Tobin

<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>[/QUOTE]
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 <and> is far superior to <operator kind="and">.

-- Richard
 
W

Wojtek

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
 
W

Wojtek

....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
 
A

ahmadf1119

...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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

bench: binary trees 10
Trees 6
Parsing multiple XML trees? 3
comparing binary trees in C 12
Binary search trees (AVL trees) 34
constructin trees in python 3
help using XSLT in parsing nested xml trees 3
B-trees 12

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top