|Re: namespace support for JET Xpaths yet? [message #26906 is a reply to message #26527]
||Tue, 17 July 2007 13:46
| Paul Elder
Registered: July 2009
Not, namespace declaration is not yet supported. But, in your case, I don't
think it would help. Here's why, and here's what to do.
JET loads UML models (with are EMF based) using EMF, and it then traverses
the loaded EObjects - JET has no idea how the objects were persisted on
When EMF loads an XMI document (such as your UML model), the xmi:type
attribute becomes the EObject's type/EClass. XPath 1.0 has no formally
defined mechanism determining type, but the JET XPath engine can determine
the type of EObjects. It leverages the engines ability to match EClass
//packagedElement[@xmi:type = 'uml:Association']
But, in looking more closely at your example, I'm guessing the $attr is
Property object (problably found by iterating over a Class, and accessing
the 'attributes' collection). In which case, you probably want:
which is the result of evaluating getAssociation() on $attr.
I just answered another thread on XPath and XMI. I'm going to create a FAQ
entry, but here are the basics:
1) forgot about looking an the XMI. Instead, think of the EMF Model you are
2) think about who your would navigate from an EMF Resource to find the
you'd want. In particular, think of the EMF EReferences and EAttributes you
will be using. Here's some pseudo code...
Resource res = ...;
RootType root = (RootType)res.getContents().get(0); // the 'contents' pseudo
... root.getSomeFeature() ... // the someFeature EReference
... someEObject.getSomeAttribute() ... // the someAttribute EAttribute
3) Write your XPath expression using the 'feature' names from you EMF model.
The initial '/' in an expression maps to the Resource, and 'contents' is the
only valid child of '/'. If your accessing an EAttribute, prefix the name
with '@'. Here's equivalent XPath
4) XPath on EMF-based models, you can use EClass names instead of feature
names. Here's equivlanet XPath:
5) The XPath Engine sees non-containment EReference features, so you can
access these, too. The expression $attr/association takes advantage of this.
"Tim Stephenson" <firstname.lastname@example.org> wrote in message
> I have a UML model including this snippet
> <packagedElement xmi:type="uml:Association"
> xmi:id="_CmyWYB4UEdy1OIzpfsW7CQ" name="c1toc2"
> which I want to be able to extract with an XPath something like this:
> <c:get select="//packagedElement[@xmi:type='uml:Association' and
> but JET (0.8.1) responds with
> Error: No namespace URI found for prefix "xmi"
> Is this something I failed to do or a limitation? I can't find any
> reference to how i declare the namespace but
> found what looks like similar posts pointing at defect 184692
> thanks in advance,
Powered by FUDForum
. Page generated in 0.03145 seconds