Dear Aspose support,
I’m facing an issue with XmlDataSource. Assume the following XML snippet:
<DATA>
<RAILPROFILE>54E2</RAILPROFILE>
</DATA>
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?
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.
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.
Hi,
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,
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.
Hi,
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
FV
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?
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.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.