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

fn:elements-to-maps: Mixed Content #1644

Open
ChristianGruen opened this issue Dec 6, 2024 · 3 comments
Open

fn:elements-to-maps: Mixed Content #1644

ChristianGruen opened this issue Dec 6, 2024 · 3 comments
Labels
Editorial Minor typos, wording clarifications, example fixes, etc. XQFO An issue related to Functions and Operators

Comments

@ChristianGruen
Copy link
Contributor

ChristianGruen commented Dec 6, 2024

Even though the function may not be used primarily for mixed content, we should make it easier to convert such XML input to maps/JSON.

If I understand correctly, the safest solution to retrieve a consistent result currently is:

fn:elements-to-maps(
  $mixed-content,
  { "disable-layouts": ("empty", "empty-plus",
      "simple", "simple-plus", "list",
      "list-plus", "record", "sequence")
  }
)

Maybe we can simplify this? If we had an inclusive option, it could possibly be:

fn:elements-to-maps(
  $mixed-content,
  { "enable-layouts": "mixed" }
)

We could also consider xml:space=''preserve attributes and apply mixed to all descendant nodes (but it shouldn't be the only solution).

Related: #1592

@ChristianGruen ChristianGruen added XQFO An issue related to Functions and Operators Editorial Minor typos, wording clarifications, example fixes, etc. labels Dec 6, 2024
@michaelhkay
Copy link
Contributor

I believe that JSON handles mixed content so badly that few people are going to want to convert "narrative" documents to JSON, and we should not distort the design in order to improve the way this case is handled.

@ChristianGruen
Copy link
Contributor Author

I believe it could be a very general requirement to convert XML to JSON as lossless as possible, and to use a representation that at least simplifies converting the data back to XML in a unified way. For those use cases, it could be tedious to exclude all layouts in the function call to enforce the use of the mixed layout.

I believe that JSON handles mixed content so badly that few people are going to want to convert "narrative" documents to JSON

I am not so sure about that. I am aware of at least one use case in which TEI data is converted to JsonML (and back to XML later on). It is not related to the work that @dariok discussed on Slack and in #1592.

@ChristianGruen
Copy link
Contributor Author

Name wildcards could be an alternative:

fn:elements-to-maps(
  $mixed-content,
  { "layouts": { "*": "mixed" } }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Editorial Minor typos, wording clarifications, example fixes, etc. XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

2 participants