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

Support custom entities #180

Open
vladchuk opened this issue Nov 2, 2023 · 1 comment
Open

Support custom entities #180

vladchuk opened this issue Nov 2, 2023 · 1 comment

Comments

@vladchuk
Copy link

vladchuk commented Nov 2, 2023

Currently, there is no way (or at least it's not clear how) to create a mapping of custom entities from the XML document. For example:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE appcast [ 
    <!ENTITY ver_1 "1.0.1">
    <!ENTITY ver_2 "1.0.2">
]>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
    <channel>
        <title>Test</title>
        <item>
            <enclosure
                sparkle:version="&ver_1;"
                url="http://localhost:8000/dev/test-install-&ver_1;.exe"
                sparkle:os="windows" />
        </item>
    </channel>
</rss>

Please add support for parsing doctype entities, so that they can be referenced within containing XML.

@renggli
Copy link
Owner

renggli commented Nov 2, 2023

You can define your own entity mapping:

const entityMapping = XmlDefaultEntityMapping({
    'joy': '😂',
    'tears': '😢',
});

final document = XmlDocument.parse('<xml>&joy; and &tears;</xml>',
    entityMapping: entityMapping);
print(document.rootElement.innerText);  // prints '😂 and 😢'

The doctype entities are already parsed to some extent, but mapping them automatically is non-trivial and requires a lot of work. Happy to take contributions in this area.

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

No branches or pull requests

2 participants