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

Infrastructure for warnings #14

Open
philshafer opened this issue Aug 6, 2013 · 0 comments
Open

Infrastructure for warnings #14

philshafer opened this issue Aug 6, 2013 · 0 comments
Assignees

Comments

@philshafer
Copy link
Contributor

Lots of non-fatal things can kill you.

Like having the wrong URI for a namespace. Your script looks fine, runs fine, but does not work.

Example:

ns xnm = "http://xml.juniper.net/xnm/1.1/xnm-oops!!";

...
    if (not(xnm:error)) {
       call destroy-the-world();
    }

Since xnm:error will never match, the world will be gone. Not good.

I think I can make this an optional warning, if that helps. The rule would go something like this:

When libslax sees a chunk of XML, it will looks for top-level 
namespaces whose prefixes match a prefix defined in a top-level
"ns" statement in the main script.

This will allow us to catch errors like your's but without searching the entire new XML document, which could be expensive.

I want to put this all inside a new "warning" infrastructure, so the user can say "-Wprefix-reuse" for this first scenario, -Wprefix-reuse-deep for complete namespace checking, -Wxxx for some future case, and "-Wall" checks these and other future warning flags.

The same logic can be applied to element names as well, so a script can report (after execution) any XML element names used in XPath expressions that were not seen during execution. Again, not check, but if you said "if (xnm:errror)", it would be a complete lifesaver.
Thanks,
Phil

@ghost ghost assigned philshafer Aug 6, 2013
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

1 participant