Package hu.jokeman.xparser.document

Examples of hu.jokeman.xparser.document.XMLNode


    private XMLNode pop () {
        return _currentNodes.pop ();
    }

    public void addCData (String content) throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Document ||
                currentNode instanceof Element) {
           
            currentNode.addChild (new CData (content));
        } else {
            throw new DocumentBuilderException ("CData isn't allowed here.");
        }
    }
View Full Code Here


            throw new DocumentBuilderException ("CData isn't allowed here.");
        }
    }

    public void addDocType (String docType) throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Document) {
            currentNode.addChild (new DocType (docType));
        } else {
            throw new DocumentBuilderException (
                    "Document schema definitions aren't allowed here.");
        }
    }
View Full Code Here

        }
    }

    public void createProcessingInstructionStart (String piName)
            throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Document) {
            ProcessingInstruction pi = new ProcessingInstruction (piName);
            currentNode.addChild (pi);
            push (pi);
        } else {
            throw new DocumentBuilderException (
                    "Document schema definitions aren't allowed here.");
        }
View Full Code Here

        }
    }

    public void finishProcessingInstructionStart ()
            throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof ProcessingInstruction) {
            pop ();
        } else {
            throw new DocumentBuilderException (
                    "Current node is not a processing instruction.");
View Full Code Here

                    "Current node is not a processing instruction.");
        }
    }

    public void createTagStart (String tagName) throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Document ||
                currentNode instanceof Element) {
            Element element = new Element (tagName);
            currentNode.addChild (element);
            push (element);
        } else {
            throw new DocumentBuilderException (
                    "Elements not allowed here.");
        }
View Full Code Here

    public void finishTagStart () throws DocumentBuilderException {
    }

    public void addAttribute (String attrName, String attrVal)
            throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Element ||
                currentNode instanceof ProcessingInstruction) {
            Attribute attr = new Attribute (attrName);
            attr.setValue (attrVal);
            currentNode.addChild (attr);
        } else {
            throw new DocumentBuilderException (
                    "Attributes not allowed here.");
        }
    }
View Full Code Here

                    "Attributes not allowed here.");
        }
    }

    public void addTagClose (String tagName) throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (!(currentNode instanceof Element) ||
                !((Element) currentNode).getName ().equals (tagName)) {
            throw new DocumentBuilderException (
                    "Cannot close element: " + tagName + ".");
        }
View Full Code Here

        pop ();
    }

    public void addEntityReference (String entityName)
            throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Element) {
            currentNode.addChild (new EntityReference (entityName));
        } else {
            throw new DocumentBuilderException (
                    "Entity references not allowed here.");
        }
    }
View Full Code Here

                    "Entity references not allowed here.");
        }
    }

    public void addComment (String content) throws DocumentBuilderException {
        XMLNode currentNode = peek ();
        if (currentNode instanceof Element ||
                currentNode instanceof Document) {
            currentNode.addChild (new Comment (content));
        } else {
            throw new DocumentBuilderException (
                    "Comments not allowed here.");
        }
    }
View Full Code Here

        _pp.print ("<" + anElement.getName ());

        XMLNodeIterator nodeIt = anElement.children ();
        int attrCount = 0;
        while (nodeIt.hasNext ()) {
            XMLNode child = nodeIt.next ();
            if (child instanceof XMLAttribute) {
                child.accept (this);
                attrCount++;
            }
        }

        if (attrCount == anElement.childCount ()) {
            _pp.printSimple (" />\n");
        } else {
            _pp.printSimple (">\n");
            _pp.inc ();
            nodeIt = anElement.children ();
            while (nodeIt.hasNext ()) {
                XMLNode child = nodeIt.next ();
                if (!(child instanceof XMLAttribute)) {
                    child.accept (this);
                }
            }
            _pp.pop ();
            _pp.println ("</" + anElement.getName () + ">");
        }
View Full Code Here

TOP

Related Classes of hu.jokeman.xparser.document.XMLNode

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.