@Deprecated public static boolean typeof(final XPathContext context, final String nodeTypeName, final String fullTypeName, final String shortTypeName) { return TypeOfFunction.typeof((Node) ((ElementNode) context.getContextItem()).getUnderlyingNode(), nodeTypeName, fullTypeName, shortTypeName); }
@Override public Receiver resolve( XPathContext context, String href, String baseUri, SerializationProperties properties) throws XPathException { StreamResult result = resolve(href, baseUri); SerializerFactory factory = context.getConfiguration().getSerializerFactory(); PipelineConfiguration pipe = context.getController().makePipelineConfiguration(); return factory.getReceiver(result, properties, pipe); }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
/** * Get the configuration, given the context. This is provided as a static method to make it accessible * as an extension function. * * @param context the XPath dynamic context * @return the Saxon Configuration for a given XPath dynamic context */ public static Configuration getConfiguration(XPathContext context) { return context.getConfiguration(); }
public GroupEndingIterator(SequenceIterator population, Pattern endPattern, XPathContext context) throws XPathException { this.population = population; this.endPattern = endPattern; baseContext = context; runningContext = context.newMinorContext(); runningContext.setCurrentIterator(population); // the first item in the population always starts a new group next = population.next(); }
public SequenceIterator getAnother() throws XPathException { SequenceIterator newBase = base.getAnother(); XPathContext c2 = context; if (c2!=null) { c2 = c2.newMinorContext(); c2.setCurrentIterator(newBase); c2.setOrigin(context.getOrigin()); } return new ContextMappingIterator(action, c2); }
/** * Return the Controller object * * @param c the XPath dynamic context * @return the Controller */ public static Controller getController(XPathContext c) { return c.getController(); }
public TailCall processLeavingTail(XPathContext context) throws XPathException { Controller controller = context.getController(); String prefix = evaluatePrefix(context); String uri = expandChildren(context).toString(); checkPrefixAndUri(prefix, uri, context); int nscode = controller.getNamePool().allocateNamespaceCode(prefix, uri); SequenceReceiver out = context.getReceiver(); out.namespace(nscode, ReceiverOptions.REJECT_DUPLICATES); return null; }
/** * Construct a ContextMappingIterator that will apply a specified ContextMappingFunction to * each Item returned by the base iterator. * @param action the mapping function to be applied * @param context the processing context. The mapping function is applied to each item returned * by context.getCurrentIterator() in turn. */ public ContextMappingIterator(ContextMappingFunction action, XPathContext context) { base = context.getCurrentIterator(); this.action = action; this.context = context; }
public MergeKeyMappingFunction(XPathContext baseContext, MergeSource ms) { this.baseContext = baseContext; this.ms = ms; keyContext = baseContext.newMinorContext(); keyContext.setTemporaryOutputState(StandardNames.XSL_MERGE_KEY); manualIterator = new ManualIterator<>(); manualIterator.setPosition(1); keyContext.setCurrentIterator(manualIterator); } public SequenceIterator<ExternalObject<ItemWithMergeKeys>> map(XPathContext context)
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. * @throws XPathException if the current receiver fails for any reason, for example * with a serialization error due to invalid characters in the content */ public void process(/*@NotNull*/ XPathContext context) throws XPathException { context.getReceiver().append(this, ExplicitLocation.UNKNOWN_LOCATION, ReceiverOptions.ALL_NAMESPACES); }
/** * Get the current group iterator. This supports the current-group() and * current-grouping-key() functions in XSLT 2.0 * * @return the current grouped collection */ public GroupIterator getCurrentGroupIterator() { return getCaller().getCurrentGroupIterator(); }
/** * Evaluate this function parameter * * @param context the XPath dynamic context * @return the value of the parameter */ public Sequence<?> evaluateVariable(XPathContext context) { return context.evaluateLocalVariable(slotNumber); }
/** * Get the value of the range variable */ public Sequence<?> evaluateVariable(XPathContext context) throws XPathException { Sequence<?> actual = context.evaluateLocalVariable(slotNumber); if (!(actual instanceof GroundedValue || actual instanceof NodeInfo)) { actual = actual.materialize(); context.setLocalVariable(slotNumber, actual); } return actual; }
public static void renderStart(XPathContext saxonContext, RenderContextSaxon2 renderContext) throws Exception { try { if(renderContext.getResult() != null) { saxonContext.changeOutputDestination(saxonContext.getReceiver(), new ParseOptions()); } } catch(Exception x) { ExtensionFunctionUtils.setExtensionFunctionError(x); throw x; } }
/** * Iterate over the results of the function */ public SequenceIterator iterate(XPathContext c) throws XPathException { PreparedExpression pexpr = prepareExpression(c); if (operation == EXPRESSION) { return SingletonIterator.makeIterator(new ObjectValue(pexpr)); } else { XPathContextMajor c2 = c.newCleanContext(); c2.setOrigin(details); c2.openStackFrame(pexpr.stackFrameMap); c2.setCurrentIterator(c.getCurrentIterator()); for (int i=1; i<argument.length; i++) { int slot = pexpr.variables[i-1].getLocalSlotNumber(); c2.setLocalVariable(slot, ExpressionTool.eagerEvaluate(argument[i],c)); } return Value.getIterator( ExpressionTool.lazyEvaluate(pexpr.expression, c2, 1)); } }
public int evaluateNameCode(XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); return context.getNamePool().allocate("", "", prefix); }
private void checkNotTemporaryOutputState(XPathContext context) throws XPathException { if (context.getTemporaryOutputState() != 0) { XPathException err = new XPathException("Cannot execute xsl:result-document while evaluating xsl:" + context.getNamePool().getLocalName(context.getTemporaryOutputState())); err.setErrorCode("XTDE1480"); err.setLocation(getLocation()); throw err; } }
public NodeInfo convert(Object object, XPathContext context) throws XPathException { ParseOptions options = new ParseOptions(); Controller controller = context.getController(); if (controller != null) { options.setSchemaValidationMode(controller.getSchemaValidationMode()); } return context.getConfiguration().buildDocumentTree((Source) object, options).getRootNode(); }