Package net.sf.saxon.s9api

Examples of net.sf.saxon.s9api.Processor


    XProcConfiguration config = new XProcConfiguration();
    config.debug = true;
    this.runtime = new XProcRuntime(config);
    //GenericConfig config = new GenericConfig();
    //this.runtime = new XProcRuntime(config);
    Processor proc = runtime.getProcessor();
    this.builder = proc.newDocumentBuilder();
    XsltCompiler comp = proc.newXsltCompiler();
    XsltExecutable exp = null;
    try {
      //xslStylesheet = getServeletContext().getResourceAsStream("/WEB-INF/proc.xsl");
      exp = comp.compile(new StreamSource(xslSheet));
      //exp = comp.compile(new StreamSource(new File("proc.xsl")));
View Full Code Here


        writer = step;
    }
   
    public void write(XdmNode doc) {
        try {
            Processor qtproc = runtime.getProcessor();
            DocumentBuilder builder = qtproc.newDocumentBuilder();
            builder.setBaseURI(new URI("http://example.com/"));
            XQueryCompiler xqcomp = qtproc.newXQueryCompiler();
            XQueryExecutable xqexec = xqcomp.compile(".");
            XQueryEvaluator xqeval = xqexec.load();
            xqeval.setContextItem(doc);

            serializer = new Serializer();
View Full Code Here

   
    query = XadoopUtil.prepareSaxon(context.getConfiguration(), true, "saxon:map" + context.getJobName());
   
    //System.out.println(context.getJobName());
   
    proc = new Processor(true);
    comp = proc.newXQueryCompiler();
    doc = proc.newDocumentBuilder();
    try {
      exec = comp.compile(query);
    } catch (SaxonApiException e) {
View Full Code Here

    }
    query = XadoopUtil.prepareSaxon(context.getConfiguration(), false, "saxon:reduce" + context.getJobName());
       
    //System.out.println(context.getJobName());
   
    proc = new Processor(true);
    comp = proc.newXQueryCompiler();
    doc = proc.newDocumentBuilder();
    try {
      exec = comp.compile(query);
    } catch (SaxonApiException e) {
View Full Code Here

            } else if (args[i].equals("-onwards")) {
                onwards = true;
            } else if (args[i].equals("-scm")) {
                useSCM = true;
                try {
                    Processor scmProcessor = new Processor(true);
                    SchemaManager sm = scmProcessor.getSchemaManager();
                    sm.importComponents(new StreamSource(new File(SCM_SCHEMA_LOCATION)));
                    scmValidator = sm.newSchemaValidator();
                } catch (SaxonApiException e) {
                    e.printStackTrace();
                    useSCM = false;
View Full Code Here

*/
public class XSLTSaxonStreamStylizer {

  public static void transform(InputStream styleSheetFile,
      InputStream xmlFile, OutputStream outputStream) {
    Processor proc = new Processor(false);
    XsltCompiler comp = proc.newXsltCompiler();
    XsltExecutable exp;
    try {
      exp = comp.compile(new StreamSource(styleSheetFile));
      XdmNode source = proc.newDocumentBuilder().build(
          new StreamSource(xmlFile));
      Serializer out = proc.newSerializer(outputStream);
      out.setOutputProperty(Serializer.Property.METHOD, "xml");
      out.setOutputProperty(Serializer.Property.INDENT, "yes");
      XsltTransformer trans = exp.load();
      trans.setInitialContextNode(source);
      trans.setDestination(out);
View Full Code Here

        }
    }

    public static void writeXdmValue(XProcRuntime runtime, XdmItem node, Destination destination, URI baseURI) throws SaxonApiException {
        try {
            Processor proc = runtime.getProcessor();
            Configuration config = proc.getUnderlyingConfiguration();
            PipelineConfiguration pipeConfig = config.makePipelineConfiguration();

            Receiver out = destination.getReceiver(config);
            out = new NamespaceReducer(out);
            TreeReceiver tree = new TreeReceiver(out);
View Full Code Here

        nodes.add(node);
        serialize(xproc, nodes, serializer);
    }

    public static void serialize(XProcRuntime xproc, Vector<XdmNode> nodes, Serializer serializer) throws SaxonApiException {
        Processor qtproc = xproc.getProcessor();
        XQueryCompiler xqcomp = qtproc.newXQueryCompiler();
        xqcomp.setModuleURIResolver(xproc.getResolver());

        // Patch suggested by oXygen to avoid errors that result from attempting to serialize
        // a schema-valid document with a schema-naive query
        xqcomp.getUnderlyingStaticContext().setSchemaAware(
View Full Code Here

        opt = getOption(_output_base_uri);
        if (opt != null) {
            outputBaseURI = opt.getString();
        }

        Processor processor = runtime.getProcessor();
        Configuration config = processor.getUnderlyingConfiguration();

        runtime.getConfigurer().getSaxonConfigurer().configXSLT(config);

        OutputURIResolver uriResolver = config.getOutputURIResolver();
        CollectionURIResolver collectionResolver = config.getCollectionURIResolver();
        UnparsedTextURIResolver unparsedTextURIResolver = runtime.getResolver();

        config.setOutputURIResolver(new OutputResolver());
        config.setCollectionURIResolver(new CollectionResolver(runtime, defaultCollection, collectionResolver));

        XdmDestination result = null;
        try {
            XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
            compiler.setSchemaAware(processor.isSchemaAware());
            XsltExecutable exec = compiler.compile(stylesheet.asSource());
            XsltTransformer transformer = exec.load();

            for (QName name : params.keySet()) {
                RuntimeValue v = params.get(name);
View Full Code Here

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

    public void run() throws SaxonApiException {
        Processor processor = new Processor(false);
        Configuration config = processor.getUnderlyingConfiguration();

        String textStyle = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'\n"
                + "                version='2.0'>\n"
                + "\n"
                + "<xsl:output method='xml' encoding='utf-8' indent='no'\n"
                + "      omit-xml-declaration='yes'/>\n"
                + "\n"
                + "<xsl:preserve-space elements='*'/>\n"
                + "\n"
                + "<xsl:template match='/'>\n"
                + "  <xsl:apply-templates/>\n"
                + "</xsl:template>\n"
                + "\n"
                + "<xsl:template match='*'>\n"
                + "  <xsl:copy>\n"
                + "    <xsl:copy-of select='@*'/>\n"
                + "    <xsl:apply-templates/>\n"
                + "  </xsl:copy>\n"
                + "</xsl:template>\n"
                + "\n"
                + "<xsl:template match='comment()|processing-instruction()|text()'>\n"
                + "  <xsl:copy/>\n"
                + "</xsl:template>\n"
                + "\n"
                + "</xsl:stylesheet>\n";


        String textXML = "<doc xml:base='foo/'><para xml:base='bar/'/></doc>";

        SAXSource stylesheet = new SAXSource(new InputSource(new StringReader(textStyle)));

        XsltCompiler compiler = processor.newXsltCompiler();
        XsltExecutable exec = compiler.compile(stylesheet);
        XsltTransformer transformer = exec.load();

        //transformer.getUnderlyingController().setBaseOutputURI("http://example.com/");

        // No resolver, there isn't one here.
        DocumentBuilder builder = processor.newDocumentBuilder();
        SAXSource document = new SAXSource(new InputSource(new StringReader(textXML)));
        XdmNode context = builder.build(document);
        transformer.setInitialContextNode(context);
        XdmDestination result = new XdmDestination();
        transformer.setDestination(result);
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.