Package nu.xom.canonical

Examples of nu.xom.canonical.Canonicalizer


        Document doc = builder.build(input, null);
       
        String expected = "<n1:elem2 xmlns:n1=\"http://example.net\" xml:lang=\"en\">"
            + "<n3:stuff xmlns:n3=\"ftp://example.org\"></n3:stuff></n1:elem2>";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Canonicalizer canonicalizer = new Canonicalizer(out,
          Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION_WITH_COMMENTS);
       
        XPathContext context = new XPathContext("n1", "http://example.net");
        canonicalizer.write(doc.query(" (//. | //@* | //namespace::*)[ancestor-or-self::n1:elem2]", context))
       
        byte[] result = out.toByteArray();
        out.close();
        String s = new String(out.toByteArray(), "UTF8");
        assertEquals(expected, s);
View Full Code Here


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

    public void testCanonicalizeAttribute() throws IOException {
    
        Attribute att = new Attribute("pre:foo", "http://www.example.org", "value");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(att);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
View Full Code Here

        Element element = new Element("pre:foo", "http://www.example.org");
        Nodes namespaces = element.query("namespace::pre");
        Namespace ns = (Namespace) namespaces.get(0);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(ns);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
View Full Code Here

        Nodes namespaces = element.query("namespace::*");
        Namespace ns = (Namespace) namespaces.get(0);
        if (ns.getPrefix().equals("xml")) ns = (Namespace) namespaces.get(1);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(ns);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
View Full Code Here

        Element element = new Element("foo");
        Nodes namespaces = element.query("namespace::*");
        Namespace ns = (Namespace) namespaces.get(0);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(ns);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
View Full Code Here

    
        Element element = new Element("pre:foo", "http://www.example.org");
        element.appendChild("  value \n value");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(element);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
View Full Code Here

        Element element = new Element("pre:foo", "http://www.example.org");
        assertNull(element.getDocument());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(element);
            assertNull(element.getDocument());
        }
        finally {
            out.close();
        }
View Full Code Here

        Element element = new Element("pre:foo", "http://www.example.org");
        root.appendChild(element);
        element.appendChild("  value \n value");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(element);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
View Full Code Here

        Element b = new Element("b");
        a.appendChild(b);
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(b);
        }
        finally {
            out.close();
        }          
        byte[] actual = out.toByteArray();
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.