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


Java XPathException类代码示例

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


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

示例1: testQueryElementNotImplementedAxis

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Test
public void testQueryElementNotImplementedAxis() throws Exception {
    final String xpath = "/CLASS_DEF//following-sibling::METHOD_DEF";
    final RootNode rootNode = getRootNode("InputXpathMapperAst.java");
    try {
        getXpathItems(xpath, rootNode);
        fail("Exception is excepted");
    }
    catch (XPathException ex) {
        assertEquals("Invalid number of nodes", "Operation is not supported", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:XpathMapperTest.java

示例2: getItems

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
/**
 * Returns list of nodes matching xpath expression given event.
 * @param event {@code TreeWalkerAuditEvent} object
 * @return list of nodes matching xpath expression given event
 */
private List<Item> getItems(TreeWalkerAuditEvent event) {
    final RootNode rootNode;
    if (event.getRootAst() == null) {
        rootNode = null;
    }
    else {
        rootNode = new RootNode(event.getRootAst());
    }
    final List<Item> items;
    try {
        final XPathDynamicContext xpathDynamicContext =
                xpathExpression.createDynamicContext(rootNode);
        items = xpathExpression.evaluate(xpathDynamicContext);
    }
    catch (XPathException ex) {
        throw new IllegalStateException("Cannot initialize context and evaluate query: "
                + xpathQuery, ex);
    }
    return items;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:XpathFilter.java

示例3: close

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Override
public void close() throws XPathException {
    String fileName = getParameter(FileAppenderStep.FILE_NAME).toString();
    String value = getParameter(FileAppenderStep.VALUE).toString();
    String lineSeparator = FileAppenderStep.getLineSeparator(getParameter(FileAppenderStep.LINE_SEPARATOR));
    Charset encoding = FileAppenderStep.getCharset(getParameter(FileAppenderStep.ENCODING));
    File f = new File(fileName);
    try {
        FileOutputStream fos = new FileOutputStream(f, true);
        try (OutputStreamWriter osw = new OutputStreamWriter(fos, encoding)) {
            osw.append(value);
            osw.append(lineSeparator);
            osw.flush();
        }
    } catch(IOException ex) {
        LOGGER.error("while writting to "+fileName,ex);
    }
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:19,代码来源:FileAppenderTerminalStep.java

示例4: close

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Override
public void close() throws XPathException {
    super.close(); 
    String fileName = getParameter(FILE_NAME).toString();
    String value = getParameter(VALUE).toString();
    String lineSeparator = getLineSeparator(getParameter(LINE_SEPARATOR));
    Charset encoding = getCharset(getParameter(ENCODING));
    File f = new File(fileName);
    try {
        FileOutputStream fos = new FileOutputStream(f, true);
        try (OutputStreamWriter osw = new OutputStreamWriter(fos, encoding)) {
            osw.append(value);
            osw.append(lineSeparator);
            osw.flush();
        }
    } catch(IOException ex) {
        LOGGER.error("while writting to "+fileName,ex);
    }
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:20,代码来源:FileAppenderStep.java

示例5: createVariableValue

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
private Value createVariableValue(ValueFacade facade) {
  try {
    return createValue(facade);
  } catch (XPathException e) {
    return new ErrorValue(e.getMessage(), facade);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:Saxon9StyleFrame.java

示例6: iterate

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
public SequenceIterator iterate(XPathContext context) throws XPathException {
  final SequenceIterator iterator = myVariable.iterate(context);
  if (iterator instanceof EmptyIterator) {
    final ValueRepresentation value = myVariable.evaluateVariable(context);
    if (value instanceof Item) {
      return SingletonIterator.makeIterator((Item)value);
    } else if (value instanceof net.sf.saxon.value.Value) {
      return ((net.sf.saxon.value.Value)value).iterate();
    } else {
      return iterator;
    }
  } else {
    return iterator;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:Saxon9StyleFrame.java

示例7: init

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
public static boolean init(Transformer transformer, final LocalDebugger dbg) {
  if (transformer instanceof Controller) {
    System.out.println("SAXON 9");
    final Controller controller = (Controller)transformer;
    ((Saxon9TraceListener)controller.getConfiguration().getTraceListener()).setDebugger(dbg);
    controller.getConfiguration().setLineNumbering(true);
    controller.getConfiguration().setCompileWithTracing(true);
    controller.getConfiguration().setMultiThreading(false);
    controller.getConfiguration().setSerializerFactory(new SerializerFactory(controller.getConfiguration()) {
      @Override
      protected Receiver createXMLSerializer(Emitter emitter,
                                             Properties props,
                                             PipelineConfiguration pipe,
                                             CharacterMapExpander characterMapExpander,
                                             ProxyReceiver normalizer) throws XPathException {
        return super.createXMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
      }

      @Override
      protected Emitter newXMLEmitter() {
        return new TracingOutputter(dbg.getEventQueue(), super.newXMLEmitter());
      }
    });
    controller.getConfiguration().setDebugger(new Debugger() {
      public SlotManager makeSlotManager() {
        return new SlotManager() {
          @Override
          public int allocateSlotNumber(StructuredQName qName) {
            System.out.println("qName = " + qName);
            return super.allocateSlotNumber(qName);
          }
        };
      }
    });
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:Saxon9Support.java

示例8: makeCallExpression

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
    return new ExtensionFunctionCall() {
        private static final long serialVersionUID = 1L;

        @Override
        public Sequence call(XPathContext xPathContext, Sequence[] arguments) throws XPathException {
            // 1st argument (mandatory, index 0)
            StringValue arg1 = (StringValue) arguments[0].iterate().next();
            String arg1Str = arg1.getStringValue();

            // 2nd argument (optional, index 1)
            String arg2Str = "";
            if (arguments.length > 1) {
                StringValue arg2 = (StringValue) arguments[1].iterate().next();
                arg2Str = arg2.getStringValue();
            }

            // Functionality goes here
            String resultStr = arg1Str + arg2Str;

            Item result = new StringValue(resultStr);
            return SequenceTool.toLazySequence(SingletonIterator.makeIterator(result));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:MyExtensionFunction2.java

示例9: makeCallExpression

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
    return new ExtensionFunctionCall() {
        private static final long serialVersionUID = 1L;

        @Override
        public Sequence call(XPathContext xPathContext, Sequence[] arguments) throws XPathException {
            // 1st argument (mandatory, index 0)
            Int64Value arg1 = (Int64Value) arguments[0].iterate().next();
            int arg1Int = arg1.getDecimalValue().toBigInteger().intValue();

            // 2nd argument (mandatory, index 1)
            Int64Value arg2 = (Int64Value) arguments[1].iterate().next();
            int arg2Int = arg2.getDecimalValue().toBigInteger().intValue();

            // Functionality goes here
            int resultInt = arg1Int + arg2Int;

            Item result = new Int64Value(resultInt);
            return SequenceTool.toLazySequence(SingletonIterator.makeIterator(result));
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MyExtensionFunction1.java

示例10: makeCallExpression

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Override
public ExtensionFunctionCall makeCallExpression() {
    return new ExtensionFunctionCall() {

        private static final long serialVersionUID = 1L;

        @Override
        public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
            // get value of first arg passed to the function
            Item arg1 = sequences[0].head();
            String arg1Val = arg1.getStringValue();

            // return a altered version of the first arg
            return new StringValue("arg1[" + arg1Val + "]");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:XQueryWithExtensionTest.java

示例11: xslt

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
public static String xslt(String xmlInput, Controller controller) throws Exception {
	String strResult = "";
	try {
		Source sourceInput = new StreamSource(new StringReader(xmlInput));
		StringWriter outWriter = new StringWriter();
		javax.xml.transform.Result result = new StreamResult(outWriter);
		try {
			controller.transform(sourceInput, result);
			strResult = outWriter.getBuffer().toString();
		} catch (XPathException err) {
			if (!err.hasBeenReported()) {
				err.printStackTrace();
			}
			throw new XPathException("Run-time errors were reported");
		}
	} catch (Exception e) {
		throw e;
	}
	return strResult;
}
 
开发者ID:regestaexe,项目名称:bygle-ldp,代码行数:21,代码来源:TrasformXslt.java

示例12: getStringValueOrNull

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
static String getStringValueOrNull(Sequence[] pArguments, int pIndex, String pFunctionName, boolean pStrict)
throws XPathException {
  String lResult = null;
  if(pArguments.length > pIndex) {
    Item lItem = pArguments[pIndex].head();
    if(!(lItem instanceof StringValue) && pStrict) {
      throw new ExInternal("Argument " + (pIndex+1) + " to " + pFunctionName + " function must be a string.");
    }

    if(lItem != null) {
      lResult = lItem.getStringValue();
    }
  }
  return lResult;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:16,代码来源:FunctionUtils.java

示例13: serialize

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
@Override
public void serialize(OutputStream out, Properties params) throws HttpClientException {
  // TODO: childs can be childs of http:body. Even if the 'http' prefix is
  // in @exclude-result-prefixes, its namespace declaration is serialized
  // in the output (I guess because http:body is still the parent of
  // childs, so ns normalization requires it. How to do?
  // TODO: Look for what Norm uses in Calabash. I know I saw a post from
  // him on the Saxon mailing list on that subject...
  Configuration config = myCtxt.getConfiguration();
  try {
    QueryResult.serializeSequence(myIt, config, out, params);
  } catch (XPathException ex) {
    throw new HttpClientException("Error serializing the single part body", ex);
  }
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:16,代码来源:SaxonSequence.java

示例14: call

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {

        	final Processor 		processor 	= new Processor(context.getConfiguration());
			final DocumentBuilder 	builder 	= processor.newDocumentBuilder();
			
			try {
				BuildingStreamWriterImpl writer = builder.newBuildingStreamWriter();

				writer.writeStartElement("test1");
				writer.writeCharacters("text1");
				writer.writeEndElement();
				
				writer.writeStartElement("test2");
				writer.writeCharacters("text2");
				writer.writeEndElement();
				
				return writer.getDocumentNode().getUnderlyingValue();
				
			} catch (SaxonApiException | XMLStreamException e) {
				logger.error(e, e);
				throw new XPathException("Failed to create return value: " + e.getMessage());
			}
        }
 
开发者ID:dita-semia,项目名称:XsltGui,代码行数:24,代码来源:GuiTest.java

示例15: resolveToString

import net.sf.saxon.trans.XPathException; //导入依赖的package包/类
public String resolveToString(List<Parameter> frameworkParameters) throws XPathException, TempContextException {
	//logger.info("resolveToString: " + getScriptName());
	final NodeInfo 	resolvedNode 	= resolve(frameworkParameters);
	final String resolvedString = SaxonNodeWrapper.serializeNode(resolvedNode);
	//logger.info(resolvedString);
	return resolvedString;
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:8,代码来源:XsltConref.java


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