data.xml

Emit Empty Elements using EmptyElementTag

Details

  • Type: Enhancement Enhancement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Does not apply
  • Patch:
    Code and Test

Description

Currently data.xml emits empty elements (elements without content) using start and end tags. The XML spec also allows special empty tags like <foo/>.

I need to serialize XML using such special empty tags because a device, I want to communicate with, does require empty tags. The device is just not able to parse XML messages using start and end tags.

I created a branch on GitHub where I implemented empty tags in the emit function. I'm not familiar how to create a patch. So for now here is the link to the compare view.

As I wrote in my commit message we should discuss, whether a option to the emit function would be a better solution.

Activity

Hide
Herwig Hochleitner added a comment -

I think, this is a worthwhile change, not because we want to support broken xml receivers, but because some xml dialects lean heavily on lots of attr-only tags for byte savings, even going so far as to encode whole polymorphic data structures in attr string values, as seen in svg.

For that reason, of not wanting to take on complexity arising from broken receivers, I'd vote against an emitter flag.

Would you be willing to sign a contributor's agreement and rebase your changes?

Show
Herwig Hochleitner added a comment - I think, this is a worthwhile change, not because we want to support broken xml receivers, but because some xml dialects lean heavily on lots of attr-only tags for byte savings, even going so far as to encode whole polymorphic data structures in attr string values, as seen in svg. For that reason, of not wanting to take on complexity arising from broken receivers, I'd vote against an emitter flag. Would you be willing to sign a contributor's agreement and rebase your changes?
Hide
Herwig Hochleitner added a comment -

When trying to implement this, I stumbled upon two bugs in StAX (horray!):

  • .writeNamespace implies .setPrefix
  • .writeEmptyElement doesn't setup its on namespace context and bleeds over to siblings

thus there is no way to use empty tags while relying on the built-in namespace context.

We will have to redesign the emitter to keep track of namespaces.

Show
Herwig Hochleitner added a comment - When trying to implement this, I stumbled upon two bugs in StAX (horray!):
  • .writeNamespace implies .setPrefix
  • .writeEmptyElement doesn't setup its on namespace context and bleeds over to siblings
thus there is no way to use empty tags while relying on the built-in namespace context. We will have to redesign the emitter to keep track of namespaces.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: