xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mrgla...@apache.org
Subject cvs commit: xml-xerces/java/docs faq-sax.xml
Date Fri, 13 Feb 2004 23:15:02 GMT
mrglavas    2004/02/13 15:15:02

  Modified:    java/docs faq-sax.xml
  Log:
  Improving language in a few FAQs.
  
  Revision  Changes    Path
  1.2       +25 -22    xml-xerces/java/docs/faq-sax.xml
  
  Index: faq-sax.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/docs/faq-sax.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- faq-sax.xml	13 Feb 2004 18:32:40 -0000	1.1
  +++ faq-sax.xml	13 Feb 2004 23:15:01 -0000	1.2
  @@ -47,26 +47,30 @@
     <a>
     <p>If you read the <jump href='http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html#characters(char[],%20int,%20int)'>SAX</jump>

     documentation, you will find that SAX may deliver contiguous text as multiple calls to

  -characters(), for reasons having to do with parser efficiency and input 
  +<code>characters</code>, for reasons having to do with parser efficiency and
input 
   buffering. It is the programmer's responsibility to deal with that 
  -appropriately, e.g. by accumulating text until the next non-characters() 
  +appropriately, e.g. by accumulating text until the next non-characters 
   event.
    </p>
  + <p>
  +   Xerces will split calls to <code>characters</code> at the end of an internal
buffer,
  +   at a new line and also at a few other boundaries. You can never rely on contiguous
  +   text to be passed in a single characters callback.
  + </p>
     </a>
     </faq>
   
     <faq title="Encodings and XML Version Via SAX">
       <q>Is there any way I can determine what encoding an entity was
       written in, or what XML version the document conformed to, if I'm
  -    using SAX?
  -    </q>
  +    using SAX?</q>
       <a>
           <p>The answer to this question is that, yes there is a way, but it's
           not particularly beautiful.  There is no way in SAX 2.0.0 or
           2.0.1 to get hold of these pieces of information; the SAX
  -        Locator2 interface from the 1.1 extensions--still in Alpha at
  +        Locator2 interface from the 1.1 extensions--still in Beta at
           the time of writing--does provide methods to accomplish this,
  -        but since Xerces is required to support precisely SAX 2.0.0 by
  +        but since Xerces is required to support precisely SAX 2.0.1 by
           Sun TCK rules, we cannot ship this interface.  However, we can
           still support the appropriate methods on the objects we
           provide to implement the SAX Locator interface.  Therefore,
  @@ -76,23 +80,22 @@
           you can use a method like this to determine the encoding of
           the entity currently being parsed:
           </p>
  -        <source> 
  -    import java.lang.reflect.Method;
  -    private String getEncoding(Locator locator) {
  -        String encoding = null;
  -        Method getEncoding = null;
  -        try {
  -            getEncoding = locator.getClass().getMethod("getEncoding", new Class[]{});
  -            if(getEncoding != null) {
  -                encoding = (String)getEncoding.invoke(locator, null);
  -            }
  -        } catch (Exception e) {
  -            // either this locator object doesn't have this
  -            // method, or we're on an old JDK
  +        <source>import java.lang.reflect.Method;
  +private String getEncoding(Locator locator) {
  +    String encoding = null;
  +    Method getEncoding = null;
  +    try {
  +        getEncoding = 
  +            locator.getClass().getMethod("getEncoding", new Class[]{});
  +        if(getEncoding != null) {
  +            encoding = (String)getEncoding.invoke(locator, null);
           }
  -        return encoding;
  -    } 
  -        </source>
  +    } catch (Exception e) {
  +        // either this locator object doesn't have this
  +        // method, or we're on an old JDK
  +    }
  +    return encoding;
  +}</source>
           <p>This code has the advantage that it will compile on JDK
           1.1.8, though it will only produce non-null results on 1.2.x
           JDK's and later.  Substituting <code>getXMLVersion</code> for
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org


Mime
View raw message