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

Some bookkeeping #4

Merged
merged 7 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,25 @@ on:
pull_request:
workflow_dispatch:

jobs:
jobs:
documenter-XmlStructTools:
permissions:
contents: write
pull-requests: read
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.10'
- uses: julia-actions/cache@v1
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
- name: Build and deploy
env:
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
run: julia --project=docs/ docs/make.jl
call-documenter-AbstractXsdTypes:
permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/subdirdocumenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.9'
version: '1.10'
- uses: julia-actions/cache@v1
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
Expand Down
Empty file removed AbstractXsdTypes.jl/CHANGELOG.MD
Empty file.
2 changes: 1 addition & 1 deletion AbstractXsdTypes.jl/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 ASML Netherlands B.V.
Copyright (c) 2023-2024 Tom Lemmens, ASML Netherlands B.V., and other AbstractXsdTypes.jl contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion AbstractXsdTypes.jl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ authors = ["Tom Lemmens", "Matthijs Cox"]
version = "0.1.0"

[deps]
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
Memoization = "6fafb56a-5788-4b4e-91ca-c0cea6611c73"
6 changes: 4 additions & 2 deletions AbstractXsdTypes.jl/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# AbstractXsdTypes
# AbstractXsdTypes.jl

[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://tom-lemmens.github.io/XmlStructTools.jl/AbstractXsdTypes.jl/dev/)

This package contains abstract types and generic functions used by the output of the `XsdToStruct` package.

Expand All @@ -12,4 +14,4 @@ This package also provides a `defaults` function for handling specified default

## Naive conversion

There are also some naive conversion functions included with this package. These give a "best effort" generic conversion of one type generated by XsdToStruct into another one. For example, a common use case is when an two XSD files describe compatible data types for certain particular elements but are otherwise completely different. You might have a function available written for the data type of the first schema but want to use it on data loaded from an XML file that follows the second schema. You will not be able to parse the complete XML file using the types of the first schema and a function call on the data loaded using the second schema will not dispatch to the correct function. With the naive `convert` function included in this package you can load the data of the XML and then try to convert the compatible subfield into the type from the first schema, which will then dispatch correctly.
There are also some naive conversion functions included with this package. These give a "best effort" generic conversion of one type generated by XsdToStruct into another one. For example, a common use case is when an two XSD files describe compatible data types for certain particular elements but are otherwise completely different. You might have a function available written for the data type of the first schema but want to use it on data loaded from an XML file that follows the second schema. You will not be able to parse the complete XML file using the types of the first schema and a function call on the data loaded using the second schema will not dispatch to the correct function. With the naive `convert` function included in this package you can load the data of the XML and then try to convert the compatible subfield into the type from the first schema, which will then dispatch correctly.
2 changes: 1 addition & 1 deletion AbstractXsdTypes.jl/src/AbstractXsdTypes.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module AbstractXsdTypes

using Memoization
using Formatting
using Format

include("type_definitions.jl")
include("construction_and_conversion_functions.jl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end

# format into string and parse back, if these are equal we are ok
max_fraction_digits = get_max_fraction_digits(T)
value_string = sprintf1("%.$(max_fraction_digits)f", value)
value_string = cfmt("%.$(max_fraction_digits)f", value)

if parse(S, value_string) != value
throw(
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# XmlStructTools.jl

[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://tom-lemmens.github.io/XmlStructTools.jl/dev/)

The tools in XmlStructTools.jl aim to fill the role of schema based XML data binding in Julia.
The functionality is split up into four packages:

Expand Down
Empty file removed XmlStructLoader.jl/CHANGELOG.MD
Empty file.
2 changes: 1 addition & 1 deletion XmlStructLoader.jl/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 ASML Netherlands B.V.
Copyright (c) 2023-2024 Tom Lemmens, ASML Netherlands B.V., and other AbstractXsdTypes.jl contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion XmlStructLoader.jl/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# XmlStructLoaderExampleXml
# XmlStructLoader.jl

[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://tom-lemmens.github.io/XmlStructTools.jl/XmlStructLoader.jl/dev/)

## Getting the required files

Expand Down
Empty file removed XmlStructWriter.jl/CHANGELOG.MD
Empty file.
2 changes: 1 addition & 1 deletion XmlStructWriter.jl/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 ASML Netherlands B.V.
Copyright (c) 2023-2024 Tom Lemmens, ASML Netherlands B.V., and other AbstractXsdTypes.jl contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion XmlStructWriter.jl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ version = "0.1.0"

[deps]
AbstractXsdTypes = "1d4aff4b-e088-40cb-b713-ffe4caf1580b"
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
4 changes: 3 additions & 1 deletion XmlStructWriter.jl/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# XmlStructWriter
# XmlStructWriter.jl

[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://tom-lemmens.github.io/XmlStructTools.jl/XmlStructWriter.jl/dev/)

## Getting the required files

Expand Down
4 changes: 2 additions & 2 deletions XmlStructWriter.jl/src/XmlStructWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module XmlStructWriter
using LightXML
using TimeZones
using Printf
using Formatting
using Format
using AbstractXsdTypes

export write_xml
Expand Down Expand Up @@ -149,7 +149,7 @@ function generate_xml_string(xml_object::AbstractXsdTypes.AbstractXSDFloat)::Str
@debug "Generating XML string from $xml_object"
if AbstractXsdTypes.fraction_digits_check in AbstractXsdTypes.get_restriction_checks(typeof(xml_object))
max_fraction_digits = AbstractXsdTypes.get_max_fraction_digits(typeof(xml_object))
xml_object = sprintf1("%.$(max_fraction_digits)f", xml_object)
xml_object = cfmt("%.$(max_fraction_digits)f", xml_object)
else
xml_object = @sprintf("%f", xml_object)
end
Expand Down
Empty file removed XsdToStruct.jl/CHANGELOG.MD
Empty file.
2 changes: 1 addition & 1 deletion XsdToStruct.jl/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 ASML Netherlands B.V.
Copyright (c) 2023-2024 Tom Lemmens, ASML Netherlands B.V., and other AbstractXsdTypes.jl contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion XsdToStruct.jl/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# XsdToStruct
# XsdToStruct.jl

[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://tom-lemmens.github.io/XmlStructTools.jl/XsdToStruct.jl/dev/)

This package generates a module with struct definitions which correspond to the data types specified in a given XML Schema file. Apart from the definitions it also generates constructors which can (partially) validate the data that is given with the restrictions specified in the schema file.

Expand Down
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
Manifest.toml
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "1.4"
13 changes: 13 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Documenter

repo = Remotes.GitHub("Tom-Lemmens", "XmlStructTools.jl")

makedocs(;
repo = repo,
sitename = "XmlStructTools.jl",
pages = ["Home" => "index.md"],
)

deploydocs(
repo="github.com/$(repo.user)/$(repo.repo)",
)
20 changes: 20 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# XmlStructTools.jl

The tools in XmlStructTools.jl aim to fill the role of schema based XML data binding in Julia.
The functionality is split up into four packages:

- XsdToStruct.jl can generate Julia struct definitions from XSD files.
- AbstractXsdTypes.jl contains the shared functionality that is common between different XSD struct types.
- XmlStructLoader.jl can use the module generated by AbstractXsdTypes.jl to validate and load XML files into the
generated struct definitions.
- XmlStructWriter.jl can write XSD struct instances to valid XML files.

For a quick introduction you can watch [XML Data and Julian Types](https://www.youtube.com/watch?v=Z7qgOBNk-to)
from JuliaCon Local Eindhoven 2023 to get a quick introduction to these packages.

**Warning**
These packages are still a work in progress.
Only a small part of the entire W3C XSD recommendation is implemented.
There are already some known bugs and a fix for them is on its way.
But since this fix was developed at ASML this will take some time to go through the proper reviews.
Please be patient while we get this sorted out.
Loading