|
Re: XML and JDOM [message #880474 is a reply to message #880284] |
Sat, 02 June 2012 04:36 |
Ed Merks Messages: 33113 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>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: XML and JDOM [message #880587 is a reply to message #880535] |
Sat, 02 June 2012 11:04 |
Ed Merks Messages: 33113 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 :(
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.06519 seconds