-
Notifications
You must be signed in to change notification settings - Fork 15
XML to TOON #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
XML to TOON #27
Conversation
Core Implementation Complete: Full functionality for converting XML documents to TOON format is implemented. New API Methods: Extended the main JToon.java class with new static methods for encoding: encodeXml(String xml) (Basic conversion) encodeXml(String xml, EncodeOptions options) (Conversion with custom options) Dedicated Normalizer: Created XmlNormalizer.java to handle XML parsing using Jackson's XmlMapper and convert it to an intermediate JsonNode object. Dependency Integration: Integrated the jackson-dataformat-xml dependency for robust XML parsing capabilities. Comprehensive Structure Support: The conversion successfully handles: Simple and nested XML elements (converted to TOON objects). XML attributes (included as additional TOON fields). XML arrays (converted to TOON arrays). Preserves element hierarchy and ordering. Full Options Support: The new methods support existing EncodeOptions for: Custom indentation levels. Different delimiters (comma, pipe, tab). Length markers for arrays. Robust Error Handling: Implemented checks to throw an IllegalArgumentException for: Null or empty XML strings. Malformed XML documents. Invalid XML structure. Extensive Testing: 449 total tests are passing (BUILD SUCCESSFUL). Tests cover positive scenarios, negative/error handling, and complex edge cases (nested structures, attributes). Documentation: Added comprehensive JavaDoc documentation with clear signatures and usage examples.
felipestanzani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, the tests are not complete.
Where are the conversion tests: given this I expect that?
Where are the tests for XmlNormalizer?
PRs won't be merged by insistence.
|
Must resolve the conflicts. |
1. encodesXmlWithAttributes
Input XML:
<user id="123" active="true"><name>John</name><email>john@example.com</email></user>
Expected TOON Output:
id: "123"
active: "true"
name: John
email: john@example.com
2. encodesDeeplyNestedXmlWithArrays
Input XML:
<company><name>TechCorp</name><departments><department><name>Engineering</name><employees><employee><name>Alice</name><role>Developer</role></employee><employee><name>Bob</name><role>Manager</role></employee></employees></department><department><name>Marketing</name><employees><employee><name>Carol</name><role>Director</role></employee></employees></department></departments></company>
Expected TOON Output:
name: TechCorp
departments:
department[2]:
- name: Engineering
employees:
employee[2]{name,role}:
Alice,Developer
Bob,Manager
- name: Marketing
employees:
employee:
name: Carol
role: Director
3. encodesXmlWithMixedContentAndAttributes
Input XML:
<book isbn="978-3-16-148410-0" category="fiction"><title>The Great Novel</title><author status="bestselling">Jane Doe</author><chapters><chapter number="1" title="Introduction">Welcome to the story</chapter><chapter number="2" title="Development">The plot thickens</chapter></chapters></book>
Expected TOON Output:
isbn: 978-3-16-148410-0
category: fiction
title: The Great Novel
author:
status: bestselling
"": Jane Doe
chapters:
chapter[2]{number,title,""}:
"1",Introduction,Welcome to the story
"2",Development,The plot thickens
Key Features Tested
- XML Attributes: Converted to regular object properties (no "@" prefix)
- Deep Nesting: Multi-level XML structures with arrays
- Mixed Content: Elements with both attributes and text content
- Array Detection: Similar child elements automatically become arrays
- Tabular Format: Arrays of similar objects use efficient tabular encoding
All tests now properly validate the expected TOON output strings, ensuring the XML to TOON conversion works correctly for complex XML structures.
|
XML Test Cases Added
Input XML: Expected TOON Output:
Input XML: Expected TOON Output:
Input XML: Expected TOON Output: Key Features Tested
All tests now properly validate the expected TOON output strings, ensuring the XML to TOON conversion works correctly for complex XML structures. |
|
@felipestanzani looks like there are many things in repo to add on top of this once you approve.
|
|
We are currently focused on migrate the lib to the official toonformat property, so we are preparing this migration that require many steps. |
No description provided.