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

com.gitlab.mvysny.konsumexml.stax.EntityExpandingStaxParser.kt Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
package com.gitlab.mvysny.konsumexml.stax

/**
 * Expands [StaxEventType.EntityReference] with known text contents (such as character entities);
 * if the entity contents is not known the entity reference is left as-is.
 */
class EntityExpandingStaxParser(val delegate: StaxParser) : StaxParser by delegate {
    override val eventType: StaxEventType
        get() {
            val e = delegate.eventType
            if (e == StaxEventType.EntityReference && text != null) {
                // both the entity text and characters can be retrieved via the `text` property
                // so it's enough if we just pretend we've received Characters instead of an EntityRef
                return StaxEventType.Characters
            }
            return e
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy