Package net.sf.saxon.s9api

Examples of net.sf.saxon.s9api.XsltCompiler


    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")));
    } catch (SaxonApiException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
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");
View Full Code Here

        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);
                if (runtime.getAllowGeneralExpressions()) {
View Full Code Here

        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.
View Full Code Here

    }

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

        XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
        XsltExecutable exec = compiler.compile(prettyPrint.asSource());
        XsltTransformer transformer = exec.load();
        transformer.setInitialContextNode(source.read());

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        Serializer serializer = new Serializer();
View Full Code Here

            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();
View Full Code Here

            if (xsl == null) {
                throw new UnsupportedOperationException("Failed to load profile_patch.xsl from JAR file.");
            }

            try {
                XsltCompiler compiler = getProcessor().newXsltCompiler();
                compiler.setSchemaAware(false);
                XsltExecutable exec = compiler.compile(new SAXSource(new InputSource(xsl)));
                XsltTransformer transformer = exec.load();
                transformer.setInitialContextNode(profile);
                XdmDestination result = new XdmDestination();
                transformer.setDestination(result);
                transformer.transform();
View Full Code Here

        }

        if (xsl() != null) {
            XdmDestination result = null;
            try {
                XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
                XsltExecutable exec = compiler.compile(xsl().asSource());
                XsltTransformer transformer = exec.load();
                transformer.setParameter(_format, new XdmAtomicValue(format));
                transformer.setInitialContextNode(doc);
                result = new XdmDestination();
                transformer.setDestination(result);
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");
        }
        exp = comp.compile(new StreamSource(file));
        trans = exp.load();
    }
View Full Code Here

        String fragmentPath = getConfigs().getString(fragment, "fragmentPath");
        if (!fragmentPath.equals("/")) {
          throw new MorphlineCompilationException("Non-root fragment paths are not yet supported", config);
       
       
        XsltCompiler compiler = processor.newXsltCompiler();
        compiler.setErrorListener(new DefaultErrorListener());
        compiler.setCompileWithTracing(isTracing);
        String version = getConfigs().getString(config, "languageVersion", null);
        if (version != null) {
          compiler.setXsltLanguageVersion(version);
        }
       
        XsltExecutable executable = null;
        String query = getConfigs().getString(fragment, "queryString", null);
        if (query != null) {
          executable = compiler.compile(new StreamSource(new StringReader(query)));    
        }
        String queryFile = getConfigs().getString(fragment, "queryFile", null);
        if (queryFile != null) {
          executable = compiler.compile(new StreamSource(new File(queryFile)));    
        }
        if (query == null && queryFile == null) {
          throw new MorphlineCompilationException("Either query or queryFile must be defined", config);
        }
        if (query != null && queryFile != null) {
View Full Code Here

TOP

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

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.