Unable to have relation on quoted name & nested element

0 votes
asked Jan 29, 2023 in Question / help by anonymous

Following text produces below diagram. For "a" - "c" part, how can I have the nesting element "a" linked to nesting element "c"? ("b" - "d" is working as expected.)

@startuml
rectangle "a" {
  rectangle "b"
}
rectangle "c" {
  rectangle "d"
}
"a" - "c"
"b" - "d"
@enduml

If I remove the quotes, it works as expected. But in my diagram I wish to use dash in name, so I cannot do so. If I remove the nested elements ("b", "d"), it works as expected. But in my diagram I wish to have nested elements. If I add alias to "a", "c" (e.g. rectangle "a" as a) and use the alias (a - c), it works as expected. But I wish to avoid having alias because it's repetitive.

1 Answer

0 votes
answered Jan 30, 2023 by albert (3,520 points)

It is possible to have in labels dashes but one has to explicitly name the node as well (by default the node name and the label name are the same.

This would result in something like (though the lines are not straight):

@startuml
rectangle "a-xx" as a1 {
  rectangle "b" as b1
}
rectangle "c-yy" as c1 {
  rectangle "d" as d1
}
a1 - c1
b1 - d1

@enduml
commented Jan 30, 2023 by anonymous

Hello albert, thank you for answering.
I also reached to same solution as I wrote in the question.

If I add alias to "a", "c" (e.g. rectangle "a" as a) and use the alias (a - c), it works as expected. 

But do you know any way to do without alias? The reason I wish to avoid this solution is because using labels are repetitive and cannot use some characters.

commented Jan 30, 2023 by albert (3,520 points)
Sorry missed that comment, I saw the remark about the dash and concentrated only on that one.
...