net.sf.saxon.trans.XPathException Java Examples
The following examples show how to use
net.sf.saxon.trans.XPathException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyConcatExtensionFunctionDefinition.java From kite with Apache License 2.0 | 6 votes |
@Override public ExtensionFunctionCall makeCallExpression() { return new ExtensionFunctionCall() { @Override public Sequence call(XPathContext ctx, Sequence[] secs) throws XPathException { if (secs.length == 0) { throw new XPathException("Missing argument"); } else { StringBuilder buf = new StringBuilder(); for (Sequence seq : secs) { SequenceIterator<? extends Item> iter = seq.iterate(); while (iter.next() != null) { buf.append(iter.current().getStringValue()); } } return new StringValue(buf.toString()); } } }; }
Example #2
Source File: XPathParser.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 6 votes |
private XPathContext parseDocument(Document doc) throws TransformerException, XPathException, DOMException, ComponentNotReadyException { // get just one context element ports = new LinkedList<Integer>(); NodeList list = doc.getChildNodes(); Node node = null; boolean found = false; for (int i=0; i<list.getLength(); i++) { if (list.item(i).getNodeName().equalsIgnoreCase(ELEMENT_CONTEXT)) { if (found) { found = false; break; } else { node = list.item(i); found = true; } } } if (!found) throw new TransformerException("Every xpath must contain just one " + ELEMENT_CONTEXT + " element!"); return parseXpathContext(node, new HashMap<String, String>(), null); }
Example #3
Source File: SaxonItemConverter.java From intellij-xquery with Apache License 2.0 | 5 votes |
public static String[] getSequenceValue(Sequence sequence) { if (sequence == null) return null; try { return getSequenceValue(sequence.iterate()); } catch (XPathException e) { return null; } }
Example #4
Source File: TEXSLFunctionCall.java From teamengine with Apache License 2.0 | 5 votes |
public static String getType(Expression expr, XPathContext context) throws XPathException { ValueRepresentation vr = ExpressionTool.lazyEvaluate(expr, context, 1); ItemType it = Value.asValue(vr).getItemType( context.getConfiguration().getTypeHierarchy()); if (it instanceof SchemaType) { return "xs:" + ((SchemaType) it).getName(); } return "xs:any"; }
Example #5
Source File: GetTypeFunctionCall.java From teamengine with Apache License 2.0 | 5 votes |
public SequenceIterator iterate(XPathContext context) throws XPathException { Expression[] argExpressions = getArguments(); ValueRepresentation vr = ExpressionTool.lazyEvaluate(argExpressions[0], context, 1); ItemType it = Value.asValue(vr).getItemType( context.getConfiguration().getTypeHierarchy()); String type = getTypeName(it); Value v = Value.convertJavaObjectToXPath(type, SequenceType.SINGLE_STRING, context); return v.iterate(); }
Example #6
Source File: SaxonRunnerAppFactory.java From intellij-xquery with Apache License 2.0 | 5 votes |
@Override public RunnerApp getInstance(XQueryRunConfig config, PrintStream output) throws XPathException { if (config.isDebugEnabled()) { return new SaxonDebuggerApp(config, output); } return new SaxonRunnerApp(config, output); }
Example #7
Source File: SaxonDebugFrame.java From intellij-xquery with Apache License 2.0 | 5 votes |
private Sequence getSequence(GlobalVariable globalVariable) { try { return globalVariable.evaluateVariable(xPathContext); } catch (XPathException e) { e.printStackTrace(); } return null; }
Example #8
Source File: SaxonItemConverter.java From intellij-xquery with Apache License 2.0 | 5 votes |
public static String[] getSequenceValue(SequenceIterator iterator) { String type = "item()"; try { List<String> sequenceItems = new ArrayList<>(); Item next = iterator.next(); if (next != null && next instanceof AtomicValue) { type = ((AtomicValue) next).getPrimitiveType().getPrimitiveItemType().toString(); } else if (next != null && next instanceof HashTrieMap) { type = "map(*)"; } while (next != null) { sequenceItems.add(itemToString(next)); next = iterator.next(); } StringBuilder sb = new StringBuilder(); int numberOfSequenceItems = sequenceItems.size(); if (numberOfSequenceItems > 1) { sb.append("("); } for (int i = 0; i < numberOfSequenceItems; i++) { sb.append(sequenceItems.get(i)); if (i < numberOfSequenceItems - 1) { sb.append(", "); } } if (numberOfSequenceItems > 1) { sb.append(")"); type = type + "*"; } return new String[]{sb.toString(), type}; } catch (XPathException e) { return null; } }
Example #9
Source File: XmlXPathEvaluator.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
private XPathExpression getExpression(String xpath) { XPathExpression expression = expressions.get(xpath); if (expression == null) { try { expression = evaluator.createExpression(xpath); } catch (XPathException e) { throw new JetelRuntimeException(e); } expressions.put(xpath, expression); } return expression; }
Example #10
Source File: XmlXPathEvaluator.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Object evaluatePath(String xpath, Map<String, String> namespaceBinding, Object context, MappingElement element) { setNamespacesToEvaluator(namespaceBinding); XPathExpression expression = getExpression(xpath); List<?> nodeList; try { nodeList = expression.evaluate((Source) context); } catch (XPathException e) { throw new JetelRuntimeException(e); } if (element instanceof FieldMapping) { return nodeList; } else if (element instanceof MappingContext) { switch (nodeList.size()) { case 0: return null; case 1: return nodeList.get(0); default: throw new JetelRuntimeException("XPath '" + xpath + "' contains two or more values!"); } } else { throw new IllegalArgumentException("Unknown type of mapping element " + element); } }
Example #11
Source File: SaxonDebuggerApp.java From intellij-xquery with Apache License 2.0 | 4 votes |
public SaxonDebuggerApp(XQueryRunConfig config, PrintStream output) throws XPathException { super(config, output); applicationThread = new Thread(getApplicationRunnable()); }
Example #12
Source File: StrictRelativeResolvingStrategy.java From validator with Apache License 2.0 | 4 votes |
@Override public Reader resolve(final URI absoluteURI, final String encoding, final Configuration config) throws XPathException { throw new IllegalStateException(MESSAGE); }
Example #13
Source File: XPathParser.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
public XPathContext parseXPath(InputStream inputStream) throws SAXException, IOException, ParserConfigurationException, TransformerException, XPathException, DOMException, ComponentNotReadyException { // create and process document Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream); return parseDocument(doc); }
Example #14
Source File: SaxonRunnerApp.java From intellij-xquery with Apache License 2.0 | 4 votes |
public SaxonRunnerApp(XQueryRunConfig config, PrintStream output) throws XPathException { this.config = config; this.output = output; setUpProcessor(config); }
Example #15
Source File: SaxonRunnerApp.java From intellij-xquery with Apache License 2.0 | 4 votes |
private Configuration getConfiguration(XQueryRunConfig config) throws XPathException { File configFile = new File(config.getConfigFile()); return Configuration.readConfiguration(new StreamSource(configFile)); }
Example #16
Source File: GetTypeFunctionCall.java From teamengine with Apache License 2.0 | 4 votes |
public static String getTypeName(ItemType it) throws XPathException { if (it instanceof SchemaType) { return "xs:" + ((SchemaType) it).getName(); } return it.toString(); }
Example #17
Source File: XPathParser.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
public XPathContext parseXPath(Document xmlDocument) throws SAXException, IOException, ParserConfigurationException, TransformerException, XPathException, DOMException, ComponentNotReadyException { // create and process document return parseDocument(xmlDocument); }
Example #18
Source File: TEFunctionCall.java From teamengine with Apache License 2.0 | 4 votes |
protected void checkArguments(ExpressionVisitor visitor) throws XPathException { // Assume arguments are OK }
Example #19
Source File: TEJavaFunctionCall.java From teamengine with Apache License 2.0 | 4 votes |
public TEJavaFunctionCall(FunctionEntry fe, StructuredQName functionName, Expression[] staticArgs, StaticContext env) throws XPathException { super(functionName, staticArgs, env); this.fe = fe; }
Example #20
Source File: StrictRelativeResolvingStrategy.java From validator with Apache License 2.0 | 4 votes |
@Override public ResourceCollection findCollection(final XPathContext context, final String collectionURI) throws XPathException { throw new IllegalStateException(MESSAGE); }
Example #21
Source File: XPathContext.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 3 votes |
/** * Creates new xpath context. * * @param xpath is xpath expression that defines context * @throws JetelException * @throws XPathException */ public XPathContext(XPathExpression exp, String xpath) throws TransformerException, XPathException { this.xpath = xpath; this.exp = exp; xpathsList = new LinkedList<XPathElement>(); xpathContextList = new LinkedList<XPathContext>(); }
Example #22
Source File: XPathElement.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 2 votes |
/** * Constructor for xpath expression. * * @param xpathExpression * @param cloverField * @throws XPathException */ public XPathElement(XPathExpression xpathExpression, String cloverField) throws XPathException { this.xpathExpression = xpathExpression; this.cloverField = cloverField; }
Example #23
Source File: XPathElementOfXSDType.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 2 votes |
/** * Constructor for xpath expression. * * @param xpathExpression * @param cloverField * @throws XPathException */ public XPathElementOfXSDType(XPathExpression xpathExpression, String cloverField) throws XPathException { super(xpathExpression, cloverField); }