xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ewout Graswinckel" <ew...@x-hive.com>
Subject Instantiating a section of an xml document
Date Fri, 29 Sep 2006 09:12:29 GMT
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


Mime
View raw message