For Xml Length Limitation

Formal or Practical XML Tag Length Limit?

I think you're unlikely to find tools that can't handle names of say 1K characters, at which point you're hitting serious performance and usability problems rather than hard limits.

But your design is wrong. XML is hierarchic, take advantage of the fact rather than trying to fight it.

For XML length limitation

Assuming you're seeing the truncation in SSMS, change your maximum character settings in SSMS's options:

  • Tools > Options > Query Results > SQL Server > Results to Text > Maximum number of characters displayed in each column

    (limit is 8192 characters)
  • Tools > Options > Query Results > SQL Server > Results to Grid > Maximum Characters Retrieved

    Non XML data limit is 65535 characters
    XML data limit is Unlimited

What is the one line max length limit in XML files?

My guess reading your question was that the limit would be somewhere between 29k and 51k but clipped to a logical number

I might have found the answer by testing it.
As you said, a char is stored on two bytes. So 29k char would be 58k bytes and 51k would be 102k bytes.
The "logical" limit would be 65536 as it is 2^16. so the limit in char is 2^16 / 2 or 2^15 which is 32768

I tested to put strings in my string.xml (basically a long line of 'a')

<string name="length_test32000">(32 000 a)</string>
<string name="length_test32767">(32 767 a)</string>
<string name="length_test32768">(32 768 a)</string>
<string name="length_test32769">(32 769 a)</string>
<string name="length_test33000">(33 000 a)</string>

Then i tried to log their size :

String test32k = getString(R.string.length_test32000);

String test32k767 = getString(R.string.length_test32767);
String test32k768 = getString(R.string.length_test32768);
String test32k769 = getString(R.string.length_test32769);

String test33k = getString(R.string.length_test33000);

Log.i("tag", "32000 : "+test32k.length());
Log.i("tag", "32767 : "+test32k767.length());
Log.i("tag", "32768 : "+test32k768.length());
Log.i("tag", "32769 : "+test32k769.length());
Log.i("tag", "33000 : "+test33k.length());

Here are the results :

I/tag: 32000 : 32000
I/tag: 32767 : 32767
I/tag: 32768 : 16
I/tag: 32769 : 16
I/tag: 33000 : 16

From 32768 it seems to be truncated so i log what was inside

Log.i("tag", "32768 : "+test32k768.length() + " content : " + test32k768);

And the result is :

I/tag: 32768 : 16 content : STRING_TOO_LARGE

The maximum char seems to be 32767 (2^15 - 1) characters. I didn't find any official doc that say that, but it is what i found while testing

What is the length of maximum text inside an xml node?

There is no limit enforced by the specification.

The usual issues of memory and other system resources apply though.

What is the max number of characters allowed in an XML attribute?

I don't believe there is a character limit per the XML specification, but the Best Practice is to keep attribute values short.

If an attribute value grows long...chances are that it should be an element of its own rather than an attribute on another element.

SQL limit for XML type

The truncation you are seeing is specific to SQL Server Management Studio (SSMS). If you go to the Query menu and select Query Options..., then go to Results and then to Grid, you should see on the right side a section for "Maximum Characters Retrieved". The "Non XML data" has a max of 65,535 (which should also be the default) and the "XML data" is a drop-down with options:

  • 1 MB
  • 2 MB (default)
  • 5 MB
  • Unlimited

Since the XML datatype can bring back more than 65,535 characters, you can convert your output to XML (this is only needed when using SSMS; client libraries should pull back the full string):

SELECT CONVERT(XML,
stuff((SELECT ',' + ldd.LddLabourDistCD + '|' + ldd.LddLabourDistDescPay
FROM LDetail ldd
INNER JOIN LDist ld
ON ldd.ID = ld.ID
AND ld.ID = 019425
AND ld.LDistType = 'F'
FOR XML PATH ('')), 1, 1, '')
)

How to resolve maximum length of 128 on a column alias when using FOR XML PATH?

SET QUOTED_IDENTIFIER OFF
SET ANSI_NULLS ON

place this at the starting it solved my problem



Related Topics



Leave a reply



Submit