Specific Class Diagram

0 votes
asked Aug 10 in Question / help by redrocket (120 points)
Hello!

I am working to create a class diagram in PlantUML that focuses on a specific class, including all its associated elements, attributes, and relationships. However, it appears that PlantUML requires explicit definitions of each class and relationship in the text description, rather than automatically generating the diagram based on a single class of interest. Given that the schema Iā€™m dealing with includes thousands of elements, manually defining each one would be impractical and counterproductive.

Does anyone know of an automated method to define a class and generate a complete class diagram with all associated elements and relationships?
commented Aug 10 by albert (3,540 points)
What is the base language of the code from which you would like to generate the UML diagrams?

Did you think about / investigate code documenters?
commented Aug 10 by redrocket (120 points)
I am trying to generate the diagrams from a massive XML schema.

Would something like code documenters help here? I am not too familiar with that.
commented Aug 11 by albert (3,540 points)
I don't know if there are documenters around that take xml as input and output uml.

Another thought might be to use xslt to transform the xml to uml.

1 Answer

0 votes
answered Aug 20 by chris (2,780 points)
Alberts suggestion of XSLT is probably the way to go, but if you're just interested in a single class then you can throw the rest of your XML away, right? You just need to pick out the class you're interested in and then simply state out the attributes/elements for that node. If you then want the relationships you want to throw away everything that isn't "related" but it's not clear how that's defined in your schema (parent, ancestor nodes - or is there some attribute that holds the name of your node that you're looking for?).
If you know the class up front you should be able to do this in a single pass with any old XML reader (python, etc), if you're trying to use some criteria to find an interesting class in a document then you'd either need multiple passes (to test and then refine the throw away bit) or to build a bunch of indexes as you parse the doc, and then use those indexes to generate the UML

I would say, get something working first, then refine it for performance. Without further detail it is hard to suggest a more specific approach. Plantuml is ideally suited to this sort of thing, I would argue - but as XML schemas are so application specific, it's not going to be able to generate a diagram that does what you want unless you tell it what you want.

Finally, consider whether your schema can be converted to JSON (I think all XML will go to JSON, but you can't always go from JSON to XML). If so, you could convert it to JSON, then use macros in Plantuml to generate your diagrams.
...