Example #1
0
 /**
  * Returns a string representation of all found arguments.
  *
  * @param args array with arguments
  * @return string representation
  */
 static String foundArgs(final Value[] args) {
   // compose found arguments
   final StringBuilder sb = new StringBuilder();
   for (final Value v : args) {
     if (sb.length() != 0) sb.append(", ");
     sb.append(v instanceof Jav ? Util.className(((Jav) v).toJava()) : v.seqType());
   }
   return sb.toString();
 }
  /**
   * Find the string value of a stylesheet variable or parameter
   *
   * <p>Returns the string value of <code>varName</code> in the current <code>context</code>.
   * Returns the empty string if the variable is not defined.
   *
   * @param context The current stylesheet context
   * @param varName The name of the variable (without the dollar sign)
   * @return The string value of the variable
   */
  protected static String getVariable(Context context, String varName) {
    Value variable = null;
    String varString = null;

    try {
      variable = Extensions.evaluate(context, "$" + varName);
      varString = variable.asString();
      return varString;
    } catch (TransformerException te) {
      System.out.println("Undefined variable: " + varName);
      return "";
    } catch (IllegalArgumentException iae) {
      System.out.println("Undefined variable: " + varName);
      return "";
    }
  }