qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qexo-general] 2 times functions applying problems


From: Gregoire DUPE
Subject: [Qexo-general] 2 times functions applying problems
Date: Tue, 11 Mar 2003 11:52:04 +0100
User-agent: KMail/1.4.3

Hi,

I wrote a function called add_attr( I give the code at the end of this mail).

This function has 3 parameters :
        - $doc is an XMI document,
        - $class_name is the name of an UML:Class included in $doc,
        - $attr is an UML:Attributes node.

The goal of this function is to add the node $attr in the node tree of the 
$class_name UML:Class.

When I use it once it works. But when I apply it a second time on the result 
of the first run, it doesn't give the expected answer.

Explaination:

-> 1 time :

let $doc := document("test9.xmi"),
$attrs := 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:address@hidden"Class_2"]/UML:Classifier.feature/UML:Attribute,
$doc1 := add_attr($doc,"Class_1",$attrs[1])
return
  $doc1

The answer is just what I'm expecting the attribute_3 has been had to the 
Class_1.

-> 2 times :
  
let $doc := document("test9.xmi"),
$attrs :=                                                                       
                                                                         
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:address@hidden"Class_2"]/UML:Classifier.feature/UML:Attribute,
$doc1 := add_attr(add_attr($doc,"Class_1",$attrs[1]),"Class_1",$attrs[2])
return
  $doc1
 
The answer is quite empty, no header, no class, just the added "attributes":
 
(The exact answer is at the end the mail)

It's just like if the answer of add_attr($doc,"Class_1",$attrs[1]) was quite 
empty.

But the most surprising point, is that, if I copy/past the answer of the 1 
time run in a file (called answer.xmi). And run my function on this new file 
(see the code above). I get the result I'm expecting ! 

let $doc := document("answer.xmi"),
$attrs := 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:address@hidden"Class_2"]/UML:Classifier.feature/UML:Attribute,
$doc1 := add_attr($doc,"Class_1",$attrs[2])
return
  $doc1

I add in the attachment my XMI test file (test9.xmi) and the file anwser.xmi.

Is somebody able to give an explaination ? Is it an error from me or just a 
bug ?


Thanks a lot in advance for your answers.

Greg


PS : I'm using the CVS version





add_attr function ------------------------------------------------------

declare namespace UML = "org.omg.xmi.namespace.UML"
declare namespace xmlns = "xmlns"

define function add_attr($doc , $class_name, $attr2add){
<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML'>
  {$doc//XMI.header}
  <XMI.content>
    <UML:Model xmi.id="{$doc//XMI.content/UML:Model/@xmi.id}" 
name="{$doc//XMI.content/UML:Model/@name}" 
isRoot="{$doc//XMI.content/UML:Model/@isRoot}" 
isLeaf="{$doc//XMI.content/UML:Model/@isLeaf}" 
isAbstract="{$doc//XMI.content/UML:Model/@isAbstract}" >
      {$doc//XMI.content/UML:Model/UML:ModelElement.taggedValue}
      <UML:Namespace.ownedElement>
      {
      for $class in 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Class
      where $class/@name!=$class_name
      return
        $class
      }
      {
      let $class := 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:address@hidden
      return
        <UML:Class xmi.id="{$class/@xmi.id}" name="{$class/@name}" 
visibility="{$class/@visibility}" isSpecification="{$class/@isSpecification}" 
isRoot="{$class/@isRoot}" isLeaf="{$class/@isLeaf}"  
isAbstract="{$class/@isAbstract}" isActive="{$class/@isActive}">
          {$class//UML:ModelElement.taggedValue}
          <UML:Classifier.feature>
          {
          for $attr in $class//UML:Classifier.feature/UML:Attribute
          return
            $attr
          }
          {$attr2add}
          </UML:Classifier.feature>
        </UML:Class> 
      }
      {
      for $package in 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package
      return
        $package
      }
      {
      for $association in 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Association
      return
        $association
      }
      {
      for $generalization in 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization
      return
        $generalization
      }
      {
      for $tag_def in 
$doc//XMI.content/UML:Model/UML:Namespace.ownedElement/UML:TagDefinition
      return
        $tag_def
      }
      </UML:Namespace.ownedElement>
    </UML:Model>
  </XMI.content>
</XMI>
}

answer of the 2 times 
run-------------------------------------------------------------------------

<XMI xmi.version="1.2" xmlns:UML="org.omg.xmi.namespace.UML">
  <XMI.content>
    <UML:Model xmi.id="a1" name="model 1" isRoot="false" isLeaf="false" 
isAbstract="false">
      <UML:Namespace.ownedElement>
      <UML:Class xmi.id="a4" name="Class_1" visibility="public" 
isSpecification="false" isRoot="false" isLeaf="false" isAbstract="false" 
isActive="false">
          <UML:Classifier.feature>
          <UML:Attribute xmi.id="a16" name="attribute_4" visibility="private" 
isSpecification="false" ownerScope="instance">
              <UML:ModelElement.taggedValue>
                <UML:TaggedValue xmi.id="a17" isSpecification="false" 
dataValue="-64--88-50-35-834e7:f3c96e9eb2:-7ff3">
                  <UML:TaggedValue.type>
                    <UML:TagDefinition xmi.idref="a3" />
                  </UML:TaggedValue.type>
                </UML:TaggedValue>
              </UML:ModelElement.taggedValue>
              <UML:StructuralFeature.type>
                <UML:DataType xmi.idref="a8" />
              </UML:StructuralFeature.type>
            </UML:Attribute>
          </UML:Classifier.feature>
        </UML:Class>
      </UML:Namespace.ownedElement>
    </UML:Model>
  </XMI.content>
</XMI>


Attachment: answer.xmi
Description: Text document

Attachment: test9.xmi
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]