|Re: JET - Only possible to use xpath? [message #16082 is a reply to message #16065]
||Thu, 17 May 2007 12:26
| Paul Elder
Registered: July 2009
First, I'd like more details on this:|
> For instance, if I say <c:get select="/AAA/BBB " /> to "select the
> first BBB child of element AAA" it doesn't do that.
Can you send me an example? If it is not working, it is definitely a bug
that must be fixed.
As for using Java code, JET supports Java scriptlets, expressions and
declarations. Here's a link to the help page:
Some useful facts for writing Java code and accessing the transformation
1) The XPath expressions work on data stored in the JET2Context passed to
the template. In Java expressions and scriptlets, this is available as the
2) The root of the source document passed to the JET (which the XPath engine
treats as /) may be obtained by context.getSource().
3) The XPath variables are stored in the context, too:
context.getVariable("...name..."). Do not include the dollar ($) sign.
4) The tricky part in writing some Java code is determining Java types
variables. JET loads XML documents using EMF's generic XML support.
Documents that have no XML Schema get loaded using the inscrutable AnyType.
If you have to write Java expressions against AnyType, I can guarantee
you'll have more code than an XPath expression.
5) If you transformation is reading a document that has a registered Ecore
model, then context.getSource() will be the EMF Resource object, and values
returned XPath expressions will be the EObjects in your model. It is much
easier to use Java expressions with such models.
Powered by FUDForum
. Page generated in 0.02123 seconds