commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morgan Delagrange <mdela...@yahoo.com>
Subject Re: [Jelly] restrict use of tag libraries
Date Tue, 04 Feb 2003 15:37:26 GMT
--- James Strachan <james_strachan@yahoo.co.uk> wrote:
> Agreed - though I can't help feeling we'd end up
> reinventing XML validation
> techniques where just reusing something like
> RelaxNG, XSD or Schematron
> might be easier.
> 
> James

Hey Christian,

That's my sentiment as well.  When designing an API,
you try to address the common usage and allow hooks
for specific implementations.  The kind of validation
you're trying to implement is pretty specific.

I have another suggestion for how you might implement
your validation.  You could use custom tags inside
your namespace to switch namespace restrictions on and
off, then enforce them with a custom JellyContext.  I
haven't checked the precise syntax, but something like
this might work.  It's not exactly elegant, but it's
simple to implement:

  <element1 xmlns="com.yadda.Yadda"> <!-- no taglibs
allowed here -->
    <allowNS/>
    <element2 xmlns:j="jelly:core"
xmlns:log="jelly:log">
      <j:something/>
        .....
    </mytags:element2>
  </mytags:element1>


  private class YaddaContext extends JellyContext {

   /**
    * Only allow other namespaces when
    * specifically enabled.
    */
    public TagLibrary getTagLibrary(String
namespaceURI)  {
      if (namespaceURI.equals("com.yadda.Yadda") ==
false) {
        if (getVariable("allowNS") == false) {
          throw new NoClassDefFoundError("Unexpected
tag library uri: " + namespaceURI);
        }
      }
        
      return super.getTagLibrary(namespaceURI); 
    }
  }

=====
Morgan Delagrange
http://jakarta.apache.org/taglibs
http://jakarta.apache.org/commons
http://axion.tigris.org
http://jakarta.apache.org/watchdog

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Mime
View raw message