Solved

How to access a Jackrabbit/JCR Nodes text content

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

760 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

24 Experts available now in Live!

Get 1:1 Help Now