Coder Social home page Coder Social logo

kxml2's Introduction

kobjects.org

Kotlin Projects

  • Konsole: A chat-like KMP "console" interface.
  • KtXml: Kxml2 ported to Kotlin Multiplatform (KMP)
  • ParserLib: A library for building recursive descent parsers.

Java Projects

  • kxml2: A lightweight "pull" parser for XML.

Legacy Projects

For an overview of all current projects (and some legacy projects), please refer to the github project page

kxml2's People

Contributors

mihnita avatar stefanhaustein avatar thekalinga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kxml2's Issues

I am unable to parse this data. It is a ActiveSync SendMail payload in http request.

byte[] arrOutput = { 0x03, 0x01, 0x6A, 0x00, 0x00, 0x15, 0x45, 0x51, 0x03, 0x36, 0x30, 0x44, 0x46, 0x33, 0x30, 0x46, 0x39, 0x2D, 0x44, 0x35, 0x34, 0x43, 0x2D, 0x34, 0x37, 0x32, 0x35, 0x2D, 0x41, 0x33, 0x44, 0x44, 0x2D, 0x31, 0x43, 0x41, 0x45, 0x32, 0x35, 0x45, 0x39, 0x38, 0x33, 0x42, 0x30, 0x00, 0x01, 0x08, 0x50, 0xC3, 0x82, 0x48, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x54, 0x79, 0x70, 0x65, 0x3A, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2F, 0x70, 0x6C, 0x61, 0x69, 0x6E, 0x3B, 0x0D, 0x0A, 0x09, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3D, 0x75, 0x73, 0x2D, 0x61, 0x73, 0x63, 0x69, 0x69, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2D, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x65, 0x72, 0x2D, 0x45, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3A, 0x20, 0x37, 0x62, 0x69, 0x74, 0x0D, 0x0A, 0x46, 0x72, 0x6F, 0x6D, 0x3A, 0x20, 0x72, 0x61, 0x6D, 0x40, 0x71, 0x61, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x2E, 0x6F, 0x6E, 0x6D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x0D, 0x0A, 0x4D, 0x69, 0x6D, 0x65, 0x2D, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, 0x30, 0x20, 0x28, 0x31, 0x2E, 0x30, 0x29, 0x0D, 0x0A, 0x44, 0x61, 0x74, 0x65, 0x3A, 0x20, 0x4D, 0x6F, 0x6E, 0x2C, 0x20, 0x31, 0x31, 0x20, 0x46, 0x65, 0x62, 0x20, 0x32, 0x30, 0x31, 0x39, 0x20, 0x31, 0x38, 0x3A, 0x30, 0x36, 0x3A, 0x33, 0x38, 0x20, 0x2B, 0x30, 0x35, 0x33, 0x30, 0x0D, 0x0A, 0x53, 0x75, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x3A, 0x20, 0x4D, 0x79, 0x0D, 0x0A, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2D, 0x49, 0x64, 0x3A, 0x20, 0x3C, 0x36, 0x30, 0x44, 0x46, 0x33, 0x30, 0x46, 0x39, 0x2D, 0x44, 0x35, 0x34, 0x43, 0x2D, 0x34, 0x37, 0x32, 0x35, 0x2D, 0x41, 0x33, 0x44, 0x44, 0x2D, 0x31, 0x43, 0x41, 0x45, 0x32, 0x35, 0x45, 0x39, 0x38, 0x33, 0x42, 0x30, 0x40, 0x71, 0x61, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x2E, 0x6F, 0x6E, 0x6D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x3E, 0x0D, 0x0A, 0x54, 0x6F, 0x3A, 0x20, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x40, 0x67, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x0D, 0x0A, 0x0D, 0x0A, 0x45, 0x6D, 0x70, 0x74, 0x69, 0x65, 0x64, 0x20, 0x0D, 0x0A, 0x0D, 0x0A, 0x53, 0x65, 0x6E, 0x74, 0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x6D, 0x79, 0x20, 0x69, 0x50, 0x68, 0x6F, 0x6E, 0x65, 0x0D, 0x0A, 0x01, 0x01 };

Note: Used all ActiveSync Code pages.

InputStream inStream = new ByteArrayInputStream(arrOutput.getBytes()); WbxmlParser wbxmlParser = new WbxmlParser(); wbxmlParser.setTagTable(...) ----> all ActiveSync code pages wbxmlParser.setTagTable(...) wbxmlParser.setInput(inStream , "UTF-8"); Document doc = new Document(); doc.parse(wbxmlParser); ByteArrayOutputStream out = new ByteArrayOutputStream(); KXmlSerializer xmlSerializer = new KXmlSerializer(); xmlSerializer.setOutput(out, null); doc.write(xmlSerializer); xmlSerializer.flush(); System.out.println(new String(out));

Expected out put is XML Converted SendMail command with tag included. I used all ActiveSync Code pages.

But I get out put as only as shown below:

<?xml version='1.0' encoding='UTF-8' ?><SendMail><Status>FB0602CB-84D1-4E1B-97ED-27AAB989C55A</Status><SaveInSentItems /><ClientId></ClientId></SendMail>

Please let me know if need more info.

Traversing the Parse Tree starting from a Node of TYPE != ELEMENT not possible.

Hello Stefan,

When using kxml2 to analyze "unknown" XML documents, I stumbled upon the fact that only nodes of the type ELEMENT are assigned their predecessors. So it is not possible to walk through the parse tree if the start point is not of type ELEMENT Wouldn't it be more sensible if elements of the type COMMENT and TEXT (possibly all) also get their predecessor. Should the memory requirement or the garbage collection be the reason for this decision perhaps using a weake reference for parrent could be the solution.

I hope I haven't overlook other side effects.

in Class:
org.kxml2.kdom.Node.java
at Method:

public void addChild(int index, int type, NodeInterface child) {
[...]
        if (type == ELEMENT) {
            if (!(child instanceof Element))
                throw new RuntimeException("TestElement obj expected)");

            ((Element) child).setParent(this);
        }
[...]
}

Thanks

Best wishes

Andreas

High Unicode values (>= 0x010000) not supported

Copied from Felix Meschberger's bug report at SourceForge.net: https://sourceforge.net/p/kxml/bugs/17/

Currently high Unicode values >= 0x01000 (outside the 16bit range) are not supported correctly. When parsing a character reference &#x; the high value should be stored as a surrogate pair. When serializing the surrogate pair should be stored as a single character reference &#x;.

A patch is attached to the original bug report, see link above

Quick question concerning version sources

Hey :)
Can the source downloads [.zip and .tar.gz] in https://github.com/stefanhaustein/kxml2/releases/tag/v2.4.2 be regarded as the stable sources for kxml2 version 2.4.2?
The reason I am asking is that for 2.4.2, I noticed some System.out.println usages in org.kxml2.io.KXmlParser.java (around line 760)
They made me wonder whether this is a stable version. The same println was not present in 2.3.0 .
Thanks :)

EDIT: Also, is there a javadoc jar for 2.4.2?

KXmlParser throws top-level RuntimeException

The KXmlParser class uses RuntimeExceptions when XmlPullParser doesn't declare a checked exception. This design choice is expected.
However, the class throws the top level RuntimeException (lines: 169, 180, 1130) instead of a more specific exception, which 'forces' clients to catch a RuntimeException, hiding the ability to detect errors from other parts of the code in the process.
One simple solution could be to throw a more specific KXmlParserRuntimeException to allow clients to catch only the errors thrown by the parser class. This would be backwards compatible with any client already catching the RuntimeException.

Gradle build fails for version 2.4.2 on Jitpack.

Build is failing only when using version 2.4.2, with 2.4.1 everything works fine.

See this for more details: https://jitpack.io/com/github/stefanhaustein/kxml2/2.4.2/build.log

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find xmlpull:xmlpull:1.1.3.1.
  Searched in the following locations:
    - file:/home/jitpack/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.pom
    - file:/home/jitpack/.m2/repository/xmlpull/xmlpull/1.1.3.1/xmlpull-1.1.3.1.jar
[Fatal Error] compress.xml:1:1: Content is not allowed in prolog.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.