Package nu.xom.xslt

Examples of nu.xom.xslt.XSLTransform


      throws IOException, ParsingException, XSLException {
       
        File stylesheet = new File(inputDir, "identity.xsl");
        Builder builder = new Builder();
        Document stylesheetDoc = builder.build(stylesheet);
        XSLTransform xform = new XSLTransform(stylesheetDoc,
          new NodeFactory() {
            public Nodes makeComment(String text) {
                return new Nodes(new Attribute("comment", text));  
            }
        });

        String data = "<a><!--test--></a>";
        Document doc = builder.build(data, "http://www.example.org/");
       
        Nodes result = xform.transform(doc);
       
        assertEquals(1, result.size());
        Element a = (Element) result.get(0);
        assertEquals("a", a.getLocalName());
        assertEquals(0, a.getChildCount());
View Full Code Here


      throws IOException, ParsingException, XSLException
       
        File stylesheet = new File(inputDir, "identity.xsl");
        Builder builder = new Builder();
        Document stylesheetDoc = builder.build(stylesheet);
        XSLTransform xform = new XSLTransform(stylesheetDoc);

        String data = "<pre:a xmlns:pre='http://www.example.org' " +
                "xmlns='http://www.example.net'>data</pre:a>";
        Document doc = builder.build(data, "http://www.example.org/");
       
        Nodes result = xform.transform(doc);
       
        assertEquals(1, result.size());
        Element a = (Element) result.get(0);
        assertEquals("a", a.getLocalName());
        assertEquals("pre:a", a.getQualifiedName());
View Full Code Here

                    try {
                        Document inputDoc = builder.build(input);
                        Document styleDoc = builder.build(style);
                        // If the transform specifies indent="yes".
                        // we remove all white space before comparing
                        XSLTransform xform;
                        if (indentYes(styleDoc)) {
                            xform = new XSLTransform(styleDoc, stripper);
                        }
                        else xform = new XSLTransform(styleDoc);
                        Nodes result = xform.transform(inputDoc);
                        if (output == null) {
                            // transform should have failed
                            fail("Transformed " + id);
                        }
                        else {
View Full Code Here

                        // xsl:output at same import precedence, though
                        // 2.6.0 does
                        continue;
                    }
                    Document inputDoc = builder.build(input);
                    XSLTransform xform;
                    if (strip) xform = new XSLTransform(styleDoc, stripper);
                    else xform = new XSLTransform(styleDoc);
                    Nodes result = xform.transform(inputDoc);
                    if (output == null) {
                        if ("Attributes__89463".equals(id)
                          || "Attributes__89465".equals(id)) {
                            // Processors are allowed to recover from
                            // this problem.
View Full Code Here

        File style = new File(base, "MSFT_CONFORMANCE_TESTS/KEYS/input.xsl");
        File output = new File(base, "MSFT_CONFORMANCE_TESTS/KEYS/out/PerfRepro3.txt");;
        Document styleDoc = builder.build(style);
        Document inputDoc = builder.build(input);
        XSLTransform xform = new XSLTransform(styleDoc);
        Nodes result = xform.transform(inputDoc);
        Document expectedResult = builder.build(output);
        Document actualResult = XSLTransform.toDocument(result);
        assertEquals(expectedResult, actualResult);
    
    }
View Full Code Here

        File style = new File(base, "MSFT_CONFORMANCE_TESTS/Sorting/2_5_13_repeat.xsl");
        File output = new File(base, "MSFT_CONFORMANCE_TESTS/Sorting/out/89749.txt");;
        Document styleDoc = builder.build(style);
        Document inputDoc = builder.build(input);
        XSLTransform xform = new XSLTransform(styleDoc);
        Nodes result = xform.transform(inputDoc);
        /*Document expectedResult = builder.build(output);
        Document actualResult = XSLTransform.toDocument(result);
        assertEquals(expectedResult, actualResult); */
    
    }
View Full Code Here

   * @throws XSLException if there are XSL problems transforming with stylesheets
   * @throws IOException if there are problems reading or parsing the Schematron file
   */
  public List<ValidationMessage> validateWithSchematron(File schematronFile) throws XSLException, IOException {
    List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
    XSLTransform schematronTransform = Util.buildSchematronTransform(schematronFile);
    Nodes nodes = schematronTransform.transform(new Document(getXOMElementCopy()));
    Document doc = XSLTransform.toDocument(nodes);

    XPathContext context = XPathContext.makeNamespaceContext(doc.getRootElement());
    String svrlNamespace = context.lookup("svrl");
    Nodes outputNodes = doc.query("//svrl:failed-assert | //svrl:successful-report", context);
View Full Code Here

    }
    Document schDocument = Util.buildXmlDocument(new FileInputStream(schematronFile));
    String queryBinding = getSchematronQueryBinding(schDocument);

    // long time = new Date().getTime();
    XSLTransform phase1 = getSchematronIncludeTransform();
    // System.out.println((new Date().getTime() - time) + "ms (Include)");

    // time = new Date().getTime();
    XSLTransform phase2 = getSchematronAbstractTransform();
    // System.out.println((new Date().getTime() - time) + "ms (Abstract)");

    // time = new Date().getTime();
    XSLTransform phase3 = getSchematronSvrlTransform(queryBinding);
    // System.out.println((new Date().getTime() - time) + "ms (SVRL)");

    // time = new Date().getTime();
    Nodes nodes = phase3.transform(phase2.transform(phase1.transform(schDocument)));
    // System.out.println((new Date().getTime() - time) + "ms (Base transformation 1, 2, 3)");

    // time = new Date().getTime();
    XSLTransform finalTransform = new XSLTransform(XSLTransform.toDocument(nodes));
    // System.out.println((new Date().getTime() - time) + "ms (Schematron Validation)");

    return (finalTransform);
  }
View Full Code Here

   * @return the phase one transform
   */
  private synchronized static XSLTransform getSchematronIncludeTransform() throws IOException, XSLException {
    if (_schematronIncludeTransform == null) {
      InputStream includeStylesheet = getLoader().getResourceAsStream("schematron/iso_dsdl_include.xsl");
      _schematronIncludeTransform = new XSLTransform(Util.buildXmlDocument(includeStylesheet));
    }
    return (_schematronIncludeTransform);
  }
View Full Code Here

   * @return the phase two transform
   */
  private synchronized static XSLTransform getSchematronAbstractTransform() throws IOException, XSLException {
    if (_schematronAbstractTransform == null) {
      InputStream abstractStylesheet = getLoader().getResourceAsStream("schematron/iso_abstract_expand.xsl");
      _schematronAbstractTransform = new XSLTransform(Util.buildXmlDocument(abstractStylesheet));
    }
    return (_schematronAbstractTransform);
  }
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.