2

I want to generate a package diagram with hierarchical packages which may contain duplicated names but not in the same level. e.g.:

@startuml
package A {
    package B {
        package C
    }
    package A
}
@enduml

I think, package A.A might be acceptable. But plantuml failed with this error: Thie element (A) is already defined.

I also try the following:

@startuml
folder A {
    folder B {
        folder C
    }
    folder A
}
@enduml

Then, plantuml failed with the same error.

Vivodo
  • 1,542
  • 2
  • 17
  • 31

2 Answers2

6

One of the options :

@startuml
package A as pkg0{
    package B as pkg1{
    }
    package A as pkg2{
        package A as pkg3{
        }
    }
    package A as pkg4{
    }
}
@enduml

will give result

enter image description here

Nikhil
  • 849
  • 8
  • 10
2

You can draw diagrams with duplicated names if you include non-printing characters in the definition, e.g. by putting the name in quotes and including one or more space characters:

@startuml
package A {
    package B {
        package C
    }
    package "A "
    package "A  "
}
@enduml

The additional spaces do not affect the layout in the diagram:

UML class diagram with duplicated packages

JRI
  • 1,766
  • 13
  • 25