You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "alessandra.brindisi@virgilio.it" <al...@virgilio.it> on 2011/12/11 16:55:06 UTC

Data graph from xml document

 Hello, I have to implement the Data Graph in Java from an XML document. For example, having the following document:

<movie>
<title> Hello </ title>
<actors>
<actor> Brad Pitt </ actor>
<actor> George Clooney </ actor>
</actors>
</movie>

we must build an internal representation of the document in the form of a graph, where elements are represented as nodes and links between elements such as arches. Then I have to navigate through the graph to process the data. I wanted to understand what are the most efficient structures for the representation of a graph, ie Hashtable, matrices, etc. ... 
In addition, you have to give me some suggestions on how I can use the sax parser to construct the structure graph? 

Re: Data graph from xml document

Posted by Mukul Gandhi <mu...@apache.org>.
Since tree is a special case for a graph, I think you may use a DOM
tree for example to represent your graph in-memory.

XML data is inherently hierarchical, and mapping it to any custom
structure (for e.g a non tree like graph or something else) I think
would require a custom design. A SAX stream to your custom graph
structure should be possible, provided you're able to develop such an
algorithm.

On Sun, Dec 11, 2011 at 9:25 PM, alessandra.brindisi@virgilio.it
<al...@virgilio.it> wrote:
>  Hello, I have to implement the Data Graph in Java from an XML document. For
> example, having the following document:
>
> <movie>
> <title> Hello </ title>
> <actors>
> <actor> Brad Pitt </ actor>
> <actor> George Clooney </ actor>
> </actors>
> </movie>
>
> we must build an internal representation of the document in the form of a
> graph, where elements are represented as nodes and links between elements
> such as arches. Then I have to navigate through the graph to process the
> data. I wanted to understand what are the most efficient structures for the
> representation of a graph, ie Hashtable, matrices, etc. ...
> In addition, you have to give me some suggestions on how I can use the sax
> parser to construct the structure graph?



-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Data graph from xml document

Posted by Jacob Kjome <ho...@visi.com>.
Seems to me that a databinding framwork such as JAXB2 [1] or JiBX [2] would work
nicely for this, assuming you have a schema for the document.


[1] http://jaxb.java.net/
[2] http://jibx.sourceforge.net/

Jake

On 12/15/2011 11:56 AM, keshlam@us.ibm.com wrote:
> There are a number of good tutorials on XML programming in Java at
> http://www.ibm.com/xml, along with a lot of articles on more specific
> techniques. For basic "how do I get started" questions, I'd recommend
> reading some of those.
> 
> XML itself is a strict tree structure, with the only "links" being the
> parent/child/attribute/previous/next relationships. The ID/IDREF
> relationship may also exist, IF the kind of document you're working with
> uses it. It's also possible that some kinds of documents define their
> own relationships. You need to understand how the specific XML-based
> language(s) you'll be working with behave if you want to extract these,
> and/or use XML Schema datatypes to help interpret them.
> 
> If you want an XML-specific in-memory datastructure, the DOM is an
> obvious one to work with since it's already implemented; you might need
> some additional datastructures to support the applicaiton-specific
> relationships. Or you can code your own, for your specific application,
> and write a SAX handler (see the tutorials) to build it ... but that's a
> straight Java data structure and UI problem, and I'd consider that
> mostly offtopic for this list.
> 
> 
> 
> ______________________________________
> "You build world of steel and stone
> I build worlds of words alone
> Skilled tradespeople, long years taught:
> You shape matter; I shape thought."
> (http://www.songworm.com/lyrics/songworm-parody/ShapesofShadow.html)
> 
> 
> From: 	"alessandra.brindisi@virgilio.it" <al...@virgilio.it>
> To: 	j-users@xerces.apache.org,
> Date: 	12/14/2011 11:08 PM
> Subject: 	Data graph from xml document
> 
> 
> ------------------------------------------------------------------------
> 
> 
> 
>  Hello, I have to implement the Data Graph in Java from an XML document.
> For example, having the following document:
> 
> <movie>
> <title> Hello </ title>
> <actors>
> <actor> Brad Pitt </ actor>
> <actor> George Clooney </ actor>
> </actors>
> </movie>
> 
> we must build an internal representation of the document in the form of
> a graph, where elements are represented as nodes and links between
> elements such as arches. Then I have to navigate through the graph to
> process the data. I wanted to understand what are the most efficient
> structures for the representation of a graph, ie Hashtable, matrices,
> etc. ...
> In addition, you have to give me some suggestions on how I can use the
> sax parser to construct the structure graph?

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Data graph from xml document

Posted by ke...@us.ibm.com.
There are a number of good tutorials on XML programming in Java at 
http://www.ibm.com/xml, along with a lot of articles on more specific 
techniques. For basic "how do I get started" questions, I'd recommend 
reading some of those.

XML itself is a strict tree structure, with the only "links" being the 
parent/child/attribute/previous/next relationships. The ID/IDREF 
relationship may also exist, IF the kind of document you're working with 
uses it. It's also possible that some kinds of documents define their own 
relationships. You need to understand how the specific XML-based 
language(s) you'll be working with behave if you want to extract these, 
and/or use XML Schema datatypes to help interpret them.

If you want an XML-specific in-memory datastructure, the DOM is an obvious 
one to work with since it's already implemented; you might need some 
additional datastructures to support the applicaiton-specific 
relationships. Or you can code your own, for your specific application, 
and write a SAX handler (see the tutorials) to build it ... but that's a 
straight Java data structure and UI problem, and I'd consider that mostly 
offtopic for this list. 



______________________________________
"You build world of steel and stone
I build worlds of words alone
Skilled tradespeople, long years taught:
You shape matter; I shape thought."
(http://www.songworm.com/lyrics/songworm-parody/ShapesofShadow.html)



From:
"alessandra.brindisi@virgilio.it" <al...@virgilio.it>
To:
j-users@xerces.apache.org, 
Date:
12/14/2011 11:08 PM
Subject:
Data graph from xml document



 Hello, I have to implement the Data Graph in Java from an XML document. 
For example, having the following document:

<movie>
<title> Hello </ title>
<actors>
<actor> Brad Pitt </ actor>
<actor> George Clooney </ actor>
</actors>
</movie>

we must build an internal representation of the document in the form of a 
graph, where elements are represented as nodes and links between elements 
such as arches. Then I have to navigate through the graph to process the 
data. I wanted to understand what are the most efficient structures for 
the representation of a graph, ie Hashtable, matrices, etc. ... 
In addition, you have to give me some suggestions on how I can use the sax 
parser to construct the structure graph? 

Re: Data graph from xml document

Posted by Olivier Rossel <ol...@gmail.com>.
I would serialize this XML as RDF triples, and load them in a RDF store.

Envoyé de mon iPad

Le 11 déc. 2011 à 16:55, "alessandra.brindisi@virgilio.it" <al...@virgilio.it> a écrit :

>  Hello, I have to implement the Data Graph in Java from an XML document. For example, having the following document:
> 
> <movie>
> <title> Hello </ title>
> <actors>
> <actor> Brad Pitt </ actor>
> <actor> George Clooney </ actor>
> </actors>
> </movie>
> 
> we must build an internal representation of the document in the form of a graph, where elements are represented as nodes and links between elements such as arches. Then I have to navigate through the graph to process the data. I wanted to understand what are the most efficient structures for the representation of a graph, ie Hashtable, matrices, etc. ... 
> In addition, you have to give me some suggestions on how I can use the sax parser to construct the structure graph?

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org