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

BC: [XML] schema: convert simple nested-elements to attributes #250

Open
jkowalleck opened this issue Jun 16, 2023 · 0 comments
Open

BC: [XML] schema: convert simple nested-elements to attributes #250

jkowalleck opened this issue Jun 16, 2023 · 0 comments

Comments

@jkowalleck
Copy link
Member

jkowalleck commented Jun 16, 2023

Have things attributes, instead of child elements,
if they are simple and describe the entity/element and don't need to be contained.

from things like this

<workflow>
  <task>
    <uid>fsdkfjklsdf<uid>
    <name>my task<name>
    <startDate>2020-07-10T15:00:00Z</startDate>
    <endDate>2020-07-10T16:00:00Z</endDate>
    <command>ls -lisah .</command>
    <command>rm -rf foo</command>
  <task>
<workflow>

to this like this

<workflow>
  <task uid="fsdkfjklsdf"
        name="my task"
        startDate="2020-07-10T15:00:00Z"
        startDate="2020-07-10T16:00:00Z"
>
    <command>ls -lisah .</command>
    <command>rm -rf foo</command>
  <task>
<workflow>

benefits of attributes over elements:

  • i could write XPATH queries easily for an element based on some attribute. selecting on a child-element with a certain content is hard
  • said XPATH could be used in XSD's key and keyref and unique constraints and rules.
  • said XPATH could be used by downstream consumers of a BOM xml, if they want to query the document.

examples:

  • i could query one/all BOM documents ad find all tasks that have a dateDiff of started-to-done-interval of more than 10 minutes,
    instead of jumping to :parent here and there (if it was possible with nested-elements at all)

PS: you guys told me it was hard for you to get an idea what should be an attribute in XML and what a nested element, as you are more used to JSON and YAML.
maybe this helps to get the right idea:

  • if you write a property in JSON schema, then it is an attribute in XML, not a nested element.
  • If you write an array JSON schema, then the elements should be nested in XML, not attributes.
@jkowalleck jkowalleck added this to the 2.0 milestone Jun 16, 2023
@jkowalleck jkowalleck changed the title schema optimizations: convert nested-elements to attributes XML schema optimizations: convert nested-elements to attributes Jun 16, 2023
@jkowalleck jkowalleck changed the title XML schema optimizations: convert nested-elements to attributes XML schema optimizations: convert simple nested-elements to attributes Jun 16, 2023
@jkowalleck jkowalleck changed the title XML schema optimizations: convert simple nested-elements to attributes XML schema: convert simple nested-elements to attributes Jul 1, 2023
@jkowalleck jkowalleck changed the title XML schema: convert simple nested-elements to attributes BC: [XML] schema: convert simple nested-elements to attributes Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant