metanorma / metanorma-ogc

Metanorma processor for OGC documents
https://www.metanorma.com
BSD 2-Clause "Simplified" License
2 stars 3 forks source link

PlantUML rendering broken? #549

Closed securedimensions closed 1 year ago

securedimensions commented 1 year ago

The rendering for plantuml diagrams is broken.

The rendering of plantuml diagrams was working fine I think, but now it's broken.

Example

.Conformance Class Model
[plantuml]
....
@startuml

package OGC {
    GeoXACML_Core ..d.|> GeoXACML_API: <<optional>>
    GeoXACML_Core ..d.|> GeoXACML_CRS_Transformation: <<optional>>
    GeoXACML_Spatial_Analysis -r-|> GeoXACML_Core: <<optional>>
}

package ISO {
    SimpleFeatures -o GeoXACML_Core : use
}

package OASIS {
    XACML3 <|-d- GeoXACML_Core: <<extends>>
}

abstract class SimpleFeatures {
    ISO 19125:2004
    # Geometry
    # WKT
    # WKB
    Functions ()
}

abstract class XACML3 {
    OASIS XACML 3.0
    Policy schema
    AD and ADR schema
    Functions ()
}

class GeoXACML_Core {
    # XACML DataType Geometry
    # XACML AttributeValue attribute 'srid'
    # XACML AttributeValue attribute 'precision'
    # Boolean allowTransformation=false

    Geometry encoding based on WKT and WKB
    Processing may result in 'geometry-error'

    CRS default 'urn:ogc:def:crs:OGC::CRS84'
    Processing different CRS result in 'crs-error'

    Processing may result in 'precision-error'

    Geometry Functions ()
    Spatial Relations Functions ()
    XACML Bag / Set Functions ()
}

class GeoXACML_Spatial_Analysis {
    # Boolean allowTransformation=false

    Spatial Analysis Functions ()
}

interface GeoXACML_CRS_Transformation {
    # XACML AttributeValue attribute 'allowTransformation'
    # Boolean allowTransformation={false, true}
}

interface GeoXACML_API {
    OGC OpenAPI
    OGC Landing Page
    OGC Conformance Class Page
}

@enduml
....

Visual Studio Code rendering

Rendering the code above produces the following image:

grafik

Metanorma rendering

Rendering the code above with metanorma (docker run -v "$(pwd)":/metanorma metanorma/metanorma metanorma compile -t ogc -x html,pdf --agree-to-terms 22-050.adoc) produces the following image:

grafik

ronaldtse commented 1 year ago

Thank you @securedimensions for the report.

This is interesting because Metanorma does not do anything special with PlantUML diagrams. We will investigate.

opoudjis commented 1 year ago

The command line plantuml (plantuml a.txt) does the following with the supplied PlantUML:

a

That is identical to what you are getting when Metanorma parses the document.

So clearly the Visual Studio Code implementation of PlantUML is cleverer than the command line implementation: the former is conflating package and class diagram definitions, and fleshing out classes found in the former with class definitions found in the latter. The command line tool doesn't.

opoudjis commented 1 year ago

Looking more closely at PlantUML, I refer you first to the halfway solution of embedding class definitions within packages

https://forum.plantuml.net/8975/dependency-between-packages-containing-classes?show=9003#c9003

which however does not work:

//www.plantuml.com/plantuml/png/ZLJlQzim4Fskl-9W7xp1xFL71vlfIbsNbhAEbBfiWp7AHJvdPh9a99ajfFdV9okgipYX95ySdz-zUtVtf7DZKTkk4Qn5_Xjd19Fh77wmnO9nWSR0DQdlMVxbzh5eqTOe7ZE9Ocvg0mi6xlSABfGIX19G2FNdGQCqbTAD0olvgK9XY7bWo8SX_wgJl0SPUFs6BHchfILT8QTrpUpk9fJfLKrQaYuolD-YB6ivWpidUmZcIlhoql7alWF_UJT_VbyyRYeUkl80oApLzRIpz1L5Hu3Fhn3jw3RQOo0BFv6tO7L7IwTgFELSQHffk4IB3_FMosx8wlcU2eskosXFRAk9roRqiFzI1qb0aYk_Z2aQAa59-FRv0L2MxddXeNTQSJAcnpGu1qsc4nPg2T4iaCIajTBHYjcj1aggi0T5dPQfcl7K1LAkJUeMdQOEyU4a6dENTLMH9cazmtzLNDvGu6Kzmp02VhFL3TzkEFkU1Au-Z25X_XSuWtTGa1rxto565aYICdawspW9APoUghRFGd5sjaVEjhktALuutx6E1xPGOfJFbalsamqtnqqnMTqSE3LM8xUmCdTHDwsWAqBRQGhtXWSVVZmyUfyU7HoS1DUD7Eui5Fu54utd5WGmM8kOPCLDiLE6R-CubFUmi9RZv63b22LgFWV3Vr63Ff9TzXPsZ_iXEXOHjlVCVleKbt5_4ILRWwE_bcHfrdDZ40QHZ2OKgsq6IA4pnCuTHTU8Vm00

