Solved

How to access a Jackrabbit/JCR Nodes text content

Posted on 2009-04-08
1
398 Views
Last Modified: 2012-05-06
Hi,

I am currently workling on a really trivial thing. At least it should be. Unfortuneately it isn't.
In my Jackrabbit JCR repository I have saved some Xml content. I have absolutely no problems in navigating and accessing nodes and attributes.

Unfortunately it seems to be impossible for me to get the simple text content of a node.

Lets take this example xml:
<test>huhu</test>
Let's assume I have an instance of javax.jcr.Node (To be more precise: org.apache.jackrabbit.core.NodeImpl)
With which code could I access the text string "huhu"?

Thanks in advance,
     Chris




0
Comment
Question by:ChristoferDutz
1 Comment
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 0 total points
ID: 24105463
Oh gee ... how I wish one day I wouldn't have to solve my problems on my own ;-)

The solution is (After digging into Jackrabbit Sourcecode and propably is valid in all JCR implementations):
The node containing the Text has a child node with the name "jcr:xmltext".
If you get this node, you have to have a look at the hidden Property with the name "jcr:xmlcharacters".

What an intuitive way to do this ;-)

So this code works for me:
Node titleNode = definitionNode.getNode("oval-def:title");
NodeImpl titleTextNode = (NodeImpl) titleNode.getNode("jcr:xmltext");
Property property = titleTextNode.getProperty("jcr:xmlcharacters");
String titleString = property.getString();

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now