Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Problem in a loop parcour XML
Problem in a loop parcour XML [message #882028] Tue, 05 June 2012 12:50 Go to next message
Hela Hakim is currently offline Hela Hakim
Messages: 20
Registered: May 2012
Junior Member
Hello all,
is the following XML file (ci_joint) and the both following code
        for (Element lifeline : lifelineElements) {
            for (Element message : messagesElements) {

                for (Element boundary : boundaryChildren) {
                    for (Element control : controlChildren) {
                        Boolean messageEmi = lifeline.getAttributeValue("coveredBy")
                                .contains(message.getAttributeValue("sendEvent"));


                        Boolean boundaryLifeline = lifeline.getAttributeValue("id", namespaces.get("xmi"))
                                .equals(boundary.getAttributeValue("base_Lifeline"));

                        // System.out.println(message.getAttributeValue("name"));
                        if (messageEmi && boundaryLifeline)  


                        {

                            System.out.println("l'objet source du message " + message.getAttributeValue("name")
                                    + "est une frontiére");


                        }}}}}

et
for (Element lifeline : lifelineElements) {
            for (Element message : messagesElements) {


                for (Element control : controlChildren) {

                    Boolean controleLifeline = lifeline.getAttributeValue("id",
                            namespaces.get("xmi")).equals(
                                    control.getAttributeValue("base_Lifeline"));

                    Boolean messageRecu = lifeline.getAttributeValue(
                            "coveredBy").contains(
                                    message.getAttributeValue("receiveEvent"));

                    if (messageRecu && controleLifeline)

                    {
                        System.out.println("l'objet destination du message "
                                + message.getAttributeValue("name")
                                + "est un controle ");


                    }
                }
            }
        }


each of these two code gives good resulats is displaying the first code is:
"l'objet source du message switchoff()est une frontiére"
the result of the second code is:
"l'objet destination du message switchoff()est un controle
l'objet destination du message performshutdown()est un controle "
I now want to test that combines two code in other words i want a test that has as result:
"le message switch off() a comme source une frontiere et comme destination un controle"
I'm really stuck for days .. Rolling Eyes
Thank you for any help
Re: Problem in a loop parcour XML [message #882045 is a reply to message #882028] Tue, 05 June 2012 13:34 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4026
Registered: July 2009
Senior Member
Hi

I've no idea what you want. Your requirement for

"le message switch off() a comme source une frontiere et comme destination un controle"

bears no relationship to the rest of your message.

Your complex use of Java reminds me of the benefits of OCL.

Since you're using Java, use your Java debugger.

Regards

Ed Willink

On 05/06/2012 17:50, Hela Hakim wrote:
> Hello all,
> is the following XML file (ci_joint) and the both following code
> for (Element lifeline : lifelineElements) {
> for (Element message : messagesElements) {
>
> for (Element boundary : boundaryChildren) {
> for (Element control : controlChildren) {
> Boolean messageEmi = lifeline.getAttributeValue("coveredBy")
> .contains(message.getAttributeValue("sendEvent"));
>
>
> Boolean boundaryLifeline = lifeline.getAttributeValue("id", namespaces.get("xmi"))
> .equals(boundary.getAttributeValue("base_Lifeline"));
>
> // System.out.println(message.getAttributeValue("name"));
> if (messageEmi&& boundaryLifeline)
>
>
> {
>
> System.out.println("l'objet source du message " + message.getAttributeValue("name")
> + "est une frontiére");
>
>
> }}}}}
> et for (Element lifeline : lifelineElements) {
> for (Element message : messagesElements) {
>
>
> for (Element control : controlChildren) {
>
> Boolean controleLifeline = lifeline.getAttributeValue("id",
> namespaces.get("xmi")).equals(
> control.getAttributeValue("base_Lifeline"));
>
> Boolean messageRecu = lifeline.getAttributeValue(
> "coveredBy").contains(
> message.getAttributeValue("receiveEvent"));
>
> if (messageRecu&& controleLifeline)
>
> {
> System.out.println("l'objet destination du message "
> + message.getAttributeValue("name")
> + "est un controle ");
>
>
> }
> }
> }
> }
>
> each of these two code gives good resulats is displaying the first code is:
> "l'objet source du message switchoff()est une frontiére"
> the result of the second code is:
> "l'objet destination du message switchoff()est un controle
> l'objet destination du message performshutdown()est un controle "
> I now want to test that combines two code in other words i want a test that has as result:
> "le message switch off() a comme source une frontiere et comme destination un controle"
> I'm really stuck for days .. :roll:
> Thank you for any help
>
Previous Topic:How to fix a "Package with uri not found." error
Next Topic:Collaborative work on UML models
Goto Forum:
  


Current Time: Thu Aug 21 08:08:54 EDT 2014

Powered by FUDForum. Page generated in 0.02330 seconds