Re: Can Resource.getContent() return a Map object directly?

Vadim Gritsenko <[email protected]> Mon, 19 Jun 2006 20:41:17 -0400
Newsgroups gmane.text.xml.xindice.user
Message-ID <[email protected]>
Alex Chew wrote:
> Hi, everybody 
>  
>              In my project, I want to use a query result just like 
> java.util.Map. But Resource.getContent() just return a raw XML String. 
> Does there some method can convert a query result into a Map 
> object? Then i can use like this,

Nope, not possible. XML:DB api provides a way to access binary data and XML 
documents, no support for maps.


> I tried now,
>  while (resourceIterator.hasMoreResources()) {
>                 Resource resource = resourceIterator.nextResource();
> //I must extract each value, element and attribute, here. It looks some 
> stranges and runs slowly
>                 System.out.println((String) resource.getContent());
>            }
>  
> I want it can work like this,
>  while (resourceIterator.hasMoreResources()) {
>                 Resource resource = resourceIterator.nextResource();
> Map result = resource.getMap();
> //then i can get specified value just use result.get("key")
>            }

Why don't you query the database and retrieve only the relevant document fragments.

Vadim