Package nu.xom.xslt

Examples of nu.xom.xslt.XSLTransform


        // XOM passes the Base URI to Xalan as the SystemId, which cannot be empty.
        URI svrlUri = getLoader().getResource(resourceName).toURI();
        svrlStylesheet.setBaseURI(svrlUri.toString());

        _schematronSvrlTransforms.put(resourceName, new XSLTransform(svrlStylesheet));
      }
      catch (URISyntaxException e) {
        throw new IOException(e.getMessage());
      }
    }
View Full Code Here


   * @return The results of the XSL transform.
   */
  public static Document runXSLOnInline(Document inline, String sheetName) {
    try {
      Document xslDoc = new ResourceGetter("uk/ac/cam/ch/wwmm/oscar3/misc/resources/").getXMLDocument(sheetName);
      XSLTransform xslt = new XSLTransform(xslDoc);
      Nodes n = xslt.transform(inline);
      return XSLTransform.toDocument(n);
    } catch (Exception e) {
      e.printStackTrace();
      return inline;
    }
View Full Code Here

 
  private OnAnnotated() {
    try {
      ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/ptc/experimental/resources/");
      Document xsltDoc = rg.getXMLDocument("toSciXML.xsl");
      xslt = new XSLTransform(xsltDoc);     
    } catch (Exception e) {
      throw new Error(e);
    }
  }
View Full Code Here

    return getInstance().subTypes.get(type);
  }
 
  private Document getSciXMLDocInternal() {
    try {
      XSLTransform xslt = new XSLTransform(rg.getXMLDocument("typesToSciXML.xsl"));
      return XSLTransform.toDocument(xslt.transform(typeDoc));
    } catch (Exception e) {
      e.printStackTrace();
      throw new Error("Couldn't make NETypes SciXML");     
    }
  }
View Full Code Here

    }
    System.out.println(nodeNames);
   
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/ptc/experimental/resources/");
   
    XSLTransform xslt = new XSLTransform(rg.getXMLDocument("patents2.xsl"));
   
    Nodes paperNodes = doc.query("/PAPERS/PAPER");
   
    File outFolder = new File("/home/ptc24/newows/corpora/NewSciXMLPatents2");
    if(!outFolder.exists()) outFolder.mkdir();
   
    for(int i=0;i<paperNodes.size();i++) {     
      Node node = paperNodes.get(i);
      node.detach();
      assert(node instanceof Element);
      Element e = (Element)node;
      Document newDoc = new Document(e);
      Document sciXML = XSLTransform.toDocument(xslt.transform(newDoc));
     
      String title = sciXML.query("/PAPER/CURRENT_TITLE").get(0).getValue().trim();
      assert(title.length() > 0);
      title = title.replaceAll(" ", "_");
      System.out.println(title);
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    XSLTransform xslt = new XSLTransform(rg.getXMLDocument("relations.xsl"));
   
    String inchiStr = ChemNameDictSingleton.getInChIForShortestSmiles("morphine");
    String ontID = "CHEBI:23888";
    File dir = new File("/home/ptc24/newows/corpora/BioIE");
    List<File> sourceFiles = FileTools.getFilesFromDirectoryByName(dir, "source.xml");
View Full Code Here

    Document xsltDoc = new Builder().build(new File("/local/scratch/ptc24/base_corpus/rsc/rsc_art2paper_rng.xsl"));
    //Document xsltDoc = new Builder().build(new File("/local/scratch/ptc24/base_corpus/nature/npg_art2paper_rng.xsl"));
    //Document xsltDoc = new Builder().build(new File("/local/scratch/ptc24/tmp_corpus/iuc/iucr_art2paper_rng.xsl"));
    //Document xsltDoc = new Builder().build(new File("/local/scratch/ptc24/base_corpus/iuc/iucr_art2paper_rng.xsl"));
    //Document xsltDoc = new Builder().build(new File("/home/ptc24/iucr_art2paper_rng.xsl"));
    XSLTransform xslt = new XSLTransform(xsltDoc);
   
    //List<File> files = FileTools.getFilesFromDirectoryBySuffix(new File("/usr/groups/sciborg/texts/iuc"), ".xml");
    List<File> files = FileTools.getFilesFromDirectoryBySuffix(new File("/usr/groups/sciborg/texts/rsc/paperset1"), ".xml");
    //List<File> files = FileTools.getFilesFromDirectoryBySuffix(new File("/usr/groups/sciborg/texts/nature/nature_2"), ".xml");
    //List<File> files = FileTools.getFilesFromDirectoryBySuffix(new File("/local/scratch/ptc24/rscorig"), ".xml");
    //files=files.subList(13,14);
    System.out.println(files);
    int i=0;
    for(File paper : files) {

      System.out.println(paper.getName());
      System.out.println(i++);
      try {
      Document xml1;
      Document xml2;
      XMLAlignment xa;
      if(true) {
        xml1 = new Builder().build(paper);
     
        PubXMLToSciXML.addNodeIds(xml1.getRootElement(), xml1.getRootElement());
     
        Nodes n = xslt.transform(xml1);
        xml2 = XSLTransform.toDocument(n);
        xa = new XMLAlignment(xml2, xml1, true);
        xa.testXML1ForOscar();
        //new Serializer(System.out).write(xml1);
        //new Serializer(System.out).write(xml2);
View Full Code Here

  private XSLTransform xslt;
  private File papersDir;
 
  public GENIACorpusNodeFactory(File papersDir) throws Exception {
    super();
    xslt = new XSLTransform(rg.getXMLDocument("GENIAToSciXML.xsl"));
    this.papersDir = papersDir;
    if(!papersDir.exists()) papersDir.mkdir();
  }
View Full Code Here

          //System.out.println("mode2doc: " + mode2doc.toString()); 
          System.out.println("rg: " + rg.toString());
         
             Document stylesheet = rg.getXMLDocument("xsl/clearMode2.xsl");
             System.out.println("Found clearMode2.xsl");
             XSLTransform transform = new XSLTransform(stylesheet);
             Document clearDoc = XSLTransform.toDocument(transform.transform(mode2doc));
             ARTSciXMLDocument clearedDoc = ARTSciXMLDocument.makeFromDoc(clearDoc);
             ap.writeMode2Doc(clearedDoc);
             response.setContentType("text/plain");
             response.getWriter().print(name);
             /*mode2doc = ap.getMode2Doc();
View Full Code Here

      fos.close();
    }     
  }
 
  private static Map<String, SciXMLDocument> getSciXML(Document pubmedResults) throws Exception {
    XSLTransform xslt = new XSLTransform(new ResourceGetter("uk/ac/cam/ch/wwmm/ptclib/scixml/resources/").getXMLDocument("pubmed2scixml.xsl"));
    Map<String, SciXMLDocument> docs = new LinkedHashMap<String, SciXMLDocument>();
    Nodes n = pubmedResults.query("/PubmedArticleSet/PubmedArticle");
    for(int i=0;i<n.size();i++) {
      try {
        if(n.get(i).query(".//ArticleTitle").size() == 0) continue;
        if(n.get(i).query(".//AbstractText").size() == 0) continue;
        if(n.get(i).query(".//PMID").size() == 0) continue;
        String id = n.get(i).query(".//PMID").get(0).getValue();
        Element elem = (Element)n.get(i);
        elem.detach();
        Document d = new Document(elem);
        Document out = XSLTransform.toDocument(xslt.transform(d));
        docs.put(id, SciXMLDocument.makeFromDoc(out));
      } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Hmm, couldn't parse that abstract.");
      }
View Full Code Here

TOP

Related Classes of nu.xom.xslt.XSLTransform

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.