/** * Get the relevant platform * @return the platform */ protected Platform getPlatform() { return Configuration.getPlatform(); }
/** * Get the relevant platform * @return the platform */ protected Platform getPlatform() { return Configuration.getPlatform(); }
/** * Declare a URI that maps to a Java class containing extension functions * @param uri the namespace uri used in the function names * @param theClass the Java class containing methods accessible using this URI */ protected void declareJavaClass(String uri, Class theClass) { Configuration.getPlatform().declareJavaClass(javaFunctions, uri, theClass); }
/** * Declare a URI that maps to a Java class containing extension functions * @param uri the namespace uri used in the function names * @param theClass the Java class containing methods accessible using this URI */ protected void declareJavaClass(String uri, Class theClass) { Configuration.getPlatform().declareJavaClass(javaFunctions, uri, theClass); }
/** * Declare a URI that maps to a Java class containing extension functions * @param uri the namespace uri used in the function names * @param theClass the Java class containing methods accessible using this URI */ protected void declareJavaClass(String uri, Class theClass) { Configuration.getPlatform().declareJavaClass(javaFunctions, uri, theClass); }
protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException { Source sourceInput; if (useURLs || sourceFileName.startsWith("http:") || sourceFileName.startsWith("file:")) { sourceInput = config.getURIResolver().resolve(sourceFileName, null); if (sourceInput == null) { sourceInput = config.getSystemURIResolver().resolve(sourceFileName, null); } } else if (sourceFileName.equals("-")) { // take input from stdin sourceInput = new StreamSource(System.in); } else { File sourceFile = new File(sourceFileName); if (!sourceFile.exists()) { quit("Source file " + sourceFile + " does not exist", 2); } if (Configuration.getPlatform().isJava()) { InputSource eis = new InputSource(sourceFile.toURI().toString()); sourceInput = new SAXSource(eis); } else { sourceInput = new StreamSource(sourceFile.toURI().toString()); } } return sourceInput; }
protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException { Source sourceInput; if (useURLs || sourceFileName.startsWith("http:") || sourceFileName.startsWith("file:")) { sourceInput = config.getURIResolver().resolve(sourceFileName, null); if (sourceInput == null) { sourceInput = config.getSystemURIResolver().resolve(sourceFileName, null); } } else if (sourceFileName.equals("-")) { // take input from stdin sourceInput = new StreamSource(System.in); } else { File sourceFile = new File(sourceFileName); if (!sourceFile.exists()) { quit("Source file " + sourceFile + " does not exist", 2); } if (Configuration.getPlatform().isJava()) { InputSource eis = new InputSource(sourceFile.toURI().toString()); sourceInput = new SAXSource(eis); } else { sourceInput = new StreamSource(sourceFile.toURI().toString()); } } return sourceInput; }
/** * Evaluate an updating expression, adding the results to a Pending Update List. * The default implementation of this method, which is used for non-updating expressions, * throws an UnsupportedOperationException * @param context the XPath dynamic evaluation context * @param pul the pending update list to which the results should be written */ public void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException { NodeInfo node = (NodeInfo)argument[0].evaluateItem(context); int kind = node.getNodeKind(); if (kind != Type.ELEMENT && kind != Type.DOCUMENT) { dynamicError("Node in put() must be a document or element node", "FOUP0001", context); } String relative = argument[1].evaluateItem(context).getStringValue(); Platform platform = Configuration.getPlatform(); String abs; try { URI resolved = platform.makeAbsolute(relative, expressionBaseURI); abs = resolved.toString(); } catch (URISyntaxException err) { dynamicError("Base URI " + Err.wrap(expressionBaseURI) + " is invalid: " + err.getMessage(), "FOUP0002", context); abs = null; } pul.addPutAction(node, abs); } }
/** * Get a comparison key for an object. This must satisfy the rule that if two objects are equal, * then their comparison keys are equal, and vice versa. There is no requirement that the * comparison keys should reflect the ordering of the underlying objects. */ public ComparisonKey getComparisonKey(AtomicValue a) { if (a instanceof StringValue) { Platform platform = Configuration.getPlatform(); if (platform.canReturnCollationKeys(collator)) { return new ComparisonKey(StandardNames.XS_STRING, collator.getCollationKey(a.getStringValue())); } else { return new ComparisonKey(StandardNames.XS_STRING, a.getStringValue()); } } else { return new ComparisonKey(StandardNames.XS_STRING, a); } }
/** * Get a comparison key for an object. This must satisfy the rule that if two objects are equal, * then their comparison keys are equal, and vice versa. There is no requirement that the * comparison keys should reflect the ordering of the underlying objects. */ public ComparisonKey getComparisonKey(AtomicValue a) { if (a instanceof StringValue) { Platform platform = Configuration.getPlatform(); if (platform.canReturnCollationKeys(collator)) { return new ComparisonKey(StandardNames.XS_STRING, collator.getCollationKey(a.getStringValue())); } else { return new ComparisonKey(StandardNames.XS_STRING, a.getStringValue()); } } else { return new ComparisonKey(StandardNames.XS_STRING, a); } }
/** * Get an iterator over the substrings defined by the regular expression * * @param context the evaluation context * @return an iterator that returns matching and nonmatching substrings * @throws XPathException */ private RegexIterator getRegexIterator(XPathContext context) throws XPathException { CharSequence input = select.evaluateAsString(context); RegularExpression re = pattern; if (re == null) { CharSequence flagstr = flags.evaluateAsString(context); final Platform platform = Configuration.getPlatform(); final int xmlVersion = context.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( regex.evaluateAsString(context), xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr); if (re.matches("")) { dynamicError("The regular expression must not be one that matches a zero-length string", "XTDE1150", context); } } return re.analyze(input); }
/** * Get an iterator over the substrings defined by the regular expression * * @param context the evaluation context * @return an iterator that returns matching and nonmatching substrings * @throws XPathException */ private RegexIterator getRegexIterator(XPathContext context) throws XPathException { CharSequence input = select.evaluateAsString(context); RegularExpression re = pattern; if (re == null) { CharSequence flagstr = flags.evaluateAsString(context); final Platform platform = Configuration.getPlatform(); final int xmlVersion = context.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( regex.evaluateAsString(context), xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr); if (re.matches("")) { dynamicError("The regular expression must not be one that matches a zero-length string", "XTDE1150", context); } } return re.analyze(input); }
/** * Initialize the default function library for XPath. * This can be overridden using setFunctionLibrary(). */ protected final void setDefaultFunctionLibrary() { FunctionLibraryList lib = new FunctionLibraryList(); lib.addFunctionLibrary( SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.XPATH_ONLY)); lib.addFunctionLibrary(getConfiguration().getVendorFunctionLibrary()); lib.addFunctionLibrary(new ConstructorFunctionLibrary(getConfiguration())); //lib.addFunctionLibrary(new JavaExtensionLibrary(getConfiguration())); if (config.isAllowExternalFunctions()) { Configuration.getPlatform().addFunctionLibraries(lib, config); } setFunctionLibrary(lib); }
/** * Create a static context for evaluating use-when expressions * @param config the Saxon configuration * @param namespaceContext the namespace context in which the use-when expression appears */ public UseWhenStaticContext(Configuration config, NamespaceResolver namespaceContext) { setConfiguration(config); this.namespaceContext = namespaceContext; FunctionLibraryList lib = new FunctionLibraryList(); lib.addFunctionLibrary(SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.USE_WHEN)); lib.addFunctionLibrary(getConfiguration().getVendorFunctionLibrary()); lib.addFunctionLibrary(new ConstructorFunctionLibrary(getConfiguration())); if (config.isAllowExternalFunctions()) { Configuration.getPlatform().addFunctionLibraries(lib, config, Configuration.XSLT); } functionLibrary = lib; }
/** * Initialize the default function library for XPath. * This can be overridden using setFunctionLibrary(). */ protected final void setDefaultFunctionLibrary() { FunctionLibraryList lib = new FunctionLibraryList(); lib.addFunctionLibrary( SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.XPATH_ONLY)); lib.addFunctionLibrary(getConfiguration().getVendorFunctionLibrary()); lib.addFunctionLibrary(new ConstructorFunctionLibrary(getConfiguration())); //lib.addFunctionLibrary(new JavaExtensionLibrary(getConfiguration())); if (config.isAllowExternalFunctions()) { Configuration.getPlatform().addFunctionLibraries(lib, config, Configuration.XPATH); } setFunctionLibrary(lib); }
/** * Create a static context for evaluating use-when expressions * @param config the Saxon configuration * @param namespaceContext the namespace context in which the use-when expression appears */ public UseWhenStaticContext(Configuration config, NamespaceResolver namespaceContext) { setConfiguration(config); this.namespaceContext = namespaceContext; FunctionLibraryList lib = new FunctionLibraryList(); lib.addFunctionLibrary(SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.USE_WHEN)); lib.addFunctionLibrary(getConfiguration().getVendorFunctionLibrary()); lib.addFunctionLibrary(new ConstructorFunctionLibrary(getConfiguration())); if (config.isAllowExternalFunctions()) { Configuration.getPlatform().addFunctionLibraries(lib, config); } functionLibrary = lib; }
/** * Reset function libraries */ private void resetFunctionLibraries() { Configuration config = getConfiguration(); if (isTopLevelModule()) { globalFunctionLibrary = new XQueryFunctionLibrary(config); } functionLibraryList = new FunctionLibraryList(); functionLibraryList.addFunctionLibrary( SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.XPATH_ONLY)); functionLibraryList.addFunctionLibrary(config.getVendorFunctionLibrary()); functionLibraryList.addFunctionLibrary(new ConstructorFunctionLibrary(config)); localFunctionLibraryNr = functionLibraryList.addFunctionLibrary( new XQueryFunctionLibrary(config)); importedFunctionLibraryNr = functionLibraryList.addFunctionLibrary( new ImportedFunctionLibrary(this, getTopLevelModule().getGlobalFunctionLibrary())); if (config.isAllowExternalFunctions()) { Configuration.getPlatform().addFunctionLibraries(functionLibraryList, config, Configuration.XQUERY); } unboundFunctionLibraryNr = functionLibraryList.addFunctionLibrary( new UnboundFunctionLibrary()); }
/** * Reset function libraries */ private void resetFunctionLibraries() { Configuration config = getConfiguration(); if (isTopLevelModule()) { globalFunctionLibrary = new XQueryFunctionLibrary(config); } functionLibraryList = new FunctionLibraryList(); functionLibraryList.addFunctionLibrary( SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.XPATH_ONLY)); functionLibraryList.addFunctionLibrary(config.getVendorFunctionLibrary()); functionLibraryList.addFunctionLibrary(new ConstructorFunctionLibrary(config)); if (config.isAllowExternalFunctions()) { Configuration.getPlatform().addFunctionLibraries(functionLibraryList, config); } localFunctionLibraryNr = functionLibraryList.addFunctionLibrary( new XQueryFunctionLibrary(config)); importedFunctionLibraryNr = functionLibraryList.addFunctionLibrary( new ImportedFunctionLibrary(this, getTopLevelModule(this).getGlobalFunctionLibrary())); unboundFunctionLibraryNr = functionLibraryList.addFunctionLibrary( new UnboundFunctionLibrary()); }
/** * Create link to the owning PreparedStylesheet object * @param sheet the PreparedStylesheet */ public void setPreparedStylesheet(PreparedStylesheet sheet) { Configuration config = sheet.getConfiguration(); stylesheet = sheet; //targetNamePool = sheet.getTargetNamePool(); exec = new Executable(config); exec.setConfiguration(config); exec.setRuleManager(new RuleManager()); exec.setLocationMap(locationMap); exec.setHostLanguage(Configuration.XSLT); functionLibrary = new FunctionLibraryList(); functionLibrary.addFunctionLibrary( SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.FULL_XSLT)); functionLibrary.addFunctionLibrary(new StylesheetFunctionLibrary(this, true)); functionLibrary.addFunctionLibrary(config.getVendorFunctionLibrary()); functionLibrary.addFunctionLibrary(new ConstructorFunctionLibrary(config)); queryFunctions = new XQueryFunctionLibrary(config); functionLibrary.addFunctionLibrary(queryFunctions); if (config.isAllowExternalFunctions()) { javaFunctions = config.getExtensionBinder("java"); Configuration.getPlatform().addFunctionLibraries(functionLibrary, config); } functionLibrary.addFunctionLibrary(new StylesheetFunctionLibrary(this, false)); }
/** * Create link to the owning PreparedStylesheet object * @param sheet the PreparedStylesheet */ public void setPreparedStylesheet(PreparedStylesheet sheet) { Configuration config = sheet.getConfiguration(); stylesheet = sheet; //targetNamePool = sheet.getTargetNamePool(); exec = new Executable(config); exec.setConfiguration(config); exec.setRuleManager(new RuleManager()); exec.setLocationMap(locationMap); exec.setHostLanguage(Configuration.XSLT); functionLibrary = new FunctionLibraryList(); functionLibrary.addFunctionLibrary( SystemFunctionLibrary.getSystemFunctionLibrary(SystemFunctionLibrary.FULL_XSLT)); functionLibrary.addFunctionLibrary(new StylesheetFunctionLibrary(this, true)); functionLibrary.addFunctionLibrary(config.getVendorFunctionLibrary()); functionLibrary.addFunctionLibrary(new ConstructorFunctionLibrary(config)); queryFunctions = new XQueryFunctionLibrary(config); functionLibrary.addFunctionLibrary(queryFunctions); if (config.isAllowExternalFunctions()) { javaFunctions = config.getExtensionBinder("java"); Configuration.getPlatform().addFunctionLibraries(functionLibrary, config); } functionLibrary.addFunctionLibrary(new StylesheetFunctionLibrary(this, false)); }