|
| Re: XML and JDOM [message #880474 is a reply to message #880284] |
Sat, 02 June 2012 00:36   |
Ed Merks Messages: 24557 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hela,<br>
<br>
This isn't a UML question,it's a jdom question. It's hard to
imagine what useful thing you're trying to accomplish by processing
directly UML2's XML/XMI serialization rather than working with UML2
instances directly. Have you noted the distinction between these
two methods?<br>
<br>
<table summary="" border="1" cellpadding="3" cellspacing="0"
width="100%">
<tbody>
<tr class="TableRowColor" bgcolor="white">
<td align="right" valign="top" width="1%"><font size="-1">
<code> java.lang.String</code></font></td>
<td><code><b><a
href="http://www.jdom.org/docs/apidocs/org/jdom2/Element.html#getAttributeValue%28java.lang.String%29">getAttributeValue</a></b>(java.lang.String attname)</code>
<br>
This returns the attribute value for the
attribute with the given name and within no namespace, null
if there is no such attribute, and the empty string if the
attribute value is empty.</td>
</tr>
<tr class="TableRowColor" bgcolor="white">
<td align="right" valign="top" width="1%"><font size="-1">
<code> java.lang.String</code></font></td>
<td><code><b><a
href="http://www.jdom.org/docs/apidocs/org/jdom2/Element.html#getAttributeValue%28java.lang.String,%20org.jdom2.Namespace%29">getAttributeValue</a></b>(java.lang.String attname,
<a
href="http://www.jdom.org/docs/apidocs/org/jdom2/Namespace.html"
title="class in org.jdom2">Namespace</a> ns)</code>
<br>
This returns the attribute value for the
attribute with the given name and within the given
Namespace, null if there is no such attribute, and the empty
string if the attribute value is empty.</td>
</tr>
</tbody>
</table>
<br>
<br>
On 01/06/2012 9:03 PM, Hela Hakim wrote:
<blockquote cite="mid:jqb3lq$7bq$1@xxxxxxxxe.org" type="cite">
<pre wrap="">Hello all,
this is a XML file (generated by papyrus (. uml)).
*****file XML*******
see joint
********************
I am willing to go before I draw the handle.
This is a JAVA code for the following parcour and display an attribute "xmi: version" of the root. but the display is null, why?
*****code de la classe JDOM2*********
import java.io.*;
import org.jdom2.*;
import org.jdom2.input.*;
import java.util.List;
import java.util.Iterator;
public class JDOM2
{
static org.jdom2.Document document;
static Element racine;
public static void main(String[] args)
{
//On crée une instance de SAXBuilder
SAXBuilder sxb = new SAXBuilder();
try
{
//On crée un nouveau document JDOM avec en argument le fichier XML
document = sxb.build(new File("C:\\Users\\Hela\\Desktop\\HelaEclipseJDK\\Etudedecas\\etude.uml"));
}
catch(Exception e){}
//On initialise un nouvel élément racine avec l'élément racine du document.
racine = document.getRootElement();
System.out.println(racine.getAttributeValue("xmi:version"));
}}
thanks for your help :)
</pre>
</blockquote>
</body>
</html>
|
|
|
|
| Re: XML and JDOM [message #880558 is a reply to message #880535] |
Sat, 02 June 2012 05:28   |
Vlad Varnica Messages: 546 Registered: July 2009 Location: Milton Keynes - UK |
Senior Member |
|
|
I think that your demand is very interesting and why not to use JDOM ? This is a great xml/java tool and it could read UML2 models as well at xml level if you use Omondo EclipseUML. You can not do it with other open source tools because there are many transformations stages between MOF and the UML diagram which makes it impossible.
Many advantages to this approach. The first is that what is changed with JDOM is live synchronized in the UML diagram. Yes, it is possible to change your model with JDOM and see live synchronization in your diagram. Whaooo !!
Why live synchronization should only be apply at code level between the code and the model ? Metamodel / Model live serialization is also as important as code live synchronization.
Please note that if you want to add your own JDOM code and create complex applications you will be able to do it directly from an UML diagram deployed by Omondo.
You can also create live stereotypes and get java annotations for ORM persistence.
Good initiative - Keep Going -
Bonne chance Hela pour votre projet 
[Updated on: Sat, 02 June 2012 05:39] Report message to a moderator
|
|
|
| Re: XML and JDOM [message #880587 is a reply to message #880535] |
Sat, 02 June 2012 07:04  |
Ed Merks Messages: 24557 Registered: July 2009 |
Senior Member |
|
|
Hela,
Read the Javadoc. Note in particular that the method you're calling is
looking for an attribute in no namespace, but the attribute you're
looking for is in the xmi prefix's namespace. And as I said before,
this forum is not the place to be asking about how to use JDOM.
On 02/06/2012 10:08 AM, Hela Hakim wrote:
> I dont understand you :(
|
|
|
Powered by
FUDForum. Page generated in 0.03062 seconds