morten      01/08/13 08:25:56

  Modified:    java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java DefaultSAXOutputHandler.java
                        TextOutput.java
  Log:
  A start on a fix for output DOCTYPE declarations based on the attributes
  of the <xsl:output> element. I also added a fix for bug 2863, to prevent
  us from outputting namespace delcaration that point a prefix to the null
  URI (such as 'xmlns:blob=""').
  PR:           bugzilla 2863
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.17      +4 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AbstractTranslet.java     2001/08/07 10:38:44     1.16
  +++ AbstractTranslet.java     2001/08/13 15:25:56     1.17
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AbstractTranslet.java,v 1.16 2001/08/07 10:38:44 morten Exp $
  + * @(#)$Id: AbstractTranslet.java,v 1.17 2001/08/13 15:25:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -542,7 +542,7 @@
                if (_standalone != null) handler.setStandalone(_standalone);
                if (_omitHeader) handler.omitHeader(true);
                if (_indent) handler.setIndent(_indent);
  -             if ((_doctypePublic != null) && (_doctypeSystem != null))
  +             if (_doctypeSystem != null)
                    handler.setDoctype(_doctypeSystem, _doctypePublic);
            }
            // Transfer all output settings relevant to HTML output
  @@ -552,7 +552,7 @@
                    handler.setIndent(_indent);
                else
                    handler.setIndent(true);
  -             if ((_doctypePublic != null) && (_doctypeSystem != null))
  +             if (_doctypeSystem != null)
                    handler.setDoctype(_doctypeSystem, _doctypePublic);
                if (_mediaType != null) handler.setMediaType(_mediaType);
            }
  @@ -569,7 +569,7 @@
            if (_standalone != null) handler.setStandalone(_standalone);
            if (_omitHeader) handler.omitHeader(true);
            if (_indent) handler.setIndent(_indent);
  -         if ((_doctypePublic != null) && (_doctypeSystem != null))
  +         if (_doctypeSystem != null)
                handler.setDoctype(_doctypeSystem, _doctypePublic);
        }
       }
  
  
  
  1.12      +22 -4     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultSAXOutputHandler.java
  
  Index: DefaultSAXOutputHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultSAXOutputHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultSAXOutputHandler.java      2001/08/01 11:52:59     1.11
  +++ DefaultSAXOutputHandler.java      2001/08/13 15:25:56     1.12
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DefaultSAXOutputHandler.java,v 1.11 2001/08/01 11:52:59 morten Exp $
  + * @(#)$Id: DefaultSAXOutputHandler.java,v 1.12 2001/08/13 15:25:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -74,8 +74,9 @@
   import org.xml.sax.Locator;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  +import org.xml.sax.ext.DeclHandler;
   
  -public class DefaultSAXOutputHandler implements ContentHandler {
  +public class DefaultSAXOutputHandler implements ContentHandler, DeclHandler {
   
       // The output writer
       private Writer _writer;
  @@ -376,8 +377,8 @@
       /**
        * SAX2: Receive notification of a processing instruction.
        */
  -    public void processingInstruction(String target, String data) throws 
  -     SAXException {
  +    public void processingInstruction(String target, String data)
  +     throws SAXException {
        try {
               if (_startTagOpen) closeStartTag(true);
               _writer.write(BEGPI);
  @@ -423,6 +424,23 @@
       public void endPrefixMapping(String prefix) {
        // Do nothing
       }
  +
  +    public void attributeDecl(java.lang.String eName, java.lang.String aName, 
java.lang.String type, java.lang.String valueDefault, java.lang.String value) {
  +
  +    }
  +
  +    public void elementDecl(java.lang.String name, java.lang.String model) {
  +
  +    }
  +
  +    public void externalEntityDecl(java.lang.String name, java.lang.String 
publicId, java.lang.String systemId) {
  +
  +    }
  +
  +    public void internalEntityDecl(java.lang.String name, java.lang.String value) {
  +
  +    }
  +    
   
       /**
        * Adds a newline in the output stream and indents to correct level
  
  
  
  1.18      +33 -3     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
  
  Index: TextOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TextOutput.java   2001/08/07 10:33:28     1.17
  +++ TextOutput.java   2001/08/13 15:25:56     1.18
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.17 2001/08/07 10:33:28 morten Exp $
  + * @(#)$Id: TextOutput.java,v 1.18 2001/08/13 15:25:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -67,9 +67,11 @@
   import java.io.*;
   import java.util.Stack;
   
  -import org.apache.xalan.xsltc.*;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  +import org.xml.sax.ext.DeclHandler;
  +
  +import org.apache.xalan.xsltc.*;
   
   public final class TextOutput implements TransletOutputHandler {
   
  @@ -85,6 +87,8 @@
       private int         _outputType = UNKNOWN;
       private String _encoding;
       private String _mediaType = "text/html";
  +    private String _doctypeSystem = null;
  +    private String _doctypePublic = null;
   
       private boolean   _escapeChars = false;
       private boolean   _startTagOpen = false;
  @@ -132,6 +136,7 @@
   
       // Reference to the SAX2 handler that consumes this handler's output
       private ContentHandler _saxHandler;
  +    private DeclHandler    _declHandler;
   
       /**
        * Creates a new translet output post-processor
  @@ -159,6 +164,22 @@
       }
   
       /**
  +     * Creates a new translet output post-processor
  +     *
  +     * @param handler A SAX2 handler to consume the generated SAX events 
  +     * @param encoding The default encoding to use (set in <xsl:output>)
  +     * @throws IOException
  +     */
  +    public TextOutput(ContentHandler saxHandler, DeclHandler declHandler,
  +                   String encoding)
  +     throws IOException {
  +        _saxHandler = saxHandler;
  +     _declHandler = declHandler;
  +        init();
  +     _encoding = encoding;
  +    }
  +
  +    /**
        * Initialise global variables
        */
       private void init() throws IOException {
  @@ -457,6 +478,12 @@
                    setTypeInternal(XML);
            }
   
  +         // Handle document type declaration (for first element only)
  +         if ((_doctypeSystem != null) && (_declHandler != null)) {
  +             // _declHandler.something(something);
  +             _doctypeSystem = null;
  +         }
  +
            _depth++;
            _elementName = elementName;
            _attributes.clear();
  @@ -647,6 +674,8 @@
   
        if (prefix.equals(XML_PREFIX)) return;
   
  +     if ((!prefix.equals(EMPTYSTRING)) && (uri.equals(EMPTYSTRING))) return;
  +
        Stack stack;
        // Get the stack that contains URIs for the specified prefix
        if ((stack = (Stack)_namespaces.get(prefix)) == null) {
  @@ -798,7 +827,8 @@
        * Set the output document system/public identifiers
        */
       public void setDoctype(String system, String pub) {
  -     // TODO - pass these to the SAX output handler - how?
  +     _doctypeSystem = system;
  +     _doctypePublic = pub;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to