Package nu.xom.canonical

Examples of nu.xom.canonical.Canonicalizer


       
        String expected = "<doc></doc>";

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out, false);
            Nodes subset = doc.query("//.");
            serializer.write(subset);
        }
        finally {
            out.close();
        }
           
View Full Code Here


       
        Document doc = new Document(new Element("root"));

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out, false);
            Nodes subset = doc.query("/");
            serializer.write(subset);
        }
        finally {
            out.close();
        }
           
View Full Code Here

       
        String expected = "<e1 xmlns=\"http://www.ietf.org\" xmlns:w3c=\"http://www.w3.org\"></e1>";

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out, false);
            serializer.write(doc.query(xpath, context));
        }
        finally {
            out.close();
        }
           
View Full Code Here

       
        try {
            String data = "<test xmlns=\"relative\">data</test>";
            Document doc = builder.build(data, "http://www.ex.org/");
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Canonicalizer serializer
              = new Canonicalizer(out, false);
            serializer.write(doc);
            fail("Canonicalized document with relative namespace URI");
        }
        catch (ParsingException success) {
            assertNotNull(success.getMessage());
        }   
View Full Code Here

    // make sure null pointer exception doesn't cause any output
    public void testNullDocument()
      throws IOException {
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
        try {
            canonicalizer.write((Document) null)
            fail("Wrote null document");
        }  
        catch (NullPointerException success) {
            // success  
        }
View Full Code Here

        attribute.setType(Attribute.Type.NMTOKENS);
        Element root = new Element("root");
        root.addAttribute(attribute);
        Document doc = new Document(root);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out);
        canonicalizer.write(doc);
        out.close();
        String result = new String(out.toByteArray(), "UTF8");
        assertEquals("<root name=\"value1 value2\"></root>", result);
       
    }
View Full Code Here

            String resolvedURI = child.getBaseURI();
           
            Document doc = builder.build(resolvedURI);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                Canonicalizer serializer = new Canonicalizer(out);
                serializer.write(doc);
            }
            finally {
                out.close();
            }          
            byte[] actual = out.toByteArray();
View Full Code Here

        elem1.appendChild("content");
        pdu.appendChild(elem1);
       
        String expected = "<n1:elem1 xmlns:n1=\"http://b.example\">content</n1:elem1>";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out,
          Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION_WITH_COMMENTS);
       
        XPathContext context = new XPathContext("n1", "http://b.example");
        Document doc = new Document(pdu);
        canonicalizer.write(doc.query("(//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1]", context))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
View Full Code Here

        Element e1 = new Element("a:a", "urn:a");
        Element e2 = new Element("b");
        e1.appendChild(e2);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer c = new Canonicalizer(out,
        Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION);
        c.write(e1);
        String s = out.toString("UTF8");
        assertEquals("<a:a xmlns:a=\"urn:a\"><b></b></a:a>", s);
       
    }
View Full Code Here

        Element e1 = new Element("a:a", "urn:a");
        Element e2 = new Element("b");
        e1.appendChild(e2);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer c = new Canonicalizer(out);
        c.write(e1);
        String s = out.toString("UTF8");
        assertEquals("<a:a xmlns:a=\"urn:a\"><b></b></a:a>", s);
       
    }
View Full Code Here

TOP

Related Classes of nu.xom.canonical.Canonicalizer

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.