Large XML File will not Format

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 12 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
sblaylock
Posts: 41
Last visit: Thu Jun 02, 2022 10:25 am

Large XML File will not Format

Post by sblaylock »

I have a large xml file that won't format in PrimalXML 2011 or PrimalScript 2011. It's over 8000 lines long according to PrimalScript. I have emailed the xml to support@sapien.com.
Scott.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Large XML File will not Format

Post by davidc »

What version of PrimalXML are you using? David
David
SAPIEN Technologies, Inc.
User avatar
sblaylock
Posts: 41
Last visit: Thu Jun 02, 2022 10:25 am

Large XML File will not Format

Post by sblaylock »

2011
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Large XML File will not Format

Post by davidc »

What build of PrimalXML 2011? When I open the file it is automatically formatted. Verify that the following setting is enabled: Options->Format XML On Open Also try changing the extension to xml instead of txt, but either case should work. If the issue persists, please send in a screenshot. David
David
SAPIEN Technologies, Inc.
User avatar
sblaylock
Posts: 41
Last visit: Thu Jun 02, 2022 10:25 am

Large XML File will not Format

Post by sblaylock »

Hi David,
Sorry about the version question. I'm running the latest build - 2.0.5. I have the option set to Format XML On Open.

The issue is happening when I paste the xml from our log files. I have sent you another file that won't format on open.
Scott.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Large XML File will not Format

Post by davidc »

OK I see the problem. There are carriage return / newline in the middle of some tags, which is causing errors with the file. If you remove the line breaks from the middle of the tags it should format.Note: Error messages are displayed in the Output panel. David
David
SAPIEN Technologies, Inc.
User avatar
sblaylock
Posts: 41
Last visit: Thu Jun 02, 2022 10:25 am

Large XML File will not Format

Post by sblaylock »


Hi David,
So the XML formatter/parser doesn't have the ability to understand a cr/lf in the middle of a tag then.

Our xml is being streamed into a log file, and we have no way of knowing when the log will add a cr/lf.

For us to walk 8000+ lines of xml and pull the cr/lfs out is a non-starter.

Is there a way to have the parser be more intelligent to understand the cr/lf is in the middle of a tag? cr/lf before and after a tag could be legit, but not in the middle of a tag.

Scott
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Large XML File will not Format

Post by Alexander Riedel »

Your xml example contains this:
</n1:attr
ibuteValue>

The file is actually only 26 lines, they just are very long. The CRLF makes the XML malformed, every parser I know of will throw that out. The initial parsing show this error:
Line 2, Column 0. Error 104: Unable to retrieve a token; Missing end bracket while parsing end tag 'n1:attr'.

If you have control over the process that streams the XML, simply add a CRLF after each close tag symbol '>' so that the log won't add them at random.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
sblaylock
Posts: 41
Last visit: Thu Jun 02, 2022 10:25 am

Large XML File will not Format

Post by sblaylock »

Hi Alexander,

Unfortunately we don't have control to the streams that dump the XML.

Somewhere along the way when I was trying to get the xml formatted, I dropped it into PrimalScript 2011 and selected Format XML. It came back with a warning that the xml was over something like 8120 lines - can't remember the exact message.

This is one of the largest dumps of xml we've dropped into PrimalXML, and it seems odd to me that all the other log files from the same system have been fine. Could there be a limit to the amount of xml it can parse? What seems odd too is it would throw a cr/lf in line 2 i.e. near the top, where, I would think, if the xml was too large from the mainframe it would drop the cr/lf near the bottom.

Anyway, it's rare for us to work with these large xml responses, so we can live with the issue.

Thanks for getting back to me,
Scott.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Large XML File will not Format

Post by Alexander Riedel »

The message warns about line length not number of lines. There is no really limit to the amount, it's just that if the XML is malformed it doesn't know what to do with it. Having a CR/LF in the middle of a tag name is just a syntactical error. Size, line length etc. have nothing to do with that.

The line number refers to the line in the original XML stream, not the reformatted one, because PrimalScript tries to parse the XML FIRST and only if that fails it reformats it as text.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 12 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.