Solved

How to access a Jackrabbit/JCR Nodes text content

Posted on 2009-04-08
1
395 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

920 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

17 Experts available now in Live!

Get 1:1 Help Now