[jdom-interest] RE: jdom-interest Digest, Vol 49, Issue 6
Martinez, Will
Will_Martinez at cable.comcast.com
Mon Nov 24 07:51:32 PST 2008
Fabio,
I encountered the same problem, if not similar to what you are describing. I submitted my question to this group but did not receive a reply.
My next step is to use Xpath. I had been busy on other tasks, but plan to tackle Xpath today. I am new to Xpath, so we'll see how far I get.
This is what I had posted:
I have this xml file that I need to access the Text "Dish." I have listed what semi works and does not work. Please see attached file.
<CatParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CatInputs>
<InputValue Name="Food">
<From>MotherCat</From>
<Where>
<On>Dish</On>
</Where>
<Get Name="Tom">WHITE</Get>
<Get Name="Jerry">BLACK</Get>
<Get Name="Sam">GREY</Get>
</InputValue>
descendant_2 =
Where
secondDescendant_1 =
On
descendant_3 =
Get
attributeValue =
Name
With this syntax, I am able to get at Dish, but that is because an attribute is not associated with
the element On.
String secondDescendant1Data = subParentElement.getChild(descendant_2).getChildText(secondDescendant_1);
System.out.print("\n secondDescendant1 Text: " + secondDescendant1Data);// child's descendant2 Where Dish
I get WHITE with this, but I do not have a way of getting to the next element BLACK.
//String secondDescendant3Data = subParentElement.getChild(descendant_3).getValue();//This works!
I get Tom with this syntax;
//String secondDescendant3Data = subParentElement.getChild(descendant_3).getAttribute(attributeValue).getValue();
With this syntax I get the actual attribute: Name;
//String secondDescendant3Data = subParentElement.getChild(descendant_3).getAttribute(attributeValue).getName();//Name
I need syntax like this;
//String secondDescendant3Data = subParentElement.getChild(descendant_3).getAttributeValue(attributeValue).getText(of Tom);
But there isnt an API method that works!
Might you be able to suggest a solution?
-----Original Message-----
From: jdom-interest-bounces at jdom.org [mailto:jdom-interest-bounces at jdom.org] On Behalf Of jdom-interest-request at jdom.org
Sent: Sunday, November 23, 2008 1:00 PM
To: jdom-interest at jdom.org
Subject: jdom-interest Digest, Vol 49, Issue 6
Send jdom-interest mailing list submissions to
jdom-interest at jdom.org
To subscribe or unsubscribe via the World Wide Web, visit
http://www.jdom.org/mailman/listinfo/jdom-interest
or, via email, send a message with subject or body 'help' to
jdom-interest-request at jdom.org
You can reach the person managing the list at
jdom-interest-owner at jdom.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of jdom-interest digest..."
Today's Topics:
1. using JDOM 1.1 on Android's Dalvik VM (Sean Sullivan)
2. Jdom with XMI Files (Fabio Leal)
3. RE: Jdom with XMI Files (Michael Kay)
4. RE: Jdom with XMI Files (Michael Kay)
----------------------------------------------------------------------
Message: 1
Date: Sat, 22 Nov 2008 16:05:46 -0800
From: "Sean Sullivan" <sean at seansullivan.com>
Subject: [jdom-interest] using JDOM 1.1 on Android's Dalvik VM
To: jdom-interest at jdom.org
Message-ID:
<3a0630af0811221605x6a5d6ab6k4092cc5147e6f18 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I'm trying to use JDOM 1.1 on the Android 1.0 platform.
The Android platform supports most Java 5 API's. However, java.rmi.*
classes are not part of the Android platform.
When I use JDOM 1.1 on Android, I see this error:
W/dalvikvm( 327): VFY: unable to resolve check-cast 98
(Ljava/rmi/RemoteException;) in Lorg/jdom/JDOMException;
W/dalvikvm( 327): VFY: rejecting opcode 0x1f at 0x003d
W/dalvikvm( 327): VFY: rejected
Lorg/jdom/JDOMException;.getNestedException
(Ljava/lang/Throwable;)Ljava/lang/Throwable;
W/dalvikvm( 327): Verifier rejected class Lorg/jdom/JDOMException;
D/AndroidRuntime( 327): Shutting down VM
W/dalvikvm( 327): threadid=3: thread exiting with uncaught exception
(group=0x40010e28)
E/AndroidRuntime( 327): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 327): java.lang.VerifyError: org.jdom.JDOMException
I looked at the JDOM source code and noticed that org.jdom.JDOMException
uses java.rmi.RemoteException:
if (parent instanceof RemoteException) {
return ((RemoteException)parent).detail;
}
In order for this code to run on Android, we would need to eliminate
java.rmi.RemoteException from JDOMException.java
One possible fix (?) is to use reflection to retrieve the "detail" field:
if (parent.getClass().getName().startsWith("java.rmi.")) {
try {
Field f = parent.getClass().getField("detail");
return (Throwable) f.get(parent);
} catch (Exception ignore) {
// ignored
}
}
Using 'startsWith' is a hack. The intent is to detect
java.rmi.RemoteException as well as all
subclasses of java.rmi.RemoteException from the java.rmi pacakge.
http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/RemoteException.html
Is there a better way to code this? Any other comments?
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20081122/3df43c07/attachment-0001.htm
------------------------------
Message: 2
Date: Sun, 23 Nov 2008 00:09:34 -0300
From: "Fabio Leal" <fabioleal.ufcg at gmail.com>
Subject: [jdom-interest] Jdom with XMI Files
To: jdom-interest at jdom.org
Message-ID:
<acc6a2a30811221909m21da7d26n77daf2a98b860e1d at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hy everybody...
I'm trying to manipulate a XMI file with Jdom, and I have experienced some
difficulties doing it.
For example:
All the subnodes of the root Element have the "same name", but have
different attributes.
How can I choose a specific "Element", by specifying it's attributes?
Another point is that the attributes started with "xmi:" aren't recognized
by Jdom. I've already tested a bunch of things to make it recognizable, but
all of them were unsuccessful. =/
I think that my problems are quite easy to solve, but I haven't found
anything that could help me in the web.
If Jdom isn't a great tool with XMI, could you suggest me other?
*Xmi file that i want to read:
http://www.omg.org/spec/UML/20061001/Superstructure.cmof
Cheers,
Fábio Leal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20081123/08303f56/attachment-0001.htm
------------------------------
Message: 3
Date: Sun, 23 Nov 2008 13:58:22 -0000
From: "Michael Kay" <mike at saxonica.com>
Subject: RE: [jdom-interest] Jdom with XMI Files
To: "'Fabio Leal'" <fabioleal.ufcg at gmail.com>,
<jdom-interest at jdom.org>
Message-ID: <373A40C0FF5B4348A9D7581488867D89 at Sealion>
Content-Type: text/plain; charset="iso-8859-1"
It's a good idea to show the code you were using, then people can tell you
where you went wrong.
It looks a bit as if you haven't grasped how namespaces work, but without
seeing your attempts, that's a guess.
Michael Kay
http://www.saxonica.com/
_____
From: jdom-interest-bounces at jdom.org [mailto:jdom-interest-bounces at jdom.org]
On Behalf Of Fabio Leal
Sent: 23 November 2008 03:10
To: jdom-interest at jdom.org
Subject: [jdom-interest] Jdom with XMI Files
Hy everybody...
I'm trying to manipulate a XMI file with Jdom, and I have experienced some
difficulties doing it.
For example:
All the subnodes of the root Element have the "same name", but have
different attributes.
How can I choose a specific "Element", by specifying it's attributes?
Another point is that the attributes started with "xmi:" aren't recognized
by Jdom. I've already tested a bunch of things to make it recognizable, but
all of them were unsuccessful. =/
I think that my problems are quite easy to solve, but I haven't found
anything that could help me in the web.
If Jdom isn't a great tool with XMI, could you suggest me other?
*Xmi file that i want to read:
http://www.omg.org/spec/UML/20061001/Superstructure.cmof
Cheers,
Fábio Leal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20081123/d56b168f/attachment-0001.htm
------------------------------
Message: 4
Date: Sun, 23 Nov 2008 15:07:26 -0000
From: "Michael Kay" <mike at saxonica.com>
Subject: RE: [jdom-interest] Jdom with XMI Files
To: "'Fabio Leal'" <fabioleal.ufcg at gmail.com>
Cc: jdom-interest at jdom.org
Message-ID: <B5CD911C957041ACA1914AF3B58A06C9 at Sealion>
Content-Type: text/plain; charset="US-ASCII"
>
> You were right. I am quite confuse when manipulating namespaces.
> Could you give me a help there?
Please don't go off-list. When people search the archives, they want to find
the answers, not only the questions!
>
> For example, how could I get to the Element:
>
> <ownedMember xmi:type="cmof:Package" xmi:id="StateMachines"
> name="StateMachines">
>
> (this is a root's child) without using
> rootElement.getchildren() and iterating over it?
Use Element.getChild(name, namespace)
>
> How could I get its child attributes without using
> myElement.getAttributes() and iterating over it?
Use Element.getAttribute(name, namespace)
Michael Kay
http://www.saxonica.com/
------------------------------
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
End of jdom-interest Digest, Vol 49, Issue 6
********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20081124/75e335e7/attachment.htm
More information about the jdom-interest
mailing list