Package net.sf.saxon.s9api

Examples of net.sf.saxon.s9api.Processor


        ValidBaseURITest test = new ValidBaseURITest();
        test.run();
    }

    public void run() throws SaxonApiException {
        Processor processor = new Processor(true);
        SchemaManager manager = processor.getSchemaManager();

        // No resolver here, there isn't one.
        DocumentBuilder builder = processor.newDocumentBuilder();
        SAXSource source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/compoundEntity.xml"));
        XdmNode document = builder.build(source);

        source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/document.xsd"));
        XdmNode schema = builder.build(source);
        manager.load(schema.asSource());

        XdmDestination destination = new XdmDestination();
        Controller controller = new Controller(processor.getUnderlyingConfiguration());
        Receiver receiver = destination.getReceiver(controller.getConfiguration());
        PipelineConfiguration pipe = controller.makePipelineConfiguration();
        pipe.setRecoverFromValidationErrors(false);
        receiver.setPipelineConfiguration(pipe);
View Full Code Here


                                        if (cs == null) {
                                            cs = Charset.defaultCharset().name();
                                        }
                                        InputStreamReader reader = new InputStreamReader(content, cs);
                                        JSONTokener jt = new JSONTokener(reader);
                                        Processor processor = runtime.getProcessor();
                                        String flavor = runtime.jsonFlavor();
                                        documents.add(JSONtoXML.convert(processor, jt, flavor));
                                    }
                                });
                                return;
View Full Code Here

    }

    public void run() throws SaxonApiException {
        super.run();

        Processor proc = runtime.getProcessor();
        SchemaManager manager = proc.getSchemaManager();

        if (manager == null) {
            validateWithXerces();
        } else {
            validateWithSaxonSA(manager);
View Full Code Here

                    default:
                        throw new UnsupportedOperationException(format("Unsupported saxonConfig kind '%s'", saxoncfg.getKind()));
                }

                SAXSource source = new SAXSource(new InputSource(instream));
                cfgProcessor = new Processor(source);
            } catch (FileNotFoundException e) {
                throw new XProcException(e);
            } catch (SaxonApiException e) {
                throw new XProcException(e);
            }
        } else {
            cfgProcessor = new Processor(licensed);
        }

        String actualtype = Configuration.softwareEdition;
        if ((proctype != null) && !"he".equals(proctype) && (!actualtype.toLowerCase().equals(proctype))) {
            System.err.println("Failed to obtain " + proctype.toUpperCase() + " processor; using " + actualtype + " instead.");
View Full Code Here

    private void importFunctions(XdmNode node) {
        String href = node.getAttributeValue(_href);
        String ns = node.getAttributeValue(_namespace);
        String type = node.getAttributeValue(_type);
        Processor processor = runtime.getProcessor();

        String sed = processor.getUnderlyingConfiguration().getEditionCode();
        if (!"EE".equals(sed)) {
            throw new XProcException("Importing functions is only supported by Saxon EE.");
        }

        try {
            URL url = runtime.getStaticBaseURI().resolve(href).toURL();
            URLConnection connection = url.openConnection();
            FunctionLibrary fl = null;

            if (type.contains("xsl")) {
                SAXSource stylesheet = new SAXSource(new InputSource(connection.getInputStream()));
                XsltCompiler compiler = processor.newXsltCompiler();
                XsltExecutable exec = compiler.compile(stylesheet);
                PreparedStylesheet ps = exec.getUnderlyingCompiledStylesheet();
                fl = ps.getFunctionLibrary();
            } else {
                XQueryCompiler xqcomp = processor.newXQueryCompiler();
                StaticQueryContext sqc = xqcomp.getUnderlyingStaticContext();
                sqc.compileLibrary(connection.getInputStream(), "utf-8");
                XQueryExpression xqe = sqc.compileQuery("import module namespace f='" + ns + "'; .");
                QueryModule qm = xqe.getStaticContext();
                fl = qm.getGlobalFunctionLibrary();
            }

            // We think this will work because we know from the test above that we're not in Saxon HE.
            // It's a bit fragile, but I can't think of a better way.
            Class<?> pc = Class.forName("com.saxonica.config.ProfessionalConfiguration");
            Class<?> fc = Class.forName("net.sf.saxon.functions.FunctionLibrary");
            Method setBinder = pc.getMethod("setExtensionBinder", String.class, fc);
            setBinder.invoke(processor.getUnderlyingConfiguration(), "xmlcalabash" + importCount, fl);
            importCount++;
        } catch (Exception e) {
            throw new XProcException(e);
        }
    }
View Full Code Here

                        queryexpr = "//text()";
                        serializer.setOutputProperty(Serializer.Property.METHOD, "text");
                        serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
                    }

                    Processor qtproc = runtime.getProcessor();
                    XQueryCompiler xqcomp = qtproc.newXQueryCompiler();
                    xqcomp.setModuleURIResolver(runtime.getResolver());
                    XQueryExecutable xqexec = xqcomp.compile(queryexpr);
                    XQueryEvaluator xqeval = xqexec.load();
                    xqeval.setContextItem(srcDoc);
