Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Mhm, I'm not sure if I'd agree that internal representation should be completely independent of expected final output, if for no other reason than the implementation of that internal representation may or may not lend itself well to any given input or output, forcing the developer to spend more time rewriting those parts later. In other words, the input and output formts dictate parts of the creation (input) and manipulation (for later output).

If he implements, for example, in Tree::DAG_Node, he might get a slight improvement in ease of creation as he steps through his psuedo-GEDCOM files, he could still use XPath for searching (it's not just for XML), and he gets a few other features he may or may not have any use for (such as ascii-art representations of the tree), but if he ever wants to output to XML, he's going to have to completely rebuild that tree in a manner more accessible to an XML writer or hand-craft his own, as I don't know of any module that will do it for him automatically.

On a more primitive example, if he implements as a pure hash tree, he can directly modify every element by location and he can convert it directly to XML via XML::TreePP, but it's otherwise going to be a nuisance to manipulate, he gets no XPath searches, and he'd have to write his own tree walking code.

If he implements with XML::Twig, he gets XPath for searches, automatic XML output, and fairly decent tree manipulation functions, but he'd have to write a few small shortcut subs for things like adding a child or a sibling (since creating and pasting an element can take 2-3 lines perhaps better reduced to one), and of course writing a GEDCOM 5.5 file isn't going be any easier than with Tree — thought it also won't really be any worse.

There are a few decent tree-building modules available, but if he wants a tree generator/manipulator with easy XPath-language searches, automatic XML output, and preservation of node order, he's pretty much down to XML::Twig that I know of. Did you have another suggestion in particular?

(As an aside, I'd dispute that XML is only a file format -- sure, it's a file format primarily, but it's a file format that makes a richer view of the traditional tree easily human-grokkable. Trees are traditionally a collection of node positions, with little more metadata attached to that position than a name or value most of the time. XML trees are trees where the nodes can contain a subtree otherwise unrelated to the main tree containing an unlimited amount of metadata, and where as a result you don't have to think of it as a subtree if you don't want to, but can if you do. If you're working with complex trees and aren't optimizing for nothing but speed, you could do a lot worse than to think of your project in terms of how it would look in XML.)

(Aside #2: Whatever happened to GEDCOM 6.0 anyway? It was in 'any day now' state half a decade ago, but a quick Googling doesn't show anything ever coming out of it, and the only copies of the specification I can find are incomplete drafts.)


In reply to Re^4: How to create XML tree from non-XML source by AZed
in thread How to create XML tree from non-XML source by H4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2023-01-28 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?