API for parsing syntax without drawing?

+1 vote
asked Jun 5, 2015 in Wanted features by anonymous
Is it possible to parse PlantUML syntax for purposes other than drawing?  My use case has us drawing UML models from the syntax, but also a desire to reuse the same text to drive other modeling behavior.  Is it possible to use the PlantUML API to parse, for example Sequence Diagrams, to stimulate other application behaviors?

2 Answers

+1 vote
answered Jun 7, 2015 by plantuml (200,240 points)
Hello,

The best option we can see for that is to use PlantUML to export a diagram to XMI format.

Since XMI is XML, it would allow you to easily parse the result.

Currently, the XMI export is really experimental (see http://plantuml.sourceforge.net/xmi.html )

However, it's difficult to find documentation about Sequence Diagram and XMI, so if anyone has some input here (or example of XMI files), please post here!
commented Jun 11, 2015 by kreuzberger (220 points)
export of a composite state engine. Example: lamp
can switch between on and off
if on
it is first cold, after some time warm

Export is from EA in Version 8 without any EA specific features and extensions in xmi

<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/UML/2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1">
    <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
    <uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
        <packagedElement xmi:type="uml:Package" xmi:id="EAPK_8CF61B11_2D04_49cf_9048_8F611FDE2096" name="Lamp" visibility="public">
            <packagedElement xmi:type="uml:StateMachine" xmi:id="EAID_SM000001_2D04_49cf_9048_8F611FDE2096" name="EA_StateMachine1" visibility="public">
                <region xmi:type="uml:Region" xmi:id="EAID_SR000001_2D04_49cf_9048_8F611FDE2096" name="EA_Region1" visibility="public">
                    <subvertex xmi:type="uml:State" xmi:id="EAID_781C439A_96B3_4d78_A93C_041C1CDFC69E" name="Off" visibility="public" isSubmachineState="false">
                        <incoming xmi:idref="EAID_B002EFCF_EC64_475b_8D7A_25CD3918BD80"/>
                        <incoming xmi:idref="EAID_0B5A7523_5DBD_48f8_B778_A815C01B57B8"/>
                        <outgoing xmi:idref="EAID_BED409F8_8B1A_4ca6_B3AB_C2EA783E5FF8"/>
                    </subvertex>
                    <transition xmi:type="uml:Transition" xmi:id="EAID_BED409F8_8B1A_4ca6_B3AB_C2EA783E5FF8" name="on" visibility="public" kind="local" source="EAID_781C439A_96B3_4d78_A93C_041C1CDFC69E" target="EAID_C0EFA44E_0F1A_4cbd_B66E_D703A3EE2434"/>
                    <subvertex xmi:type="uml:Pseudostate" xmi:id="EAID_3277689E_8D32_40f5_A279_940C843E6707" visibility="public" kind="initial">
                        <outgoing xmi:idref="EAID_0B5A7523_5DBD_48f8_B778_A815C01B57B8"/>
                    </subvertex>
                    <transition xmi:type="uml:Transition" xmi:id="EAID_0B5A7523_5DBD_48f8_B778_A815C01B57B8" visibility="public" kind="local" source="EAID_3277689E_8D32_40f5_A279_940C843E6707" target="EAID_781C439A_96B3_4d78_A93C_041C1CDFC69E"/>
                </region>
            </packagedElement>
            <packagedElement xmi:type="uml:StateMachine" xmi:id="EAID_C0EFA44E_0F1A_4cbd_B66E_D703A3EE2434" name="On" visibility="public">
                <incoming xmi:idref="EAID_BED409F8_8B1A_4ca6_B3AB_C2EA783E5FF8"/>
                <outgoing xmi:idref="EAID_B002EFCF_EC64_475b_8D7A_25CD3918BD80"/>
                <region xmi:type="uml:Region" xmi:id="EAID_SR000002_2D04_49cf_9048_8F611FDE2096" name="EA_Region2" visibility="public">
                    <subvertex xmi:type="uml:State" xmi:id="EAID_14C70402_FCEB_43cc_9EEC_420AF7DE3C3D" name="Cold" visibility="public" isSubmachineState="false">
                        <incoming xmi:idref="EAID_000FB017_164B_4cc7_95F0_59DA7D48327B"/>
                        <outgoing xmi:idref="EAID_C9A276A9_E916_463f_962D_4CB5DD521A9A"/>
                    </subvertex>
                    <transition xmi:type="uml:Transition" xmi:id="EAID_C9A276A9_E916_463f_962D_4CB5DD521A9A" name="hot" visibility="public" kind="local" source="EAID_14C70402_FCEB_43cc_9EEC_420AF7DE3C3D" target="EAID_574E5F6E_443F_488c_91FD_759339F18AFC"/>
                    <subvertex xmi:type="uml:State" xmi:id="EAID_574E5F6E_443F_488c_91FD_759339F18AFC" name="Hot" visibility="public" isSubmachineState="false">
                        <incoming xmi:idref="EAID_C9A276A9_E916_463f_962D_4CB5DD521A9A"/>
                    </subvertex>
                    <subvertex xmi:type="uml:Pseudostate" xmi:id="EAID_5108B7E9_DECD_4532_947F_138B20205575" visibility="public" kind="initial">
                        <outgoing xmi:idref="EAID_000FB017_164B_4cc7_95F0_59DA7D48327B"/>
                    </subvertex>
                    <transition xmi:type="uml:Transition" xmi:id="EAID_000FB017_164B_4cc7_95F0_59DA7D48327B" visibility="public" kind="local" source="EAID_5108B7E9_DECD_4532_947F_138B20205575" target="EAID_14C70402_FCEB_43cc_9EEC_420AF7DE3C3D"/>
                </region>
            </packagedElement>
            <transition xmi:type="uml:Transition" xmi:id="EAID_B002EFCF_EC64_475b_8D7A_25CD3918BD80" name="off" visibility="public" kind="local" source="EAID_C0EFA44E_0F1A_4cbd_B66E_D703A3EE2434" target="EAID_781C439A_96B3_4d78_A93C_041C1CDFC69E"/>
        </packagedElement>
    </uml:Model>
</xmi:XMI>
0 votes
answered Jun 10 by Ente

Hi

exactly for this reason I did start the plantuml-parser project.

The aim of this project is to provide a feature-complete, well tested, and maintainable Parsing Expression Grammar (PEG) for the PlantUML syntax. The parser is designed to be used as JavaScript library or from the Command Line.

If you are interested, I am still looking for more contributors. Any feedback welcome.

I hope this helps

...