Trees in XML

Discussion in 'XML' started by Wojtek, Oct 22, 2007.

  1. Wojtek

    Wojtek Guest

    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
    Wojtek, Oct 22, 2007
    #1
    1. Advertising

  2. "Wojtek" <> a écrit dans le message de news:
    ffi6fn$ipc$...
    > 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
    Armel Asselin, Oct 22, 2007
    #2
    1. Advertising

  3. 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 !
    Philippe Poulard, Oct 22, 2007
    #3
  4. 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?
    Timothy Murphy, Oct 22, 2007
    #4
  5. 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
    Joseph Kesselman, Oct 22, 2007
    #5
  6. 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
    Joseph Kesselman, Oct 22, 2007
    #6
  7. In article <471ca0c3$0$5096$>,
    Armel Asselin <> wrote:

    >> <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 <and> is 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.
    Richard Tobin, Oct 23, 2007
    #7
  8. Wojtek

    Wojtek Guest

    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
    Wojtek, Oct 24, 2007
    #8
  9. Wojtek

    Wojtek Guest

    ....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
    Wojtek, Oct 24, 2007
    #9
  10. Wojtek

    Guest

    On 24 , 15:26, Wojtek <> wrote:
    > ...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, 2007
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pif

    Trees in java

    Pif, Apr 6, 2004, in forum: Java
    Replies:
    1
    Views:
    428
    Manolo
    Apr 6, 2004
  2. jova

    Binary Trees

    jova, Apr 25, 2004, in forum: Java
    Replies:
    11
    Views:
    722
    Roedy Green
    Apr 26, 2004
  3. David Svoboda

    Parsing multiple XML trees?

    David Svoboda, Dec 15, 2005, in forum: XML
    Replies:
    3
    Views:
    604
    Andrew Schorr
    Dec 16, 2005
  4. Replies:
    3
    Views:
    632
  5. jacob navia

    Binary search trees (AVL trees)

    jacob navia, Jan 3, 2010, in forum: C Programming
    Replies:
    34
    Views:
    1,394
    Dann Corbit
    Jan 8, 2010
Loading...

Share This Page