View Full Code Here

*/
public class HTMLRender {
   
    public void init() throws SaxonApiException{
       
        proc = new Processor(false);
        XsltCompiler comp = proc.newXsltCompiler();
        File file = new File("../app/xsl/highlight-file.xsl");
        if (!file.exists()){
            file = new File("xslt/highlight-file.xsl");
        }
View Full Code Here

  public SaxonCommand(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
    super(builder, config, parent, child, context);
   
    this.isTracing = getConfigs().getBoolean(config, "isTracing", false);
    boolean isLicensedSaxonEdition = getConfigs().getBoolean(config, "isLicensedSaxonEdition", false);
    this.processor = new Processor(isLicensedSaxonEdition);
    this.documentBuilder = processor.newDocumentBuilder();
   
    Config features = getConfigs().getConfig(config, "features", ConfigFactory.empty());
    for (Map.Entry<String, Object> entry : new Configs().getEntrySet(features)) {
      processor.setConfigurationProperty(entry.getKey(), entry.getValue());
View Full Code Here

  public SaxonCommand(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
    super(builder, config, parent, child, context);
   
    this.isTracing = getConfigs().getBoolean(config, "isTracing", false);
    boolean isLicensedSaxonEdition = getConfigs().getBoolean(config, "isLicensedSaxonEdition", false);
    this.processor = new Processor(isLicensedSaxonEdition);
    this.documentBuilder = processor.newDocumentBuilder();
   
    Config features = getConfigs().getConfig(config, "features", ConfigFactory.empty());
    for (Map.Entry<String, Object> entry : new Configs().getEntrySet(features)) {
      processor.setConfigurationProperty(entry.getKey(), entry.getValue());
View Full Code Here

    Set<Object> roots = new HashSet<Object>();
    for (TreePath path : selection.getPaths()) {
      roots.add(path.getFirstSegment());
    }
    Processor proc = new Processor(false);
    ItemTypeFactory fact = new ItemTypeFactory(proc);
    GetAstNodeFunction func = new GetAstNodeFunction(fact);
    proc.registerExtensionFunction(func);
    proc.registerExtensionFunction(new AstTextExtensionFunction(fact));
    AnalysisPluginsManager.initialiseExtensions();
    ExtensionFunctions extFuncs = new ExtensionFunctions(fact, proc);
   
//    XPathCompiler xpath = proc.newXPathCompiler();
//    xpath.declareNamespace("cs", FunctionUtils.NAMESPACE);
    DocumentBuilder builder = proc.newDocumentBuilder();
    builder.setLineNumbering(true);
    builder.setWhitespaceStrippingPolicy(WhitespaceStrippingPolicy.ALL);

    //show progress dialog
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
View Full Code Here

TOP

Related Classes of net.sf.saxon.s9api.Processor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.