Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Xpath node
Xpath node [message #27223] Wed, 18 July 2007 15:08 Go to next message
Zsolt Paroczi is currently offline Zsolt ParocziFriend
Messages: 3
Registered: July 2009
Junior Member
Hi,

How can I access an Xpath node in a custom tag or in a custom Xpath
function source code?


Thanks forward,
Zsolt
Re: Xpath node [message #27356 is a reply to message #27223] Thu, 19 July 2007 13:40 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Zsolt:

From a tag:
-----------
To evaluate the XPath expressions yourself in the tag handler (like c:get
and c:iterate), you need to use the class XPathContextExtender:

XPathContextExtender xce = XPathContextExtender.getInstance(context);

// there is a whole family of resolveXXX methods. To resolve an xpath as a
boolean, you'd use:
boolean result = xce.resolveTest(currentXPathContext(),
getAttribute("test");

From an XPath function:
------------------------
You can use the XPathUtil class to convert function arguments into the
desired primitive type (String, number, boolean).

In either case
-------------
If you are looking for a model 'node', the XPath engine returns a
org.eclipse.jet.xpath.NodeSet, which is an extension of java.util.Set (so
you can use .iterator() to traverse the set's elements). The type of the
actual object returned will depend on the 'modelLoader' you used. The
org.eclipse.jet.emf and org.eclipse.jet.emfxml loaders will return you
EObject's (or subtypes). If you use the org.eclipse.jet.resource model
loader, you will get org.eclipse.core.resources.IResource objects.

Paul

"Zsolt Paroczi" <paroczizs@ext.t-mobile.hu> wrote in message
news:970dee2d93c5bcdbb487dddde8766e40$1@www.eclipse.org...
> Hi,
>
> How can I access an Xpath node in a custom tag or in a custom Xpath
> function source code?
>
>
> Thanks forward,
> Zsolt
>
>
Previous Topic:Problem with XPath comparison operator '>=' ?
Next Topic:Xpath and XMI format
Goto Forum:
  


Current Time: Fri Apr 26 23:03:19 GMT 2024

Powered by FUDForum. Page generated in 0.02903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top