Solved

How to access a Jackrabbit/JCR Nodes text content

Posted on 2009-04-08
1
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article will shed light on the latest trends when it comes to your resume building needs. For far too long, the traditional CV format has monopolized the recruitment market.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.

734 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