-
Notifications
You must be signed in to change notification settings - Fork 21
XML to TOON Conversion in JToon #25
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
00f4b97
XML to TOON Conversion Summary in JToon
badpirogrammer2 47a8ad3
reverted the version to java 17 and moved un necessary classes.
badpirogrammer2 743edec
implemented xmlmapper
badpirogrammer2 c4d6b67
New test cases added in a nested class
badpirogrammer2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/felipestanzani/jtoon/normalizer/XmlNormalizer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.felipestanzani.jtoon.normalizer; | ||
|
|
||
| import tools.jackson.databind.JsonNode; | ||
| import tools.jackson.dataformat.xml.XmlMapper; | ||
|
|
||
| /** | ||
| * Normalizes XML strings to Jackson JsonNode representation. | ||
| * Converts XML structure to JSON-compatible format for TOON encoding. | ||
| */ | ||
| public final class XmlNormalizer { | ||
|
|
||
| private static final XmlMapper XML_MAPPER = XmlMapper.builder().build(); | ||
|
|
||
| private XmlNormalizer() { | ||
| throw new UnsupportedOperationException("Utility class cannot be instantiated"); | ||
| } | ||
|
|
||
| /** | ||
| * Parses an XML string into a JsonNode using the shared XmlMapper. | ||
| * <p> | ||
| * This centralizes XML parsing concerns to keep the public API thin and | ||
| * maintain separation of responsibilities between parsing, normalization, | ||
| * and encoding. | ||
| * </p> | ||
| * | ||
| * @param xml The XML string to parse (must be valid XML) | ||
| * @return Parsed JsonNode | ||
| * @throws IllegalArgumentException if the input is blank or not valid XML | ||
| */ | ||
| public static JsonNode parse(String xml) { | ||
| if (xml == null || xml.trim().isEmpty()) { | ||
| throw new IllegalArgumentException("Invalid XML"); | ||
| } | ||
| try { | ||
| return XML_MAPPER.readTree(xml); | ||
| } catch (Exception e) { | ||
| throw new IllegalArgumentException("Invalid XML", e); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.