@startuml
package OGC [
{{
class GeoXACML_Spatial_Analysis {
    # Boolean allowTransformation=false

    Spatial Analysis Functions ()
}

interface GeoXACML_API {
    OGC OpenAPI
    OGC Landing Page
    OGC Conformance Class Page
}

interface GeoXACML_CRS_Transformation {
    # XACML AttributeValue attribute 'allowTransformation'
    # Boolean allowTransformation={false, true}
}

class GeoXACML_Core {
    # XACML DataType Geometry
    # XACML AttributeValue attribute 'srid'
    # XACML AttributeValue attribute 'precision'
    # Boolean allowTransformation=false

    Geometry encoding based on WKT and WKB
    Processing may result in 'geometry-error'

    CRS default 'urn:ogc:def:crs:OGC::CRS84'
    Processing different CRS result in 'crs-error'

    Processing may result in 'precision-error'

    Geometry Functions ()
    Spatial Relations Functions ()
    XACML Bag / Set Functions ()
}
    GeoXACML_Core ..d.|> GeoXACML_API: <<optional>>
    GeoXACML_Core ..d.|> GeoXACML_CRS_Transformation: <<optional>>
    GeoXACML_Spatial_Analysis -r-|> GeoXACML_Core: <<optional>>

}}
]

package ISO [
{{
abstract class SimpleFeatures {
    ISO 19125:2004
    # Geometry
    # WKT
    # WKB
    Functions ()
}

}}
]

package OASIS [
{{
abstract class XACML3 {
    OASIS XACML 3.0
    Policy schema
    AD and ADR schema
    Functions ()
}
     XACML3 <|-d- OGC.GeoXACML_Core: <<extends>>

}}
]

     ISO.SimpleFeatures -o OGC.GeoXACML_Core : use
@enduml

--- the classes and packages are drawn, but the diagram cannot comprehend arrows drawn from one package to another at all: you can see that both the namespaced ISO.SimpleFeatures -o OGC.GeoXACML_Core : use outside the ISO package, and the un-namespaced XACML3 <|-d- OGC.GeoXACML_Core: <<extends>> within the OASIS package, are ignored.

I then refer you to the current PlantUML solution, implemented as of February 2023, which is to conflate namespaces and packages completely. PlantUML command-line will simply not deal with all three of packages, class definitions, and class relations, as far as I can tell; and by getting rid of packages completely and replacing them with namespaces, you are no longer forcing it to.

So the following does work:

//www.plantuml.com/plantuml/png/bLHRRzem57xdLnof3spIoEXbqXOnr92g5Led447Rtj31EM6M73ko7Mq8-j_dM34R3LCf3oJ-pkNxpYM-DHQrhKlHwu7xpHxIw87KZoJz-hXAbIQ8eZpQZuyDoNmQmsYaAikLH34Ulo8sNMIhfKPf2gLBR1Ayb2ghd1kALUBiMyCD3FHWF-xIFSlZ4qspMPJniX9qJsXhJIvQdL0QGsseRK6IJRF8swvXj1_aWzDKzDkIp4t3rCEriHgP1IRGc5Eiko07BZzTNds8huR36mzTWCjSajNRzlZzo_BmDl5lzxLaJLa6thpjFNNOZWJl_jO07eBhQEYnkHASRS6mdrIYHv8xG9cxnoAWfzWyIRS5BTD5otA75fVRYewh2TR4MitNjQLlA6e234Ve6ytp_fc-bIR6ZPCM0YPA2K89A8JwTRnKdmiKOQ914f1aAkTo0siqb8EIJRDz3qAhvrenCgRnAN4BRdAriC0bz3TjaW5fhRHN0FxFBJJaL63ZsA-rZDM6nGw8cJQnQriSEu-FD_td-NDU5AH9Md3sVvbSN8Va_xeEJUd4XBAF9kejxHS52nBe3LqNFmkOu0RUGqRsdAteVAUxruqfg0hn7KukBUa26Rrqey3kp8tgAZfhjtPUzJkmkgQdqyh2FTbASJ3CAf8EEPmVKVfbdEE63c2gfEUHZ23rFVPcnz6x9PdNfVW3

@startuml
OGC.GeoXACML_Core ..d.|> OGC.GeoXACML_API: <<optional>>
    OGC.GeoXACML_Core ..d.|> OGC.GeoXACML_CRS_Transformation: <<optional>>
    OGC.GeoXACML_Spatial_Analysis -r-|> OGC.GeoXACML_Core: <<optional>>

    ISO.SimpleFeatures -o OGC.GeoXACML_Core : use

    OASIS.XACML3 <|-d- OGC.GeoXACML_Core: <<extends>>

abstract class ISO.SimpleFeatures {
    ISO 19125:2004
    # Geometry
    # WKT
    # WKB
    Functions ()
}

abstract class OASIS.XACML3 {
    OASIS XACML 3.0
    Policy schema
    AD and ADR schema
    Functions ()
}

class OGC.GeoXACML_Core {
    # XACML DataType Geometry
    # XACML AttributeValue attribute 'srid'
    # XACML AttributeValue attribute 'precision'
    # Boolean allowTransformation=false

    Geometry encoding based on WKT and WKB
    Processing may result in 'geometry-error'

    CRS default 'urn:ogc:def:crs:OGC::CRS84'
    Processing different CRS result in 'crs-error'

    Processing may result in 'precision-error'

    Geometry Functions ()
    Spatial Relations Functions ()
    XACML Bag / Set Functions ()
}

class OGC.GeoXACML_Spatial_Analysis {
    # Boolean allowTransformation=false

    Spatial Analysis Functions ()
}

interface OGC.GeoXACML_CRS_Transformation {
    # XACML AttributeValue attribute 'allowTransformation'
    # Boolean allowTransformation={false, true}
}

interface OGC.GeoXACML_API {
    OGC OpenAPI
    OGC Landing Page
    OGC Conformance Class Page
}
@enduml
opoudjis commented 1 year ago

I am reasonably confident that the Visual Studio rendering of PlantUML that you are appealing to has never worked with command-line PlantUML, and therefore with Metanorma. Metanorma uses the command-line implementation alone; please refer to that in future.

securedimensions commented 1 year ago

Thanks a lot!