You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by md...@us.britannica.com on 2000/07/24 17:15:21 UTC

RE: FW: Resubmitting: [PATCH] remove dynamic validation from DTML iaison.java

Hi Scott,

OK, so: 

  default behaviour       - validation = false, dynamic validation = true
  setUseValidation(true)  - validation = true,  dynamic validation = false
  setUseValidation(false) - validation = false, dynamic validation = false

Is that an accurate summation?

This looks like a good short term patch to me.  However there are still
problems that would best be worked out on the Xerces side.  For example,
users who aren't following this thread (most, I would guess :) will still be
performing validation by default for certain documents, which is the
opposite of what the current Xalan documentation claims.  In a heterogeneous
collection of transformations, e.g. batch processing of standard XML formats
like XMLNews, they could get mysterious performance impacts or validation
error.  Obviously the best long term solution, if possible, is for the id
feature to work when validation is truly off.  For the short term, this
workaround should definitely be noted in the release notes as a bug.

- Morgan


> -----Original Message-----
> From: Scott_Boag@lotus.com [mailto:Scott_Boag@lotus.com]
> Sent: Friday, July 21, 2000 8:18 PM
> To: xalan-dev@xml.apache.org
> Subject: Re: FW: Resubmitting: [PATCH] remove dynamic validation from
> DTMLiais on.j ava
> 
> 
> 
> > I don't think this went out the first time for some reason.
> 
> I've gotten it 5 times now.  :-)
> 
> I think I found a reasonable solution (short term, anyway), 
> without having
> to add to the existing API, or change the existing default behavior.
> 
> In XMLParserLiaisonDefault, I do:
> 
>   /**
>    * True if validation was specifically set by the caller,
>    * false if not.
>    */
>   protected boolean m_isDefaultUseValidation = true;
> 
>   /**
>    * If set to true, validation will be performed,
>    * if set to false, validation will not be performed.
>    * Validation is
>    * <a href
> "http://xml.apache.org/xerces-j/features.html#dynamic">dynamic</a>
>    * by default.  Note that if validation is off, the id() function
>    * will not be able to locate nodes.
>    */
>   public void setUseValidation(boolean b)
>   {
>     m_isDefaultUseValidation = false;
>     m_use_validation = b;
>   }
> 
> And then in DTMLiaison and XercesLiaison, I do:
> 
>     if(getUseValidation())
>       
> parser.setFeature("http://xml.org/sax/features/validation", true);
>     else
>     {
>       if(m_isDefaultUseValidation)
>         
> parser.setFeature("http://xml.org/sax/features/validation/dynamic",
> true);
>       else
>         
> parser.setFeature("http://xml.org/sax/features/validation", false);
>     }
> 
> So, now, if you set validation to false, it really will be 
> non-validating.
> Can everyone live with this?
> 
> I want to still make dynamic validation the default, so the 
> norm will be to
> not break people's stylesheets that are relying on the id() function
> working.
> 
> -scott
> 
> 
> 
> 
>                                                               
>                                                         
>                     mdelagra@us.brit                          
>                                                         
>                     annica.com              To:     
> xalan-dev@xml.apache.org, Scott_Boag@lotus.com                    
>                                             cc:     
> xerces-dev@xml.apache.org                                         
>                     07/21/2000 04:47        Subject:     FW: 
> Resubmitting: [PATCH] remove dynamic validation from     
>                     PM                      DTMLiais on.j ava 
>                                                         
>                     Please respond                            
>                                                         
>                     to xalan-dev                              
>                                                         
>                                                               
>                                                         
>                                                               
>                                                         
> 
> 
> 
> I don't think this went out the first time for some reason.
> 
> -----Original Message-----
> From: Delagrange, Morgan
> Sent: Friday, July 21, 2000 11:26 AM
> To: 'xalan-dev@xml.apache.org'; Delagrange, Morgan;
> 'Scott_Boag@lotus.com'
> Cc: xerces-dev@xml.apache.org
> Subject: RE: Resubmitting: [PATCH] remove dynamic validation from
> DTMLiaison.j ava
> 
> 
> Ugh, this is a problem for so many reasons.
> 
> Advantages to dynamic validation
> --------------------------------
> - The id function works.
> - It might be easier to maintain, but only in a system that uses a
> combination of validating documents and nonvalidating 
> documents _with no
> special characters_.
> 
> Disadvantages to dynamic validation
> -----------------------------------
> - The id function doesn't work.
> - It's not correct default behavior in nonvalidating mode, 
> and therefore it
> introduces a performance cost hidden to the end user.  For 
> example, users
> may have a fully specified DTD but _not want to validate_ for 
> performance
> reasons.
> - It produces many, many errors (at least 1 per element) for 
> nonvalidating
> documents with special characters.
> 
> Dynamic validating is especially a problem in my case, since 
> I'm running
> Xalan in a production servlet.  My log files would be pretty useless,
> because every XSLT request will produce 50 or so errors from 
> Xalan.  Of
> course, I can keep patching Xalan with every release, since I 
> don't use the
> id function in production, but I'd prefer to see a fix merged 
> into the code
> base.
> 
> Rejecting this patch may be the best short term solution, but 
> it leaves a
> big problem.  In addition to the problem with the error 
> messages, all those
> requests are being slowed down, because they're needlessly undergoing
> validation.  As I point out above, this also means that users with
> validating DTDs may be getting an unexpected performance hit, 
> because they
> don't get error messages and therefore don't know that their 
> documents are
> being validated.
> 
> I'm interested to hear some input from the Xerces group.  
> It's definitely a
> problem in the XSLT world if you can't get the id of a node 
> when validation
> is disabled.  The id() function is not terribly useful in most
> environments;
> it's a shame that you have to introduce all that validation 
> overhead in
> order to support it.
> 
> > -----Original Message-----
> > From: Scott Boag/CAM/Lotus [mailto:Scott_Boag@lotus.com]
> > Sent: Thursday, July 20, 2000 1:56 PM
> > To: mdelagra@us.britannica.com
> > Cc: xalan-dev@xml.apache.org; xerces-dev@xml.apache.org
> > Subject: Re: Resubmitting: [PATCH] remove dynamic validation from
> > DTMLiaison.j ava
> >
> >
> > > Unfortunately, dynamic validation does work :) and causes
> > problems for
> > > existing XML documents that worked in previous versions of Xalan.
> > Dynamic
> > > validation blindly enables validation whenever it
> > encounters a "DOCTYPE"
> > > declaration.
> >
> > The problem with commenting out dynamic validation is it will
> > make the id
> > (...) functions fail... I talked to the Xerces folk, and,
> > while they do
> > process entity refs and default attributes, they do not process ID
> > declarations if validation is not run (I think this is the
> > wrong behavior,
> > but that's something we need to discuss with the Xerces folk,
> > as they may
> > well have good reasons for this).  With your patch, many of
> > our conformance
> > tests failed that used the id(...) function.
> >
> > I am unsure of where to go with this.  I am inclined to
> > reject the patch,
> > on the basis of the id(...) function working being more
> > important.  On the
> > other hand, I understand your problem.  Note that processing
> > still occurs
> > (at least on the command line), even though validation errors
> > are reported.
> >
> > I would like to get your opinion, given this additional
> > information, in
> > addition to anyone else's opinion, before making a decision
> > on this patch
> > for our next release.  Perhaps the Xerces folks have 
> something to add?
> >
> > On solution might be to add a third option that allows
> > dynamic validation
> > to be controlled (with validation on by default).  This 
> isn't really a
> > solution, but at least it would provide a work-around.  This
> > is more work
> > than I can do for this release, but we would be willing to
> > incorporate a
> > patch that does this if someone does it fast.
> >
> > -scott
> >
> >
> > ----- Forwarded by Scott Boag/CAM/Lotus on 07/20/2000 12:51 PM -----
> >
> >
> >                     Scott Boag
> >
> >                                          To:
> > xalan-dev@xml.apache.org
> >                     07/17/2000           cc:
> >
> >                     07:33 PM             Subject:     Re:
> > Resubmitting: [PATCH] remove dynamic validation from
> >                                          DTMLiaison.j
> > ava(Document link: Scott Boag)
> >
> >
> >
> >
> >
> > Sorry for the delay.  We have about 8 patches backlogged 
> which we are
> > working on incorporating this week.  Myriam may have already
> > incorporated
> > this particular patch today, I'm not sure.  We also need to
> > run our full
> > regression suite on the patched code.
> >
> > Our intention is to create our first patch-only release for 
> Xalan 1.1,
> > probably sometime next week.  If other's have patches, now's
> > the time to
> > submit them!
> >
> > BTW, this whole dynamic validation thing is tremendously
> > frustrating to me.
> > The way it works seems to keep changing in Xerces.  I agree
> > with you about
> > the dynamic validation being turned off by default, except I
> > would expect
> > that entity decls and default attributes would still be
> > processed in this
> > case... not sure about lately, but at least at the time I
> > wrote that code,
> > that wasn't the case (maybe a bug?).  The bottom line is, the
> > processor
> > should be able to process the document correctly without
> > having to know
> > anything about the document (including entities and default 
> attributes
> > declared in the external doctype).  If, in the case you gave,
> > with dynamic
> > validation turned off, the mdash entity does not get 
> resolved, I would
> > argue that dynamic validation should be on by default (I
> > agree with you
> > that there should be an API method to control it).
> >
> > -scott
> >
> >
> >
> >
> >
> >
> >                     mdelagra@us.brit
> >
> >                     annica.com              To:
> > xalan-dev@xml.apache.org
> >                                             cc:     (bcc:
> > Scott Boag/CAM/Lotus)
> >                     07/17/2000 05:49        Subject:
> > Resubmitting: [PATCH] remove dynamic validation from
> >                     PM                      DTMLiaison.j ava
> >
> >                     Please respond
> >
> >                     to xalan-dev
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: mdelagra@us.britannica.com [mailto:mdelagra@us.britannica.com]
> > Sent: Thursday, July 13, 2000 9:22 AM
> > To: xalan-dev@xml.apache.org
> > Subject: [PATCH] remove dynamic validation from DTMLiaison.java
> >
> >
> > Hi all,
> >
> > Could a Committer please review and commit this patch?  Thanks.
> >
> >
> > Index: DTMLiaison.java
> > ===================================================================
> > RCS file:
> > /home/cvspublic/xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLi
> > aison.java,v
> > retrieving revision 1.16
> > diff -u -r1.16 DTMLiaison.java
> > --- DTMLiaison.java       2000/05/26 05:50:21            1.16
> > +++ DTMLiaison.java       2000/07/13 14:17:33
> > @@ -225,11 +225,10 @@
> >
> >          if(getUseValidation())
> >            
> parser.setFeature("http://xml.org/sax/features/validation",
> > true);
> > -        else
> > -        {
> > -          // This doesn't seem to work, but I'm a setting 
> it anyhow.
> > -
> > 
> parser.setFeature("http://apache.org/xml/features/validation/dynamic",
> > true);
> > -        }
> > +
> > +        // "http://xml.org/sax/features/validation/dynamic"
> > is and should
> > be false
> > +        // by default.  It incorrectly decides to validate
> > documents that
> > declare
> > +        // internal entities.
> >
> >          if(m_doThreading)
> >          {
> >
> >
> >
> > -----Original Message-----
> > From: mdelagra@us.britannica.com [mailto:mdelagra@us.britannica.com]
> > Sent: Tuesday, July 11, 2000 6:12 PM
> > To: xalan-dev@xml.apache.org
> > Subject: Bug in DTMLiaison.java concerning "dynamic validation"
> >
> >
> > Hi all,
> >
> > There is a significant bug in DTMLiaison, version 1.16.
> > Scott B. created
> > the following block of code:
> >
> >   if(getUseValidation())
> >     
> parser.setFeature("http://xml.org/sax/features/validation", true);
> >   else
> >   {
> >     // This doesn't seem to work, but I'm a setting it anyhow.
> >
> > 
> parser.setFeature("http://apache.org/xml/features/validation/dynamic",
> > true);
> >   }
> >
> > Unfortunately, dynamic validation does work :) and causes 
> problems for
> > existing XML documents that worked in previous versions of
> > Xalan.  Dynamic
> > validation blindly enables validation whenever it encounters
> > a "DOCTYPE"
> > declaration.  This is not proper default behavior, because some XML
> > documents perform nonvalidating resolution of special
> > characters in the
> > DOCTYPE declaration.  For example, the current version of
> > Xalan attempts to
> > validate this legal nonvalidating XML document:
> >
> >    <?xml version="1.0" ?>
> >   <!DOCTYPE article [
> >     <!ENTITY mdash "&#151;">
> >   ]>
> >
> >   <article>
> >     this is my mdash &mdash;
> >   </article>
> >
> > To make a long story short, dynamic validation should be
> > disabled.  The
> > above code block should be replaced with this:
> >
> >   if(getUseValidation())
> >     
> parser.setFeature("http://xml.org/sax/features/validation", true);
> >
> > You may want to include a method in the XMLParserLiaison that
> > allows a user
> > to enable it explicitly, but it should be disabled by
> > default, as it is in
> > Xerces.  In the current API, there is no way to turn off dynamic
> > validation.
> > That's bad.
> >
> > Incidentally, I thought we were supposed to submit bugs to
> > http://xml.apache.org/bugs, but I've never been able to gain
> > access.  Is
> > the
> > bug database only accessible to certain people?
> >
> > Thanks!
> >
> > Morgan Delagrange
> > Britannica.com
> >
> >
> >
> >
> >
> 
> 
> 
>