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

XML not serialized properly #15

Closed
MarkNahabedian opened this issue Jul 1, 2023 · 1 comment
Closed

XML not serialized properly #15

MarkNahabedian opened this issue Jul 1, 2023 · 1 comment

Comments

@MarkNahabedian
Copy link

I'm in the process of upgrading TabletWeaving.jl to use XML.jl v0.3.

I have a function that generates HTML:

using TabletWeaving
using Colors
color1 = RGB(1, 0, 0)
color2 = RGB(0, 1, 0)
image = [ color1 color1;
          color1 color2;
          color2 color1;
          color1 color2;
          color2 color1 ]
pattern = TabletWeavingPattern("test", image;
                               threading_function = symetric_threading!)
p = pretty(pattern)
Node Element <html> (2 children)
XML.children(p)
2-element Vector{Node}:
 Node Text "Node Element <head> (1 child)"
Node Text "Node Element <body> (2 children)"

When I try to serialize it though, I get

XML.write(p)
"&lt;html&gt;\n  Node Element &lt;head&gt; (1 child)\n  Node Element <body> (2 children)\n&lt;/html&gt;"

as if XML.write is recursing to Base.write rather than XML.write when serializing an element's children.

NOTE that I needed to explicitly escape the less than and greater thans in that output because the GitHub issues substrate was being stupid.

I found this bug because TabletWeaving.jl has tests that use EzXML.jl to parse its HTML output so that tests can use XPath to find and test parts of the document.

Perhaps XML.jl should test that it can parse what it has serialized.

I'm not sure how you wich to resolve this.

My inclination would be to explicitly overload Base.write in XML.jl/src/XML.jl and explicitly specialize those methods to XML.Node.

@MarkNahabedian
Copy link
Author

Oops. My bug. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant