开发者

XML modelling tool [closed]

Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 8 years ago.

开发者_运维技巧 Improve this question

I have searched and am looking for a tool which would help when working with XML files. I've got to understand different XML structures and it gets quite annoying when I have to draw everything on a paper or model a diagram myself.

I would like to know if anybody has some tool to offer which would help when figuring out XML structures ?

For anyone who doesn't understand why I need this, imagine this:

<parent id="1"> 
 <name> ... </name>
</parent>
<parent id="2">
 <name> ... </name>
</parent>

<child mother="1" father="2"></child>

In this case, mother and father are set by id in parent element.

And sometimes I have a huge structure which is connected with other nodes in this way(using ID or some string identificator). It sucks to handle this manually and I would like to know if there's some automatic way to draw a diagram from XML(with minimal input).

Thank you


I know you're asking for a tool, and you're tagging your question with UML, but perhaps you'll like the Graph::Easy module with Perl, just to get a first big view of your XML.

Here is the sample XML :

<test>
  <parent id="1"/>
  <parent id="2"/>
  <child id="11" mother="1" father="2"/>
  <child id="10" mother="1" father="2"/>
</test>

Here is the little script :

#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;

use Graph::Easy;
use IO::All;
use Path::Class;
use XML::LibXML;

my $graph   = Graph::Easy->new(timeout => 100);
my $parser  = XML::LibXML->new();
my $xmlFile = file('...') # Replace by your path.

my $dom = $parser->parse_file($xmlFile);
foreach my $childNode ($dom->findnodes('//child'))
{
    $graph->add_edge
    (
        $childNode->getAttribute('id'),
        $childNode->getAttribute('mother'),
        'has mother'
    );
    $graph->add_edge
    (
        $childNode->getAttribute('id'),
        $childNode->getAttribute('father'),
        'has father'
    );
}

$graph->as_svg > io("graph.svg");

and the result :

XML modelling tool [closed]

That's just a very simple example, but you can easily go further and add different types of lines, colors, etc. By example :

XML modelling tool [closed]


Perhaps you're using the wrong tool? XML is best for identifying data stored as top-down tree structures. The structure your describing has more complex relationships (parents may in some instances be the top level element, in others the low level element)... something that a relational database (for example, SQL based) would be better at describing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