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

Modify Document in-place #845

Open
gmithel opened this issue Feb 19, 2025 · 3 comments
Open

Modify Document in-place #845

gmithel opened this issue Feb 19, 2025 · 3 comments
Labels
documentation Issues about improvements or bugs in documentation

Comments

@gmithel
Copy link

gmithel commented Feb 19, 2025

I was looking at the docs about the writer:

"A XML writer. Can be nested with readers if you want to transform XMLs.
Especially for nested XML elements, the user must keep track where (how deep) in the XML document the current event is located."

I was looking and there is no documentation or an example regarding this. Is there an example that can show this happening?

@Mingun
Copy link
Collaborator

Mingun commented Feb 20, 2025

We do not have much examples of writing yet. Basically, the example from Writer is the one example of writing which also shows how to transform document (it is not "in place", but "streaming"). In that example you can see that we just check the tag name to see if we need to replace it. In case of document like

<this_tag>
  <this_tag>
    <this_tag>
    </this_tag>
  </this_tag>
</this_tag>

we will replace all three of them, while you may want to replace, say, only most nested. So you additionally should keep track the nesting level, which is increasing before procession of each Start event and decreasing after processing of the End event.

@Mingun Mingun added the documentation Issues about improvements or bugs in documentation label Feb 20, 2025
@gmithel
Copy link
Author

gmithel commented Feb 20, 2025

Ah ok, so we can't really use this method to modify a document in place really, we must make a new file?

@Mingun
Copy link
Collaborator

Mingun commented Feb 20, 2025

Yes, you need to write new document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues about improvements or bugs in documentation
Projects
None yet
Development

No branches or pull requests

2 participants