Package nu.xom

Examples of nu.xom.NodeFactory


   
    public void testChangeElementsToAttributes()
      throws ParsingException, IOException {
       
        String data = "<a><b>data1</b><c>text</c></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes();
                if (element.getParent() instanceof Document) {
                    result.append(element);
View Full Code Here


    public void testChangeDefaultNamespaceFromEnd()
      throws ParsingException, IOException {
       
        String data = "<a><b xmlns='http://www.a.com'/></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes(element);
                element.setNamespaceURI("http://www.b.org/");
                return result;
View Full Code Here

    // XXX need to test changing namespaces of attributes too
    public void testChangePrefixedNamespaceFromEnd()
      throws ParsingException, IOException {
       
        String data = "<a><pre:b xmlns:pre='http://www.a.com'/></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes(element);
                element.setNamespaceURI("http://www.b.org/");
                return result;
View Full Code Here

   
    public void testChangeDefaultNamespaceFromBeginning()
      throws ParsingException, IOException {
       
        String data = "<a><b xmlns='http://www.a.com'/></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Element startMakingElement(String name, String namespaceURI) {
                return new Element(name, "http://www.b.org/");
            }
           
View Full Code Here

    public void testChangePrefixedNamespaceFromBeginning()
      throws ParsingException, IOException {
       
        String data = "<a><pre:b xmlns:pre='http://www.a.com'/></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Element startMakingElement(String name, String namespaceURI) {
                return new Element(name, "http://www.b.org/");
            }
           
View Full Code Here

    public void testChangeTextToAttributes()
      throws ParsingException, IOException {
       
        String data = "<a><b>data1</b><c>text</c></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes makeText(String text) {
                Nodes result = new Nodes();
                result.append(new Attribute("name", text));
                return result;
View Full Code Here

   
    public void testChangeRootElementsToAttribute()
      throws ParsingException, IOException {
       
        String data = "<a><b>data1</b><c>text</c></a>";
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes();
                result.append(new Attribute(element.getLocalName(), element.getValue()));
                return result;
View Full Code Here

   
    public void testCantBypassMultipleParentChecks()
      throws ParsingException, IOException {
       
        String doc = "<root><a/><a/></root>";  
        Builder builder = new Builder(new NodeFactory() {
           
            private Element a = new Element("a");
           
            public Element startMakingElement(String name, String namespace) {
                if (name.equals("a")) return a;
View Full Code Here

   
    public void testCantBypassMultipleParentChecksFromFinishMakingElement()
      throws ParsingException, IOException {
       
        String doc = "<root><a/><a/></root>";  
        Builder builder = new Builder(new NodeFactory() {
           
            private Element a = new Element("a");
           
            public Nodes finishMakingElement(Element element) {
                if (element.getLocalName().equals("a")) return new Nodes(a);
View Full Code Here

   
    public void testFinishMakingElementIsCalledForRootElement()
      throws ParsingException, IOException {
       
        String doc = "<root/>";  
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                throw new XMLException("Method was called");  
            }
           
View Full Code Here

TOP

Related Classes of nu.xom.NodeFactory

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.