gpt4 book ai didi

org.apache.commons.jelly.parser.XMLParser类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 13:45:05 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.commons.jelly.parser.XMLParser类的一些代码示例,展示了XMLParser类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLParser类的具体详情如下:
包路径:org.apache.commons.jelly.parser.XMLParser
类名称:XMLParser

XMLParser介绍

[英]XMLParser parses the XML Jelly format. The SAXParser and XMLReader portions of this code come from Digester.
[中]XMLParser解析XML Jelly格式。这段代码的SAXParser和XMLReader部分来自Digester。

代码示例

代码示例来源:origin: commons-jelly/commons-jelly

/**
 * Compile the script
 */
private void compileScriptAndKeep() {
  XMLParser parser = new XMLParser();
  parser.setContext(m_context);
  m_scriptCompiled = false;
  try {
    m_script = parser.parse(m_inputStream);
    m_script = m_script.compile();
    m_scriptCompiled = true;
  }
  catch (IOException e) {
    m_scriptCompilationException = e;
  }
  catch (SAXException e) {
    m_scriptCompilationException = e;
  }
  catch (Exception e) {
    m_scriptCompilationException = e;
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

/**
 * Adds the text to the current script block parsing any embedded
 * expressions inot ExpressionScript objects.
 */
protected void addTextScript(String text) throws JellyException {
  Expression expression =
    CompositeExpression.parse(text, getExpressionFactory());
  addExpressionScript(script, expression);
}

代码示例来源:origin: commons-jelly/commons-jelly

/**
 * If this object has not been configured then register the default
 * namespaces
 */
private void ensureConfigured() {
  if (!configured) {
    configure();
    configured = true;
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

/**
   * Factory method to create a new Jelly parser
   * @return XMLParser
   */
  protected XMLParser createJellyParser() {
    XMLParser answer = new XMLParser();
    answer.setContext(context);
    return answer;
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

XMLParser parser = new XMLParser();
try {
  parser.setContext(getJellyContext());
} catch (MalformedURLException e) {
  throw new JellyException(e.toString());
  parser.setDefaultNamespaceURI(this.defaultNamespaceURI);
  parser.setValidating(this.validateXML);
  script = parser.parse(getUrl());
  script = script.compile();
  if (log.isDebugEnabled()) {

代码示例来源:origin: commons-jelly/commons-jelly

Class taglibClass = getClassLoader().loadClass(uri);
      taglib = (TagLibrary) taglibClass.newInstance();
      context.registerTagLibrary(namespaceURI, taglib);
      throw createSAXException("Could not load class: " + uri + " so taglib instantiation failed", e);
      throw createSAXException("Constructor for class is not accessible: " + uri + " so taglib instantiation failed",e);
      throw createSAXException("Class could not be instantiated: " + uri + " so taglib instantiation failed",e);
      throw createSAXException("Class is not a TagLibrary: " + uri + " so taglib instantiation failed",e);
  TagScript script = taglib.createTagScript(localName, list);
  if ( script != null ) {
    configureTagScript(script);
      Expression expression =
        taglib.createExpression(
          getExpressionFactory(),
          script,
          attributeName,
          attributeValue);
      if (expression == null) {
        expression = createConstantExpression(localName, attributeName, attributeValue);
  "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName,
  e);
throw createSAXException(e);

代码示例来源:origin: org.jvnet.hudson/commons-jelly

/**
 * Attempts to parse the script from the given InputSource using the
 * {@link #getResource} method then returns the compiled script.
 */
public Script compileScript(InputSource source) throws JellyException {
  XMLParser parser = getXMLParser();
  parser.setContext(this);
  Script script = null;
  try {
    script = parser.parse(source);
  } catch (IOException e) {
    throw new JellyException(JellyContext.BAD_PARSE+" : "+source.getSystemId(), e);
  } catch (SAXException e) {
    throw new JellyException(JellyContext.BAD_PARSE+" : "+source.getSystemId(), e);
  }
  return script.compile();
}

代码示例来源:origin: org.jvnet.hudson/commons-jelly

TagScript newTagScript = createTag(namespaceURI, localName, list);
if (newTagScript == null) {
  newTagScript = createStaticTag(namespaceURI, localName, qName, list);
  addTextScript(textBuffer.toString(),true);
  textBuffer.setLength(0);
throw createSAXException( "Runtime Exception: " + e, e );

代码示例来源:origin: maven/maven

factory.setNamespaceAware( true );
XMLReader reader = factory.newSAXParser().getXMLReader();
XMLParser parser = new XMLParser( reader );
parser.setContext( context );
parser.setClassLoader( context.getClassLoader() );
script = parser.parse( source );

代码示例来源:origin: org.jvnet.hudson/commons-jelly

/**
 * Factory method to create a static Tag that represents some static content.
 *
 * <p>
 * Note that to if you use jelly:define taglib, these tags might turn out to be non-static
 * during the runtime.
 */
protected TagScript createStaticTag(
  final String namespaceURI,
  final String localName,
  final String qName,
  Attributes list)
  throws SAXException {
  try {
    StaticTagScript script = new StaticTagScript();
    configureTagScript(script);
    configureStaticTagAttributes(script,list);
    return script;
  }
  catch (Exception e) {
    log.warn(
      "Could not create static tag for URI: "
        + namespaceURI
        + " tag name: "
        + localName,
      e);
    throw createSAXException(e);
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

public void testArgs() throws Exception {
  InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/test_args.jelly");
  XMLParser parser = new XMLParser();
  Script script = parser.parse(in);
  script = script.compile();
  log.debug("Found: " + script);
  assertTrue("Parsed a Script", script instanceof Script);
  String[] args = { "one", "two", "three" };
  JellyContext context = new JellyContext();
  context.setVariable("args", args);
  StringWriter buffer = new StringWriter();
  script.run(context, XMLOutput.createXMLOutput(buffer));
  String text = buffer.toString().trim();
  if (log.isDebugEnabled()) {
    log.debug("Evaluated script as...");
    log.debug(text);
  }
  assertEquals("Produces the correct output", "one two three", text);
}

代码示例来源:origin: commons-jelly/commons-jelly

configureTagScript(script);
  String attributeValue = list.getValue(i);
  Expression expression = CompositeExpression.parse(
      attributeValue, getExpressionFactory()
    );
  String attrQName = list.getQName(i);
    + localName,
  e);
throw createSAXException(e);

代码示例来源:origin: commons-jelly/commons-jelly

TagScript newTagScript = createTag(namespaceURI, localName, list);
if (newTagScript == null) {
  newTagScript = createStaticTag(namespaceURI, localName, qName, list);
    addTextScript(textBuffer.toString());
    textBuffer.setLength(0);

代码示例来源:origin: commons-jelly/commons-jelly

/**
   * Create a SAX exception which also understands about the location in
   * the digester file where the exception occurs
   *
   * @return the new exception
   */
  protected SAXException createSAXException(String message) {
    return createSAXException(message, null);
  }
}

代码示例来源:origin: org.hudsonci.stapler/commons-jelly

tagScript = (TagScript) tagScriptStack.remove(tagScriptStack.size() - 1);
  if (textBuffer.length() > 0) {
    addTextScript(textBuffer.toString(),false);
    textBuffer.setLength(0);
} catch (Exception e) {
  log.error( "Caught exception: " + e, e );
  throw createSAXException( "Runtime Exception: " + e, e );

代码示例来源:origin: commons-jelly/commons-jelly

/**
 * Parse the content of the specified file using this XMLParser.  Returns
 * the root element from the object stack (if any).
 *
 * @param file File containing the XML data to be parsed
 *
 * @exception IOException if an input/output error occurs
 * @exception SAXException if a parsing exception occurs
 */
public Script parse(File file) throws IOException, SAXException {
  return parse(file.toURL());
}

代码示例来源:origin: commons-jelly/commons-jelly

/**
 * Factory method to allow JellyContext implementations to overload how an XMLParser
 * is created - such as to overload what the default ExpressionFactory should be.
 */
protected XMLParser createXMLParser() {
  return new XMLParser(allowDtdToCallExternalEntities);
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

@Override
protected void addExpressionScript(ScriptBlock script, Expression exp) {
  try {
    if (exp instanceof InternationalizedStringExpression && escapeByDefaultField.getBoolean(this)) {
      script.addScript(new ExpressionScript(((InternationalizedStringExpression) exp).escape()));
      return; // stick with our escaped+internationalized script
    }
  } catch (Exception e) {
    // fall back to original behaviour...
  }
  super.addExpressionScript(script, exp);
}

代码示例来源:origin: org.jenkins-ci/commons-jelly

/**
 * Adds the given Expression object to the current Script.
 */
protected void addExpressionScript(ScriptBlock script, Expression expression) {
  if ( expression instanceof ConstantExpression ) {
    ConstantExpression constantExpression
      = (ConstantExpression) expression;
    Object value = constantExpression.getValue();
    if ( value != null ) {
      script.addScript(new TextScript( value.toString() ));
    }
  }
  else
  if ( expression instanceof CompositeExpression ) {
    CompositeTextScriptBlock newBlock = new CompositeTextScriptBlock();
    script.addScript(newBlock);
    CompositeExpression compositeExpression
      = (CompositeExpression) expression;
    Iterator iter = compositeExpression.getExpressions().iterator();
    while (iter.hasNext()) {
      addExpressionScript( newBlock, (Expression) iter.next() );
    }
  }
  else {
    if (escapeByDefault)
      expression = createEscapingExpression(expression);
    script.addScript(new ExpressionScript(expression));
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

/** @return the expression factory used to evaluate tag attributes */
public ExpressionFactory getExpressionFactory() {
  if (expressionFactory == null) {
    expressionFactory = createExpressionFactory();
  }
  return expressionFactory;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com