morten      01/06/12 02:40:28

  Modified:    java/src/org/apache/xalan/xsltc/runtime BasisLibrary.java
                        TextOutput.java
  Log:
  Fix attribute node-set comparisons. There was a bug in one of the compare()
  methods of the BasisLibrary class which prevented attribute values from
  being compared. The method compared node IDs instead of node values.
  Pretty stupid bug, but now it is solved anyway.
  PR:           Bugzilla 1409
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.3       +17 -7     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasisLibrary.java 2001/05/22 17:27:13     1.2
  +++ BasisLibrary.java 2001/06/12 09:40:20     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: BasisLibrary.java,v 1.2 2001/05/22 17:27:13 morten Exp $
  + * @(#)$Id: BasisLibrary.java,v 1.3 2001/06/12 09:40:20 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -460,12 +460,9 @@
       public static boolean compare(int node, NodeIterator nodeSet,
                                  int op, DOM dom) {
        final String lvalue = dom.getNodeValue(node);
  -     //System.out.println("lvalue = " + lvalue);
  -     
        int rnode;
        nodeSet.reset();
        while ((rnode = nodeSet.next()) != NodeIterator.END) {
  -         //System.out.println("rnode = " + rnode);
            if (compareStrings(lvalue, dom.getNodeValue(rnode), op, dom)) {
                return true;
            }
  @@ -475,23 +472,36 @@
   
       public static boolean compare(int node, NodeIterator iterator,
                                  int op, int dummy, DOM dom) {
  -
        iterator.reset();
  +
        int rnode;
  +     String value;
  +
        switch(op) {
        case EQ:
  +         /* TODO:
  +          * This needs figuring out: What sort of comparison is done here?
  +          * Are we comparing exact node id's, node types, or node values?
  +          * Values is the obvious for attributes, but what about elements?
  +          */
  +         value = dom.getNodeValue(node);
            while ((rnode = iterator.next()) != NodeIterator.END)
  -             if (rnode == node) return true;
  +             if (value.equals(dom.getNodeValue(rnode))) return true;
  +         // if (rnode == node) return true; It just ain't that easy!!!
            break;
        case NE:
  +         value = dom.getNodeValue(node);
            while ((rnode = iterator.next()) != NodeIterator.END)
  -             if (rnode != node) return true;
  +             if (!value.equals(dom.getNodeValue(rnode))) return true;
  +         // if (rnode != node) return true;
            break;
        case LT:
  +         // Assume we're comparing document order here
            while ((rnode = iterator.next()) != NodeIterator.END)
                if (rnode > node) return true;
            break;
        case GT:
  +         // Assume we're comparing document order here
            while ((rnode = iterator.next()) != NodeIterator.END)
                if (rnode < node) return true;
            break;
  
  
  
  1.10      +11 -1     
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TextOutput.java   2001/06/11 13:05:02     1.9
  +++ TextOutput.java   2001/06/12 09:40:22     1.10
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.9 2001/06/11 13:05:02 morten Exp $
  + * @(#)$Id: TextOutput.java,v 1.10 2001/06/12 09:40:22 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -91,6 +91,8 @@
       // Contains all elements that should be output as CDATA sections
       private Hashtable _cdataElements = new Hashtable();
   
  +    private static final String XML_PREFIX = "xml";
  +
       private static final char[] AMP      = "&amp;".toCharArray();
       private static final char[] LT       = "&lt;".toCharArray();
       private static final char[] GT       = "&gt;".toCharArray();
  @@ -489,6 +491,8 @@
            if (_outputType == UNKNOWN) {
                if (elementName.toLowerCase().equals("html")) {
                    setType(HTML);
  +                 setIndent(true);
  +                 _escapeChars = true;
                }
                else {
                    setType(XML);
  @@ -695,6 +699,9 @@
        * Declare a prefix to point to a namespace URI
        */
       private void pushNamespace(String prefix, String uri) throws SAXException {
  +
  +     if (prefix.equals(XML_PREFIX)) return;
  +
        Stack stack;
        // Get the stack that contains URIs for the specified prefix
        if ((stack = (Stack)_namespaces.get(prefix)) == null) {
  @@ -714,6 +721,9 @@
        * Undeclare the namespace that is currently pointed to by a given prefix
        */
       private void popNamespace(String prefix) throws SAXException {
  +
  +     if (prefix.equals(XML_PREFIX)) return;
  +
        Stack stack;
        if ((stack = (Stack)_namespaces.get(prefix)) != null) {
            stack.pop();
  
  
  

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

Reply via email to