Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support XML-based input files #202

Closed
ivanperez-keera opened this issue Jan 19, 2025 · 6 comments
Closed

Support XML-based input files #202

ivanperez-keera opened this issue Jan 19, 2025 · 6 comments
Assignees
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Feature Admin only: Change request pertaining to new features requested
Milestone

Comments

@ivanperez-keera
Copy link
Member

ivanperez-keera commented Jan 19, 2025

Description

There is a need in Ogma to support XML-based input files, since this is produced by many standard tools in the industry. Like with JSON, we want users to be able to customize the input format via a command-line flag, so that users can work with XML-based files whose format is previously unknown to Ogma without having to modify the tool.

Type

  • Feature: new capability.

Additional context

None.

Requester

  • Ivan Perez.

Method to check presence of bug

Not applicable (not a bug).

Expected result

Ogma is able to process and extract data from an input file in XML, obtaining information from a configuration file provided by the user.

Desired result

Ogma is able to process and extract data from an input file in XML, obtaining information from a configuration file provided by the user.

Proposed solution

Introduce a parsing library for XML files, and use it in ogma-core to parse input files when the user specifies that the format is XML-based.

Further notes

None.

@ivanperez-keera ivanperez-keera added CR:Status:Initiated Admin only: Change request that has been initiated CR:Type:Feature Admin only: Change request pertaining to new features requested labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Change Manager: Confirmed that the issue exists.

@ivanperez-keera ivanperez-keera added CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager and removed CR:Status:Initiated Admin only: Change request that has been initiated labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Technical Lead: Confirmed that the issue should be addressed.

@ivanperez-keera ivanperez-keera added CR:Status:Accepted Admin only: Change request accepted by technical lead and removed CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Technical Lead: Issue scheduled for fixing in Ogma 1.6.0.

Fix assigned to: @ivanperez-keera .

@ivanperez-keera ivanperez-keera added CR:Status:Scheduled Admin only: Change requested scheduled and removed CR:Status:Accepted Admin only: Change request accepted by technical lead labels Jan 19, 2025
@ivanperez-keera ivanperez-keera self-assigned this Jan 19, 2025
@ivanperez-keera ivanperez-keera added this to the 1.6.0 milestone Jan 19, 2025
@ivanperez-keera ivanperez-keera added CR:Status:Implementation Admin only: Change request that is currently being implemented and removed CR:Status:Scheduled Admin only: Change requested scheduled labels Jan 19, 2025
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
…a#202.

There is a need in Ogma to support XML-based input files, since this is
produced by many standard tools in the industry. Like with JSON, we want
users to be able to customize the input format via a command-line flag,
so that users can work with XML-based files whose format is previously
unknown to Ogma without having to modify the tool.

This commit introduces a new library to parse Ogma specifications from
XML files. The parsing functions are parameterized by the functions that
parse requirement sub-expressions, allowing for further customization,
The sub-expression parser may execute an IO-action, enabling the use of
external commands and/or LLMs to pre-process expressions. The
specification of the XML format is readable, which will also enable
parsing a format specification from an input file (either a known file
distributed with Ogma or a user-provided input file).
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
…#202.

There is a need in Ogma to support XML-based input files, since this is
produced by many standard tools in the industry. Like with JSON, we want
users to be able to customize the input format via a command-line flag,
so that users can work with XML-based files whose format is previously
unknown to Ogma without having to modify the tool.

A prior commit has introduced a library to parse Ogma specifications
from XML files.

This commit extends ogma-core to accept input files in XML, and to treat
any configuration file with the prefix "xml" as format specification for
an XML-based input file.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
There is a need in Ogma to support XML-based input files, since this is
produced by many standard tools in the industry. Like with JSON, we want
users to be able to customize the input format via a command-line flag,
so that users can work with XML-based files whose format is previously
unknown to Ogma without having to modify the tool.

A prior commit has introduced the capability to use XML files with
ogma-core.

This commit adds four XML format specifications based on two standard
formats used in known MBSE tools.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
…#202.

There is a need in Ogma to support XML-based input files, since this is
produced by many standard tools in the industry. Like with JSON, we want
users to be able to customize the input format via a command-line flag,
so that users can work with XML-based files whose format is previously
unknown to Ogma without having to modify the tool.

A prior commit has introduced a library to parse Ogma specifications
from XML files.

This commit extends ogma-core to accept input files in XML, and to treat
any configuration file containing an XMLFormat specification as format
specification for an XML-based input file.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
There is a need in Ogma to support XML-based input files, since this is
produced by many standard tools in the industry. Like with JSON, we want
users to be able to customize the input format via a command-line flag,
so that users can work with XML-based files whose format is previously
unknown to Ogma without having to modify the tool.

A prior commit has introduced the capability to use XML files with
ogma-core.

This commit adds four XML format specifications based on two standard
formats used in known MBSE tools.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Implementor: Solution implemented, review requested.

@ivanperez-keera ivanperez-keera added CR:Status:Verification Admin only: Change request that is currently being verified and removed CR:Status:Implementation Admin only: Change request that is currently being implemented labels Jan 19, 2025
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles and passes all tests. Details:
    • The solution proposed produces the expected result. Details:
      The following dockerfile uses the new parser, together with a custom XML format specification, to parse read properties from an input file and generate a Copilot monitor, checking that the produced monitor compiles correctly, after which it prints the message "Success":
      --- Dockerfile-verify-202
      FROM ubuntu:trusty
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy --constraint='happy < 2.0'
      RUN apt-get install --yes git
      
      ADD xml-custom-format /tmp/xml-custom-format
      ADD properties.xml /tmp/properties.xml
      
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install copilot-4.2 $NAME/$PAT**/ && \
          ogma standalone --input-format /tmp/xml-custom-format --file-name /tmp/properties.xml --target-dir output && \
          cabal v1-exec -- runhaskell -XPartialTypeSignatures -Wno-partial-type-signatures output/Copilot.hs && \
          echo "Success"
      
      --- xml-custom-format
      XMLFormat
        { specInternalVars    = Nothing
        , specInternalVarId   = ("//*", Nothing)
        , specInternalVarExpr = ("//*", Nothing)
        , specInternalVarType = Nothing
        , specExternalVars    = Nothing
        , specExternalVarId   = ("//*", Nothing)
        , specExternalVarType = Nothing
        , specRequirements    = ("//Requirement", Nothing)
        , specRequirementId   = ("//Requirement/@Id/text()", Nothing)
        , specRequirementDesc = Just ("//Requirement/@Id/text()", Nothing)
        , specRequirementExpr = ("//Requirement/@Text/text()", Nothing)
        }
      
      --- properties.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <Requirement name="REQ-1" Id="req1" Text="!go_too_fast" />
      
      Command (substitute variables based on new path after merge):
      $ docker run -e "REPO=https://github.com/ivanperez-keera/ogma" -e "NAME=ogma" -e "PAT=ogma" -e "COMMIT=c0af537eba86de2966172112b14fc52a1842202a" -it ogma-verify-202
      
  • Implementation is documented. Details:
    All new libraries, modules and top-level functions include documentation. Modifications to ogma-core's top-level definitions also include additional documentation.
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No updates needed.
  • Required version bumps are evaluated. Details:
    Bump not required (API is backwards compatible).

@ivanperez-keera
Copy link
Member Author

Change Manager: Implementation ready to be merged.

@ivanperez-keera ivanperez-keera added CR:Status:Closed Admin only: Change request that has been completed and removed CR:Status:Verification Admin only: Change request that is currently being verified labels Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Feature Admin only: Change request pertaining to new features requested
Projects
None yet
Development

No branches or pull requests

1 participant