XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
=?utf-8?B?IFJlOiBbeG1sLWRldl0gUmVwcmVzZW50aW5nIGJpbmFyeSB0cmVlcyBpbiBY?==?utf-8?B?TUwg4oCmIGZsYXQgdmVyc3VzIHJlY3Vyc2l2ZQ==?=

Hi John,

 

  • A simpler XML approach is to use elements named root-node, left-node, and right-node.  That reduces the number of levels in the tree by half.

 

Sorry, I am not clear on what you are suggesting. Do you mean this (recursive) design:

 

<binary-tree>
    
<root-node>
       
<value>root</value>
       
<left-node>
           
<value>A</value>
           
<left-node>
               
<value>C</value>
           
</left-node>
           
<right-node>
               
<value>D</value>
           
</right-node>
       
</left-node>
       
<right-node>
           
<value>B</value>
           
<left-node>
               
<value>E</value>
           
</left-node>
           
<right-node>
               
<value>F</value>
           
</right-node>
        
</right-node>
   
</root-node>
</binary-tree>

 

That doesn’t reduce the number of levels in the tree.

 

/Roger

 

From: John Cowan <johnwcowan@gmail.com>
Sent: Thursday, July 4, 2019 1:13 PM
To: Costello, Roger L. <costello@mitre.org>
Cc: xml-dev@lists.xml.org
Subject: [EXT] Re: [xml-dev] Representing binary trees in XML … flat versus recursive

 

 

 

On Thu, Jul 4, 2019 at 9:45 AM Costello, Roger L. <costello@mitre.org> wrote:

 

Recursive Implementation

The root node consists of a value, an optional left subtree, and an optional right subtree.

A subtree is a node.

A node consists of a value, an optional left subtree, and an optional right subtree.

Here is a recursive XML representation of the above binary tree:

A simpler XML approach is to use elements named root-node, left-node, and right-node.  That reduces the number of levels in the tree by half.

 

In addition, I don't know of any parsers that use recursion in the language to support recursion in the tree; the nesting is normally stored as an array of element objects, either fixed (in which case you get an error) or growable.  Such a structure can of course be traversed in XSLT, but not with native traversal mechanisms..  Your flat representation doesn't gain you much, then.

 

 

John Cowan          http://vrici.lojban.org/~cowan        cowan@ccil.org
Cash registers don't really add and subtract;
        they only grind their gears.
But then they don't really grind their gears, either;
        they only obey the laws of physics.  --Unknown

 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS