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

Use XSLT for xml transforms #6

Open
blaggacao opened this issue Oct 14, 2019 · 2 comments
Open

Use XSLT for xml transforms #6

blaggacao opened this issue Oct 14, 2019 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@blaggacao
Copy link
Contributor

blaggacao commented Oct 14, 2019

Stylesheets are the standard for transfomring XML documents, use it instead of error prone regular expressions.

Random example: https://gist.github.com/blaggacao/e7ba05c7b4aa36317046ceb843cbed9f

@legalsylvain legalsylvain added the help wanted Extra attention is needed label Nov 5, 2019
@yajo
Copy link
Member

yajo commented Dec 15, 2020

I think that it would be more familiar for odoo-ish people to just allow using xpath for matching instead of regexps. XSLT is a whole new world for many.

@yajo
Copy link
Member

yajo commented Dec 15, 2020

Oh man look at this from #46 😿

re.compile(
r"""
# find a button...
<button
\s[^>]*
# ... that is a oe_stat_button
class=['"].*\b
oe_stat_button
\b.*['"]
[^>]*>\s*
# ... that contains a field
<field\s+
(
[^>]*
(
# ... named "active"
name=['"]active['"]|
# ... with a boolean_button widget
widget=['"]boolean_button['"]
)
[^>]*
){2}
[^>]*>\s*
</button>
""",
re.VERBOSE,
): """
<field name="active" invisible="1" />
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
""",

This should be fixed quickly before the library grows into an unmaintainable mess of regexps... 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants