当前位置: 首页>>代码示例>>Java>>正文


Java Context类代码示例

本文整理汇总了Java中com.icl.saxon.Context的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Context类属于com.icl.saxon包,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVariable

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * <p>Find the string value of a stylesheet variable or parameter</p>
 *
 * <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.</p>
 *
 * @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 "";
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:UnwrapLinks.java

示例2: setupColumnWidths

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * <p>Setup the parameters associated with column width calculations</p>
 *
 * <p>This method queries the stylesheet for the variables
 * associated with table column widths. It is called automatically before
 * column widths are adjusted. The context is used to retrieve the values,
 * this allows templates to redefine these variables.</p>
 *
 * <p>The following variables are queried. If the variables do not
 * exist, builtin defaults will be used (but you may also get a bunch
 * of messages from the Java interpreter).</p>
 *
 * <dl>
 * <dt><code>nominal.table.width</code></dt>
 * <dd>The "normal" width for tables. This must be an absolute length.</dd>
 * <dt><code>table.width</code></dt>
 * <dd>The width for tables. This may be either an absolute
 * length or a percentage.</dd>
 * </dl>
 *
 * @param context The current stylesheet context
 *
 */
private static void setupColumnWidths(Context context) {
  // Hardcoded defaults
  nominalWidth = 6 * pixelsPerInch;
  tableWidth = "100%";

  String varString = null;

  try {
    // Get the stylesheet type
    varString = getVariable(context, "stylesheet.result.type");
    foStylesheet = varString.equals("fo");

    // Get the nominal table width
    varString = getVariable(context, "nominal.table.width");
    nominalWidth = convertLength(varString);

    // Get the table width
    varString = getVariable(context, "table.width");
    tableWidth = varString;
  } catch (TransformerException e) {
    //nop, can't happen
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:47,代码来源:Table.java

示例3: unwrapLinks

import com.icl.saxon.Context; //导入依赖的package包/类
/**
  * <p>Unwrap links</p>
  *
  * @param rtf The result tree fragment of the verbatim environment.
  *
  * @return The modified result tree fragment.
  */
 public static NodeSetValue unwrapLinks (Context context,
				  NodeSetValue rtf_ns) {

   FragmentValue rtf = (FragmentValue) rtf_ns;
   boolean tryAgain = true;

   setupUnwrapLinks(context);

   try {
     Controller controller = context.getController();
     NamePool namePool = controller.getNamePool();

     while (tryAgain) {
UnwrapLinksEmitter ulEmitter = new UnwrapLinksEmitter(controller,
						      namePool,
						      foStylesheet);
rtf.replay(ulEmitter);
tryAgain = ulEmitter.tryAgain();
rtf = (FragmentValue) ulEmitter.getResultTreeFragment();
     }

     return rtf;

   } catch (TransformerException e) {
     // This "can't" happen.
     System.out.println("Transformer Exception in unwrapLinks");
     return rtf;
   }
 }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:UnwrapLinks.java

示例4: getVariable

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * <p>Find the string value of a stylesheet variable or parameter</p>
 *
 * <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.</p>
 *
 * @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) 
  throws TransformerException {
  Value variable = null;
  String varString = null;

  try {
    variable = Extensions.evaluate(context, "$" + varName);
    varString = variable.asString();
    return varString;
  } catch (IllegalArgumentException e) {
    System.out.println("Undefined variable: " + varName);
    return "";
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:Table.java

示例5: addVariables

import com.icl.saxon.Context; //导入依赖的package包/类
void addVariables(StyleElement element, ArrayList<Debugger.Variable> variables, Enumeration enumeration, boolean isGlobal) {
  final Context context = myContext;
  final StaticContext ctx = context.getStaticContext();

  final NamePool pool = element.getNamePool();
  final Bindery bindery = context.getBindery();

  while (enumeration.hasMoreElements()) {
    String name = (String)enumeration.nextElement();
    try {
      final String[] parts = name.split("\\^");
      final String realname = parts[1];
      final int fingerprint = ctx != null ? ctx.getFingerprint(realname, false) : pool.getFingerprint(parts[0], realname);
      final Binding binding = element.getVariableBinding(fingerprint);
      final Debugger.Variable.Kind kind =
        binding instanceof XSLParam ? Debugger.Variable.Kind.PARAMETER : Debugger.Variable.Kind.VARIABLE;
      final com.icl.saxon.expr.Value value = bindery.getValue(binding, myFrameId);

      if (binding instanceof XSLGeneralVariable) {
        final XSLGeneralVariable v = (XSLGeneralVariable)binding;
        final String id = v.getSystemId();
        variables.add(new VariableImpl(realname, convertValue(value), isGlobal, kind, id != null ? id.replaceAll(" ", "%20") : null,
                                       v.getLineNumber()));
      } else {
        variables.add(new VariableImpl(realname, convertValue(value), isGlobal, kind, null, -1));
      }
    } catch (XPathException e) {
      // this should never happen I guess...
      e.printStackTrace();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:SaxonFrameImpl.java

示例6: enterSource

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * Called when a node of the source tree gets processed
 */
public void enterSource(NodeHandler handler, Context context) {
  NodeInfo curr = context.getContextNodeInfo();
  final String path = Navigator.getPath(curr);
  if (TRACE) {
    trace(indent + "<Source node=\"" + path
          + "\" line=\"" + curr.getLineNumber()
          + "\" mode=\"" + getModeName(context) + "\">");
    indent += " ";
  }

  myDebugger.pushSource(new SaxonSourceFrame(myDebugger.getSourceFrame(), curr));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:SaxonTraceListener.java

示例7: leaveSource

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * Called after a node of the source tree got processed
 */
public void leaveSource(NodeHandler handler, Context context) {
  if (TRACE) {
    indent = indent.substring(0, indent.length() - 1);
    trace(indent + "</Source><!-- " +
          Navigator.getPath(context.getContextNodeInfo()) + " -->");
  }

  myDebugger.popSource();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:SaxonTraceListener.java

示例8: enter

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * Called when an element of the stylesheet gets processed
 */
public void enter(NodeInfo element, Context context) {
  if (element.getNodeType() == NodeInfo.ELEMENT) {
    if (TRACE) {
      trace(indent + "<Instruction element=\"" + element.getDisplayName() + "\" line=\"" + element.getLineNumber() + "\">");
      indent += " ";
    }

    myDebugger.enter(new SaxonFrameImpl(myDebugger.getCurrentFrame(), context, (StyleElement)element));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SaxonTraceListener.java

示例9: leave

import com.icl.saxon.Context; //导入依赖的package包/类
/**
   * Called after an element of the stylesheet got processed
   */
  public void leave(NodeInfo element, Context context) {
    if (element.getNodeType() == NodeInfo.ELEMENT) {
//            final int lineNumber = element.getLineNumber();
//            final String uri = element.getSystemId();

      myDebugger.leave();

      if (TRACE) {
        indent = indent.substring(0, indent.length() - 1);
        trace(indent + "</Instruction> <!-- " +
              element.getDisplayName() + " -->");
      }
    }
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SaxonTraceListener.java

示例10: getModeName

import com.icl.saxon.Context; //导入依赖的package包/类
static String getModeName(Context context) {
  Mode mode = context.getMode();
  if (mode == null) return "#none";
  int nameCode = mode.getNameCode();
  if (nameCode == -1) {
    return "#default";
  } else {
    return context.getController().getNamePool().getDisplayName(nameCode);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:SaxonTraceListener.java

示例11: unwrapLinks

import com.icl.saxon.Context; //导入依赖的package包/类
/**
  * <p>Unwrap links</p>
  *
  * @param context The current stylesheet context.
  * @param rtf_ns The result tree fragment of the verbatim environment.
  *
  * @return The modified result tree fragment.
  */
 public static NodeSetValue unwrapLinks (Context context,
				  NodeSetValue rtf_ns) {

   FragmentValue rtf = (FragmentValue) rtf_ns;
   boolean tryAgain = true;

   setupUnwrapLinks(context);

   try {
     Controller controller = context.getController();
     NamePool namePool = controller.getNamePool();

     while (tryAgain) {
UnwrapLinksEmitter ulEmitter = new UnwrapLinksEmitter(controller,
						      namePool,
						      foStylesheet);
rtf.replay(ulEmitter);
tryAgain = ulEmitter.tryAgain();
rtf = (FragmentValue) ulEmitter.getResultTreeFragment();
     }

     return rtf;

   } catch (TransformerException e) {
     // This "can't" happen.
     System.out.println("Transformer Exception in unwrapLinks");
     return rtf;
   }
 }
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:38,代码来源:UnwrapLinks.java

示例12: SaxonFrameImpl

import com.icl.saxon.Context; //导入依赖的package包/类
SaxonFrameImpl(Debugger.StyleFrame prev, Context context, StyleElement element) {
  super(prev, element);
  myContext = context;
  myFrameId = context.getBindery().getFrameId();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:SaxonFrameImpl.java

示例13: process

import com.icl.saxon.Context; //导入依赖的package包/类
public void process(Context context) throws TransformerException {
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:3,代码来源:SaxonFrameImpl.java

示例14: insertCallouts

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * <p>Insert text callouts into a verbatim environment.</p>
 *
 * <p>This method examines the <tt>areaset</tt> and <tt>area</tt> elements
 * in the supplied <tt>areaspec</tt> and decorates the supplied
 * result tree fragment with appropriate callout markers.</p>
 *
 * <p>If a <tt>label</tt> attribute is supplied on an <tt>area</tt>,
 * its content will be used for the label, otherwise the callout
 * number will be used, surrounded by parenthesis. Callout numbers may
 * also be represented as graphics. Callouts are
 * numbered in document order. All of the <tt>area</tt>s in an
 * <tt>areaset</tt> get the same number.</p>
 *
 * <p>Only the <tt>linecolumn</tt> and <tt>linerange</tt> units are
 * supported. If no unit is specifed, <tt>linecolumn</tt> is assumed.
 * If only a line is specified, the callout decoration appears in
 * the defaultColumn. Lines will be padded with blanks to reach the
 * necessary column, but callouts that are located beyond the last
 * line of the verbatim environment will be ignored.</p>
 *
 * <p>Callouts are inserted before the character at the line/column
 * where they are to occur.</p>
 *
 * <p>If graphical callouts are used, and the callout number is less
 * than or equal to the $callout.graphics.number.limit, the following image
 * will be generated for HTML:
 *
 * <pre>
 * &lt;img src="$callout.graphics.path/999$callout.graphics.ext"
 *         alt="conumber">
 * </pre>
 *
 * If the $stylesheet.result.type is 'fo', the following image will
 * be generated:
 *
 * <pre>
 * &lt;fo:external-graphic src="$callout.graphics.path/999$callout.graphics.ext"/>
 * </pre>
 *
 * <p>If the callout number exceeds $callout.graphics.number.limit,
 * the callout will be the callout number surrounded by
 * parenthesis.</p>
 *
 * @param context The stylesheet context.
 * @param areaspecNodeList The source node set that contains the areaspec.
 * @param rtf_ns The result tree fragment of the verbatim environment.
 *
 * @return The modified result tree fragment.
 */
public static NodeSetValue insertCallouts (Context context,
			     NodeList areaspecNodeList,
			     NodeSetValue rtf_ns) {

  FragmentValue rtf = (FragmentValue) rtf_ns;

  setupCallouts(context);

  try {
    Controller controller = context.getController();
    NamePool namePool = controller.getNamePool();
    CalloutEmitter cEmitter = new CalloutEmitter(controller,
				   namePool,
				   defaultColumn,
				   foStylesheet,
				   fCallout);
    cEmitter.setupCallouts(areaspecNodeList);
    rtf.replay(cEmitter);
    return cEmitter.getResultTreeFragment();
  } catch (TransformerException e) {
    // This "can't" happen.
    System.out.println("Transformer Exception in insertCallouts");
    return rtf;
  }
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:76,代码来源:Verbatim.java

示例15: process

import com.icl.saxon.Context; //导入依赖的package包/类
/**
 * @see com.icl.saxon.style.StyleElement#process(com.icl.saxon.Context)
 */
public void process(Context context) throws TransformerException {
    //nop
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:7,代码来源:BarcodeNonRootStyleElement.java


注:本文中的com.icl.saxon.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。