How to define a container with an alias without a name

0 votes
asked Apr 14, 2021 in Question / help by kasra (1,040 points)

hi,

i would like to define a container ( rectangle, node...) with an alias for referencing it in a relationship but without a name.

Unfortunately, this is not working : 

rectangle  as r1 {

  rectangle child1

  rectangle child2

}

we must do 

rectangle " some name" as r1 

{

  rectangle child1

  rectangle child2

}

In that case, r1 is used for the relationships, and "some name" is the displayed name

Or 

rectangle  r1 

{

  rectangle child1

  rectangle child2

}

In that case, r1 is used for the relationships and is also the displayed name

Is it possible to wrap elements into a container with only an alias without a  displayed name?

thanks

2 Answers

+1 vote
answered Apr 14, 2021 by Martin (9,120 points)
selected Apr 14, 2021 by kasra
 
Best answer

Don't ask me why it works; and I'm not sure whether it will work on all Platforms.  But on my Windows 10, I can do this:

@startuml
rectangle "<U+0000>" as R1 {
  rectangle Child1
  rectangle Child2
}

rectangle "<U+000A>" as R2 {
  rectangle Child3
  rectangle Child4
}

rectangle "<U+000D>" as R3 {
  rectangle Child5
  rectangle Child6
}

R1 --> R2
Child4 --> Child5
@enduml

i.e. control characters 0,10, or 13 all create an empty title.

commented Apr 14, 2021 by kasra (1,040 points)
I will not ask you if it's portable or not, I just say thank you for sharing your solution ;-) !

I am on windows 10 either and your solution works for me.

Kasra
+1 vote
answered Apr 14, 2021 by The-Lu (70,400 points)

Hello K.,

A first workaround will be to use " ":

@startuml
rectangle " " as r1 {
  rectangle child1
  rectangle child2
}
@enduml

But with that, we observe an empty white line on the top of  rectangle!

If that can help,
Regards,
Th.

commented Apr 14, 2021 by kasra (1,040 points)
Thanks for the quick reply!

I actually found that solution but as you said there is an empty line on the top.

I do believe that is so far the best solution.

Should I suggest that as a wanted feature?

Thanks again.

Regards,

Kasra
...