We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Specify XSD Schema to Avoid Automatic Conversion of Double Values in XmlDataSource | LINQ Reporting Java

Dear Aspose support,
I’m facing an issue with XmlDataSource. Assume the following XML snippet:


After processing with LINQ I get the following text: 5400.0
This is really unwanted: 54E2 is interpreted as double value (even if it is not in this case) and I cannot find any switch/command to use in the template to force rendering as string.

At this time it would be somewhat difficult to adapt code and/or XML generation; which is the best/faster approach to solve this issue?

Thanks for your attention,
Kind regards


Please compress the following resources into ZIP format and attach the .zip file here for testing:

  • A simplified template Word document
  • Sample XML file containing the simplified data
  • Aspose.Words generated output DOCX file showing the undesired behavior
  • Your expected docuemnt showing the desired output
  • Please also create a standalone simplified Console Application (source code without compilation errors) that helps us to reproduce this problem on our end and attach it here for testing. Please do not include DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will then start further investigation into your particular issue and provide you more information.

xmlbadformatting.zip (10.9 KB)

please find attached a zip with files to reproduce the issue with the latest Aspose.Words version.

I have also added another undesired behaviour: a field containing value “4,6” is rendered as “Tue Apr 06 00:00:00 CEST 2021”.

I do understand automatic type recognition, but this seems just too far if an option to configure a given field as String is not provided.

If you know of any workaround (I do have control on XML + DOCX + Java code) that I could readily apply, then it would be really really appreciated.

Thanks for your attention
Best Regards


We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-22455. We will further look into the details of this problem and will keep you updated here on the status of the linked ticket. We apologize for any inconvenience.

I’ve made an effort to produce dinamycally an XSD schema to load in the XmlDataSource to force the rendering of some fields as strings.

While this solves my original problem, it breaks proper insertion of images which are encoded in the XML as base64 (either configuring those fields as “xs:string” or as “xs:base64Binary”.

I’m running short on workarounds while waiting for some official solution.
Any hint would be appreciated,

thanks in advance for your attention


54E2 is a valid number representation in scientific notation, so it is not a bug that the engine recognizes it as a number by default as per our documentation here (Accessing XML Data). You need to specify a data type for an XML element explicitly, if you want the XML element to be loaded as a value of another type. At the moment, the only way to do this is using XML Schema (XSD). XmlDataSource has constructors accepting XSD data.

Loading from Base64-encoded string is supported; please make sure that you are using the latest (21.6) version of Aspose.Words for Java. If this does not resolve the issue, then please provide us a template document, XML, XSD, and code to reproduce this particular issue. Thanks for your cooperation.

thanks for answering.
Building an XSD is what I did, and was able also to properly laod base64 images.

That said, I still consider the interpretation of the String “4,6” as date is a bit too far, not an ideal behavior.
Probably not a bug this too, but quite an unlikely use case.

Thanks for you support, I’m currently able to make things working.
Best regards

By the way, just FYI,
it looks like that loading an XML schema in XmlDataSource in which elements have the attributes

maxOccurs="unbounded" minOccurs="0"

causes an NPE in Aspose library.



Please provide simplified template Word file, XML, XSD, and code to reproduce this particular issue on our end.


Internally, LINQ Reporting Engine uses standard .NET APIs when probing values of different types. For example, please check the following C# code.

Console.WriteLine(DateTime.Parse("4,6")); // Prints "4/6/2021 12:00:00 AM" for an invariant culture.

And while porting above code to Java, this behavior is kept. So this is not a bug either.

As far as we see, you were able to resolve these issues by proper usage of XSD on your end. However, if this particular issue still requires a resolution, we could implement XmlDataLoadOptions.ExactDateTimeParseFormats by analogy with JsonDataLoadOptions.ExactDateTimeParseFormats to restrict parse formats used to recognize date-time values when XSD is not provided. Please clarify, if you need this?

thanks for the kind response.

On our end, dynamic XSD generation to fit our data model is now implemented.
So no need for additional implementations on your side.

Thanks for your attention,
Kind regards,


It is just to inform you that we have now closed the linked issue (WORDSNET-22455). In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.