You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2002/09/21 00:11:58 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/res XPATHErrorResources.java

zongaro     2002/09/20 15:11:58

  Modified:    java/src/org/apache/xalan/lib Tag: XSLTC_DTM ExsltMath.java
               java/src/org/apache/xalan/serialize Tag: XSLTC_DTM
                        SerializerToXML.java
               java/src/org/apache/xalan/xslt Tag: XSLTC_DTM Process.java
               java/src/org/apache/xpath/objects Tag: XSLTC_DTM
                        XRTreeFragSelectWrapper.java
               java/src/org/apache/xpath/res Tag: XSLTC_DTM
                        XPATHErrorResources.java
  Log:
  Merging in lastest changes from MAIN branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.3   +42 -43    xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java
  
  Index: ExsltMath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java,v
  retrieving revision 1.2.2.2
  retrieving revision 1.2.2.3
  diff -u -r1.2.2.2 -r1.2.2.3
  --- ExsltMath.java	12 Sep 2002 16:07:31 -0000	1.2.2.2
  +++ ExsltMath.java	20 Sep 2002 22:11:57 -0000	1.2.2.3
  @@ -102,29 +102,27 @@
      * 
      * @param nl The NodeList for the node-set to be evaluated.
      * 
  -   * @return String representation of the maximum value found, NaN if any node cannot be 
  -   * converted to a number.
  +   * @return the maximum value found, NaN if any node cannot be converted to a number.
      * 
      * @see <a href="http://www.exslt.org/">EXSLT</a>
      */
  -  public static String max (NodeList nl)
  +  public static double max (NodeList nl)
     {
  -  	Node maxNode = null;
  -  	double m = Double.MIN_VALUE;
  -  	for (int i = 0; i < nl.getLength(); i++)
  -  	{
  -  		Node n = nl.item(i);
  -  		double d = toNumber(n);
  -  		if (Double.isNaN(d))
  -  		  return "NaN";
  -  		else if (d > m)
  -  		{
  -  			m = d;
  -  			maxNode = n;
  -  		}
  -  	}
  +    if (nl == null || nl.getLength() == 0)
  +      return Double.NaN;
  +      
  +    double m = Double.MIN_VALUE;
  +    for (int i = 0; i < nl.getLength(); i++)
  +    {
  +      Node n = nl.item(i);
  +      double d = toNumber(n);
  +      if (Double.isNaN(d))
  +        return Double.NaN;
  +      else if (d > m)
  +        m = d;
  +    }
     	
  -  	return toString(maxNode);  	
  +    return m;  	
     }
   
     /**
  @@ -139,28 +137,27 @@
      * 
      * @param nl The NodeList for the node-set to be evaluated.
      * 
  -   * @return String representation of the minimum value found, NaN if any node cannot be 
  -   * converted to a number.
  +   * @return the minimum value found, NaN if any node cannot be converted to a number.
      * 
      * @see <a href="http://www.exslt.org/">EXSLT</a>
      */
  -  public static String min (NodeList nl)
  +  public static double min (NodeList nl)
     {
  -    Node minNode = null;
  +    if (nl == null || nl.getLength() == 0)
  +      return Double.NaN;
  +
       double m = Double.MAX_VALUE;
       for (int i = 0; i < nl.getLength(); i++)
       {
         Node n = nl.item(i);
         double d = toNumber(n);
         if (Double.isNaN(d))
  -        return "NaN";
  +        return Double.NaN;
         else if (d < m)
  -      {
           m = d;
  -        minNode = n;
  -      }
       }
  -    return toString(minNode);
  +    
  +    return m;
     }
     
     /**
  @@ -181,19 +178,20 @@
      * if any node cannot be converted to a number.
      */
     public static NodeList highest (NodeList nl)
  -  {    
  -    double high = new Double(max(nl)).doubleValue();
  +  {        
  +    double maxValue = max(nl);
  +
       NodeSet highNodes = new NodeSet();
  -    highNodes.setShouldCacheNodes(true);
  +    highNodes.setShouldCacheNodes(true);    
       
  -    if (Double.isNaN(high))
  +    if (Double.isNaN(maxValue))
         return highNodes;  // empty Nodeset
       
       for (int i = 0; i < nl.getLength(); i++)
       {
         Node n = nl.item(i);
         double d = toNumber(n); 
  -      if (d == high)
  +      if (d == maxValue)
           highNodes.addElement(n);
       }
       return highNodes;
  @@ -218,19 +216,19 @@
      */
     public static NodeList lowest (NodeList nl)
     {
  -    double low = new Double(min(nl)).doubleValue();
  +    double minValue = min(nl);
   
       NodeSet lowNodes = new NodeSet();
       lowNodes.setShouldCacheNodes(true);
       
  -    if (Double.isNaN(low))
  +    if (Double.isNaN(minValue))
         return lowNodes;  // empty Nodeset
       
       for (int i = 0; i < nl.getLength(); i++)
       {
         Node n = nl.item(i);
         double d = toNumber(n); 
  -      if (d == low)
  +      if (d == minValue)
           lowNodes.addElement(n);
       }
       return lowNodes;
  @@ -372,14 +370,15 @@
     /**
      * The math:constant function returns the specified constant to a set precision. 
      * The possible constants are:
  -   *
  -   * PI
  -   * E
  -   * SQRRT2
  -   * LN2
  -   * LN10
  -   * LOG2E
  -   * SQRT1_2 
  +   * <pre>
  +   *  PI
  +   *  E
  +   *  SQRRT2
  +   *  LN2
  +   *  LN10
  +   *  LOG2E
  +   *  SQRT1_2
  +   * </pre>
      */
      public static double constant(String name, double precision)
      {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.2  +19 -1     xml-xalan/java/src/org/apache/xalan/serialize/SerializerToXML.java
  
  Index: SerializerToXML.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/SerializerToXML.java,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- SerializerToXML.java	29 Jul 2002 00:01:19 -0000	1.14.2.1
  +++ SerializerToXML.java	20 Sep 2002 22:11:57 -0000	1.14.2.2
  @@ -1278,8 +1278,26 @@
       try
       {
         final Writer writer = m_writer;
  +      final int limit = start + length;
  +      boolean wasDash = false;
         writer.write("<!--");
  -      writer.write(ch, start, length);
  +
  +      // Detect occurrences of two consecutive dashes, handle as necessary.
  +      for (int i = start; i < limit; i++) {
  +        if (wasDash && ch[i] == '-') {
  +          writer.write(ch, start, i - start);
  +          writer.write(" -");
  +          start = i + 1;     	  
  +        }
  +        wasDash = (ch[i] == '-');
  +      }      	 
  +      
  +      // Output the remaining characters.
  +      writer.write(ch, start, limit - start);
  +      // Protect comment end from a single trailing dash
  +      if (ch[limit-1] == '-')
  +        writer.write(' ');
  +
         writer.write("-->");
       }
       catch(IOException ioe)
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.47.6.2  +109 -95   xml-xalan/java/src/org/apache/xalan/xslt/Process.java
  
  Index: Process.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/Process.java,v
  retrieving revision 1.47.6.1
  retrieving revision 1.47.6.2
  diff -u -r1.47.6.1 -r1.47.6.2
  --- Process.java	29 Jul 2002 00:01:21 -0000	1.47.6.1
  +++ Process.java	20 Sep 2002 22:11:57 -0000	1.47.6.2
  @@ -116,7 +116,6 @@
    */
   public class Process
   {
  -
     /**
      * Prints argument options.
      *
  @@ -124,9 +123,9 @@
      */
     protected static void printArgOptions(ResourceBundle resbundle)
     {
  -
       System.out.println(resbundle.getString("xslProc_option"));  //"xslproc options: ");
       System.out.println(resbundle.getString("optionIN"));  //"    -IN inputXMLURL");
  +    System.out.println(resbundle.getString("optionXSLTC"));  //"    [-XSLTC (use XSLTC for transformation)]
       System.out.println(resbundle.getString("optionXSL"));  //"   [-XSL XSLTransformationURL]");
       System.out.println(resbundle.getString("optionOUT"));  //"   [-OUT outputFileName]");
   
  @@ -202,8 +201,25 @@
       }
       else
       {
  +      boolean useXSLTC = false;
  +      for (int i = 0; i < argv.length; i++)
  +      {
  +        if ("-XSLTC".equalsIgnoreCase(argv[i]))
  +        {
  +          useXSLTC = true;
  +        }
  +      }
  +        
         TransformerFactory tfactory;
  -
  +      if (useXSLTC)
  +      {
  +	 String key = "javax.xml.transform.TransformerFactory";
  +	 String value = "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
  +	 Properties props = System.getProperties();
  +	 props.put(key, value);
  +	 System.setProperties(props);      
  +      }
  +      
         try
         {
           tfactory = TransformerFactory.newInstance();
  @@ -239,39 +255,63 @@
   
         for (int i = 0; i < argv.length; i++)
         {
  -        if ("-TT".equalsIgnoreCase(argv[i]))
  +        if ("-XSLTC".equalsIgnoreCase(argv[i]))
  +        {
  +          // The -XSLTC option has been processed.
  +        }
  +        else if ("-TT".equalsIgnoreCase(argv[i]))
           {
  -          if (null == tracer)
  -            tracer = new PrintTraceListener(diagnosticsWriter);
  +          if (!useXSLTC)
  +          {
  +            if (null == tracer)
  +              tracer = new PrintTraceListener(diagnosticsWriter);
   
  -          tracer.m_traceTemplates = true;
  +            tracer.m_traceTemplates = true;
  +          }
  +          else
  +            printInvalidXSLTCOption("-TT");
   
             // tfactory.setTraceTemplates(true);
           }
           else if ("-TG".equalsIgnoreCase(argv[i]))
           {
  -          if (null == tracer)
  -            tracer = new PrintTraceListener(diagnosticsWriter);
  +          if (!useXSLTC)
  +          {
  +            if (null == tracer)
  +              tracer = new PrintTraceListener(diagnosticsWriter);
   
  -          tracer.m_traceGeneration = true;
  +            tracer.m_traceGeneration = true;
  +          }
  +          else
  +            printInvalidXSLTCOption("-TG");
   
             // tfactory.setTraceSelect(true);
           }
           else if ("-TS".equalsIgnoreCase(argv[i]))
           {
  -          if (null == tracer)
  -            tracer = new PrintTraceListener(diagnosticsWriter);
  +          if (!useXSLTC)
  +          {
  +            if (null == tracer)
  +              tracer = new PrintTraceListener(diagnosticsWriter);
   
  -          tracer.m_traceSelection = true;
  +            tracer.m_traceSelection = true;
  +          }
  +          else
  +            printInvalidXSLTCOption("-TS");
   
             // tfactory.setTraceTemplates(true);
           }
           else if ("-TTC".equalsIgnoreCase(argv[i]))
           {
  -          if (null == tracer)
  -            tracer = new PrintTraceListener(diagnosticsWriter);
  +          if (!useXSLTC)
  +          {
  +            if (null == tracer)
  +              tracer = new PrintTraceListener(diagnosticsWriter);
   
  -          tracer.m_traceElements = true;
  +            tracer.m_traceElements = true;
  +          }
  +          else
  +            printInvalidXSLTCOption("-TTC");
   
             // tfactory.setTraceTemplateChildren(true);
           }
  @@ -361,20 +401,6 @@
                   XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
                   new Object[]{ "-PARAM" }));  //"Missing argument for);
           }
  -        else if ("-TREEDUMP".equalsIgnoreCase(argv[i]))  // sc 28-Feb-01 appears to be unused; can we remove?
  -        {
  -          if (i + 1 < argv.length)
  -            treedumpFileName = argv[++i];
  -          else
  -            System.err.println(
  -              XSLMessages.createMessage(
  -                XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
  -                new Object[]{ "-treedump" }));  //"Missing argument for);
  -        }
  -        else if ("-F".equalsIgnoreCase(argv[i]))  // sc 28-Feb-01 appears to be unused; can we remove?
  -        {
  -          formatOutput = true;
  -        }
           else if ("-E".equalsIgnoreCase(argv[i]))
           {
   
  @@ -391,29 +417,15 @@
           }
           else if ("-QC".equalsIgnoreCase(argv[i]))
           {
  -          quietConflictWarnings = true;
  +          if (!useXSLTC)
  +            quietConflictWarnings = true;
  +          else
  +            printInvalidXSLTCOption("-QC");
           }
           else if ("-Q".equalsIgnoreCase(argv[i]))
           {
             setQuietMode = true;
           }
  -
  -        /*
  -        else if("-VALIDATE".equalsIgnoreCase(argv[i]))
  -        {
  -          String shouldValidate;
  -          if(((i+1) < argv.length) && (argv[i+1].charAt(0) != '-'))
  -          {
  -            shouldValidate = argv[++i];
  -          }
  -          else
  -          {
  -            shouldValidate = "yes";
  -          }
  -
  -          // xmlProcessorLiaison.setUseValidation(shouldValidate.equalsIgnoreCase("yes"));
  -        }
  -        */
           else if ("-DIAG".equalsIgnoreCase(argv[i]))
           {
             doDiag = true;
  @@ -523,12 +535,20 @@
             }
           }
           else if ("-L".equalsIgnoreCase(argv[i]))
  -          useSourceLocation = true;
  +        {
  +          if (!useXSLTC)
  +            useSourceLocation = true;
  +          else
  +            printInvalidXSLTCOption("-L");
  +        }
           else if ("-INCREMENTAL".equalsIgnoreCase(argv[i]))
           {
  -          tfactory.setAttribute
  -            ("http://xml.apache.org/xalan/features/incremental", 
  -             java.lang.Boolean.TRUE);
  +          if (!useXSLTC)
  +            tfactory.setAttribute
  +              ("http://xml.apache.org/xalan/features/incremental", 
  +               java.lang.Boolean.TRUE);
  +          else
  +            printInvalidXSLTCOption("-INCREMENTAL");
           }
           else if ("-NOOPTIMIZE".equalsIgnoreCase(argv[i]))
           {
  @@ -537,19 +557,32 @@
             // %REVIEW% We should have a generalized syntax for negative
             // switches...  and probably should accept the inverse even
             // if it is the default.
  -          tfactory.setAttribute
  -            ("http://xml.apache.org/xalan/features/optimize", 
  -             java.lang.Boolean.FALSE);
  +          if (!useXSLTC)
  +            tfactory.setAttribute
  +              ("http://xml.apache.org/xalan/features/optimize", 
  +               java.lang.Boolean.FALSE);
  +          else
  +            printInvalidXSLTCOption("-NOOPTIMIZE");
   	}
           else if ("-RL".equalsIgnoreCase(argv[i]))
           {
  -          if (i + 1 < argv.length)
  -            recursionLimit = Integer.parseInt(argv[++i]);
  +          if (!useXSLTC)
  +          {
  +            if (i + 1 < argv.length)
  +              recursionLimit = Integer.parseInt(argv[++i]);
  +            else
  +              System.err.println(
  +                XSLMessages.createMessage(
  +                  XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
  +                  new Object[]{ "-rl" }));  //"Missing argument for);
  +          }
             else
  -            System.err.println(
  -              XSLMessages.createMessage(
  -                XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION,
  -                new Object[]{ "-rl" }));  //"Missing argument for);
  +          {
  +            if (i + 1 < argv.length)
  +             i++;
  +             
  +            printInvalidXSLTCOption("-RL");
  +          }
           }
   
           else
  @@ -620,7 +653,7 @@
           SAXTransformerFactory stf = (SAXTransformerFactory) tfactory;
           
   		// This is currently controlled via TransformerFactoryImpl.
  -        if (useSourceLocation)
  +        if (!useXSLTC && useSourceLocation)
              stf.setAttribute(XalanProperties.SOURCE_LOCATION, Boolean.TRUE);        
   
           // Did they pass in a stylesheet, or should we get it from the 
  @@ -766,8 +799,9 @@
                   reader = XMLReaderFactory.createXMLReader();
                 }
                 
  -              stf.setAttribute(org.apache.xalan.processor.TransformerFactoryImpl.FEATURE_INCREMENTAL, 
  -                 Boolean.TRUE);
  +              if (!useXSLTC)
  +                stf.setAttribute(org.apache.xalan.processor.TransformerFactoryImpl.FEATURE_INCREMENTAL, 
  +                   Boolean.TRUE);
                    
                 TransformerHandler th = stf.newTransformerHandler(stylesheet);
                 
  @@ -798,36 +832,8 @@
                 
                 th.setResult(strResult);
                 
  -              // System.out.println("sending parse events to the handler...");
  -              // for (int i = 0; i < 50; i++) 
  -              {
  -// System.out.print(".");
  -// if((i % 50) == 0)
  -//   System.out.println("");
  -                reader.parse(new InputSource(inFileName));
  -                // Transformer t = ((org.apache.xalan.transformer.TransformerHandlerImpl)th).getTransformer();
  -                // System.err.println("Calling reset");
  -                // ((TransformerImpl)t).reset();
  -              }
  -              
  -              
  -
  -//              if (contentHandler != null)
  -//              {
  -//                SAXResult result = new SAXResult(contentHandler);
  -//
  -//                transformer.transform(
  -//                  new SAXSource(reader, new InputSource(inFileName)), result);
  -//              }
  -//              else
  -//              {
  -//                transformer.transform(
  -//                  new SAXSource(reader, new InputSource(inFileName)),
  -//                  strResult);
  -//              }
  -
  -              // ===============
  -              }
  +              reader.parse(new InputSource(inFileName));
  +              }                            
               }
               else
               {
  @@ -983,6 +989,14 @@
      * */
     static void doExit(int i)
     {
  -          System.exit(i);
  +    System.exit(i);
  +  }
  +  
  +  /**
  +   * Print a message if an option cannot be used with -XSLTC.
  +   */
  +  private static void printInvalidXSLTCOption(String option)
  +  {
  +    System.err.println(XSLMessages.createMessage("invalid_xsltc_option", new Object[]{option}));
     }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.1   +7 -16     xml-xalan/java/src/org/apache/xpath/objects/XRTreeFragSelectWrapper.java
  
  Index: XRTreeFragSelectWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XRTreeFragSelectWrapper.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- XRTreeFragSelectWrapper.java	22 Mar 2002 01:04:44 -0000	1.5
  +++ XRTreeFragSelectWrapper.java	20 Sep 2002 22:11:58 -0000	1.5.2.1
  @@ -44,27 +44,18 @@
      *
      * @param xctxt The XPath execution context.
      *
  -   * @return This object.
  +   * @return the result of executing the select expression
      *
      * @throws javax.xml.transform.TransformerException
      */
     public XObject execute(XPathContext xctxt)
             throws javax.xml.transform.TransformerException
     {
  -    try
  -    {
  -      m_selected = ((Expression)m_obj).execute(xctxt);
  -      m_selected.allowDetachToRelease(m_allowRelease);
  -      XRTreeFragSelectWrapper xrtf = (XRTreeFragSelectWrapper)this.clone();
  -      return xrtf;
  -    }
  -    catch(CloneNotSupportedException cnse)
  -    {
  -      throw new javax.xml.transform.TransformerException(cnse);
  -    }
  -    
  +     m_selected = ((Expression)m_obj).execute(xctxt);
  +     m_selected.allowDetachToRelease(m_allowRelease);
  +     return m_selected;
     }
  -  
  +    
     /**
      * Detaches the <code>DTMIterator</code> from the set which it iterated
      * over, releasing any computational resources and placing the iterator
  @@ -121,11 +112,11 @@
     /**
      * Tell what kind of class this is.
      *
  -   * @return type CLASS_RTREEFRAG 
  +   * @return the type of the select expression
      */
     public int getType()
     {
  -    return CLASS_STRING; // hmm...
  +    return m_selected.getType();
     }
   
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.8.2  +36 -0     xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.java
  
  Index: XPATHErrorResources.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.java,v
  retrieving revision 1.10.8.1
  retrieving revision 1.10.8.2
  diff -u -r1.10.8.1 -r1.10.8.2
  --- XPATHErrorResources.java	29 Jul 2002 00:01:34 -0000	1.10.8.1
  +++ XPATHErrorResources.java	20 Sep 2002 22:11:58 -0000	1.10.8.2
  @@ -522,9 +522,45 @@
     public static final int ER_ARG_PREFIX_INVALID = 102;
   
    
  +/** Field ER_CANT_CONVERT_TO_BOOLEAN          */
  +  public static final int ER_CANT_CONVERT_TO_BOOLEAN = 103;
  +  
  +  
  +/** Field ER_CANT_CONVERT_TO_SINGLENODE       */
  +  public static final int ER_CANT_CONVERT_TO_SINGLENODE = 104;  
   
  +/** Field ER_CANT_GET_SNAPSHOT_LENGTH         */
  +  public static final int ER_CANT_GET_SNAPSHOT_LENGTH = 105;
  +  
  +/** Field ER_NON_ITERATOR_TYPE                */
  +  public static final int ER_NON_ITERATOR_TYPE        = 106;
   
  +/** Field ER_DOC_MUTATED                      */
  +  public static final int ER_DOC_MUTATED              = 107;
  +  
  +/** Field ER_INVALID_XPATH_TYPE               */
  +  public static final int ER_INVALID_XPATH_TYPE       = 108;
  +  
  +/** Field ER_EMPTY_XPATH_RESULT                */
  +  public static final int ER_EMPTY_XPATH_RESULT       = 109;
   
  +/** Field ER_INCOMPATIBLE_TYPES                */
  +  public static final int ER_INCOMPATIBLE_TYPES       = 110;  
  +  
  +/** Field ER_NULL_RESOLVER                     */
  +  public static final int ER_NULL_RESOLVER            = 111;
  +
  +/** Field ER_CANT_CONVERT_TO_STRING            */
  +  public static final int ER_CANT_CONVERT_TO_STRING   = 112;
  +  
  +/** Field ER_NON_SNAPSHOT_TYPE                 */
  +  public static final int ER_NON_SNAPSHOT_TYPE       = 113;
  +
  +/** Field ER_WRONG_DOCUMENT                    */
  +  public static final int ER_WRONG_DOCUMENT          = 114;
  + 
  +/** Field ER_WRONG_NODETYPE                    */
  +  public static final int ER_WRONG_NODETYPE          = 115; 
     
     // Warnings...
   
  
  
  

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