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

expand_entity: :never does not preserve the 
 entity as expected #136

Open
LFelicien opened this issue Jan 25, 2025 · 0 comments
Open

Comments

@LFelicien
Copy link

LFelicien commented Jan 25, 2025

Hello,

I'm using Saxy to parse .docx files, and I need to preserve certain entities exactly as they appear in the XML content—for instance, (line feed) present in attributes such as o:gfxdata.

According to the documentation, the expand_entity: :never option is supposed to keep entity references literal in the output (rather than converting them to the character \n). However, in my tests, still ends up converted or normalized, and I no longer see in the resulting DOM structure.

Minimal example:

xml = ~s|<tag attr="Base64&#xA;MoreBase64" />|
{:ok, dom} = Saxy.SimpleForm.parse_string(xml, expand_entity: :never)
# Expected behavior: the attribute value should remain "Base64&#xA;MoreBase64".
# Actual behavior: the entity &#xA; seems to be turned into something else.
IO.inspect(dom)

The specification for the :never setting suggests that the entity should not be resolved, i.e., it should be emitted as in the final structure. Is this a bug, or is there an internal XML normalization step affecting line feeds in attributes?

Thank you in advance for your help!

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