[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    Instantiating a section of an xml document
From:       "Ewout Graswinckel" <ewout () x-hive ! com>
Date:       2006-09-29 9:12:29
Message-ID: 200609290912.k8T9CT9A056152 () smtp-vbr1 ! xs4all ! nl
[Download RAW message or body]

Hi,

I'd like to know if it's possible to instantiate only a single node from a
document. I'm using an xml database to return a node from some document
using xquery/xpath. Once I have that node I'd like to use xmlbeans to easily
access it.

So far I've come up with this:

<doc>
......
<block><something>abc</something></block>
....
</doc>

Class 'Block' represents the block element in the xml.

Node n =
getNodeFromDatabaseUsingXpath("doc('.')/descendant-or-self::block[1]");
Block block = (Block) XmlBeans.getContextTypeLoader().parse(n, Block.type,
null);
assertEquals("abc", block.getSomething()); // block.getSomething() == null

This doesn't give any exceptions, but calling block.getSomething() simply
returns null.

I can get it to work if I let my query return an <xml-fragment> element
instead of <block>, but this is not desired in my case. Is there a better
way to do this?

Thanks,
Ewout


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic