All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.digidoc4j.ddoc.c14n.TinyXMLParser Maven / Gradle / Ivy

Go to download

DDoc4J is Java Library for validating DDOC documents. It's not recommended to use it directly but rather through DigiDoc4J's API.

The newest version!
package org.digidoc4j.ddoc.c14n;

import org.digidoc4j.ddoc.c14n.common.StringImplementation;

import java.util.Stack;

public class TinyXMLParser {


    public TinyXMLParser()
    {
    }


    public void Fail(TinyXMLParser_Fragment f, String reason) throws RuntimeException
    {
        Object[] objectArray0;

        objectArray0 = new Object[]
                {
                        "Error line ",
                        new Integer(f.get_TextPosition().get_Line()),
                        ", column ",
                        new Integer(f.get_TextPosition().get_Column()),
                        " - ",
                        reason
                };
        throw new java.lang.RuntimeException(StringImplementation.Concat(objectArray0));
    }

    public void Parse(TinyXMLParser_Handler h, byte[] data)
    {
        TinyXMLParser_Document doc;
        Stack a;
        TinyXMLParser_Fragment f;
        TinyXMLParser_Element current;
        TinyXMLParser_NestedElement nested;
        TinyXMLParser_Tag def;
        TinyXMLParser_Comment comment;
        TinyXMLParser_Element n;
        TinyXMLParser_CData u;
        TinyXMLParser_TextNode ux;

        try
        {
            doc = new TinyXMLParser_Document();
            doc.ParseHandler = h;
            a = new Stack();
            h.startDocument();
            f = TinyXMLParser_Fragment.Of(data, 0);
            if(f == null) return;
            f.OwnerDocument = doc;
            f.SplitMarkup();
            current = null;
            while (!(f == null))
            {

                if (f.get_IsMarkup())
                {

                    if (f.get_Item(""))
                            {
                                h.endElement(n);
                            }
                            else
                            {

                                if (!(current == null))
                                {
                                    a.push(current);
                                }
                                else
                                {

                                    if (!(doc.DocumentElement == null))
                                    {
                                        this.Fail(f, "document element already defined");
                                    }

                                    doc.DocumentElement = n;
                                }

                                current = n;
                            }

                            continue;
                        }


                        if (f.get_Item("




© 2015 - 2024 Weber Informatics LLC | Privacy Policy