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

Free Support Forum - aspose.com

Linq + xml type inference

Hi,

i’m sorry but i have another problem with xml and linq.
The DataSet created through dataSet.readXml() doesn’t seem to have the correct datatypes (or linq reporting engine doesn’t).

For example it doesn’t handle boolean values or date correctly.

If i have an xml containing this attribute:
1950-04-01T00:00:00+01:00

and try to output it on the template using format options for date like this:
<<[identity.first().birthDate]:"dd.MM.yyyy">>

the pdf will output the string value and not the correct date:
1950-04-01T00:00:00+01:00

The same occours with boolean datatypes which are always treated as strings…
Once again Mail merge and XmlDataSet treated this values correctly.

Thanks

Hi Simone,

Thanks for your inquiry. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-12394. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Simone,

Further to my last post, note that in contrast to Mail Merge, LINQ Reporting Engine heavily depends on the type of a data field processed. Otherwise, it would be impossible for the engine to use members of this type which is essential due to the engine’s concept. By this reason, the birthDate field is treated as a string and can not be formatted using a date-time pattern.

In this case, you need to use an XML schema that explicitly specifies the type of the birthDate column as “xs:dateTime”. Please load the xml schema as shown below. Hope this helps you.

DataSet dataSet = new DataSet();
dataSet.readXmlSchema(MyDir + "input.xsd");
dataSet.readXml(MyDir + "input.xml");

Hi, in my use case a cannot use an xsd for the xml.
Is there another way of handling it ?

If not i cannot jump to linq and have to remain on mail merge !
So i ask you to add the if (conditional) statement in mail merge too, please…

thanks

Hi, in my use case a cannot use an xsd for the xml.
Is there another way of handling it ?

If not i cannot jump to linq and have to remain on mail merge !
So i ask you to add the if (conditional) statement in mail merge too, please…

thanks

Hi Simone,

Thanks for your inquiry.

*simone.padovan:

Hi, in my use case a cannot use an xsd for the xml.
Is there another way of handling it ?*

You are using XML as data source. In this case, you need to load the XML schema into DataSet. If you do not load the xml schema into DataSet, the date field will be treated as string.

Note that in contrast to Mail Merge, LINQ Reporting Engine heavily
depends on the type of a data field processed. Otherwise, it would be
impossible for the engine to use members of this type which is essential
due to the engine’s concept. By this reason, the birthDate field is
treated as a string and can not be formatted using a date-time pattern.

*simone.padovan:

So i ask you to add the if (conditional) statement in mail merge too, please…*

Unfortunately, I have not understood this query. Could you please share some more detail about this query? We will then provide you more information on this.

I’d like to use this feature with Mail Merging:
https://docs.aspose.com/words/java/using-conditional-blocks/

<<if [conditional_expression1]>>
template_option1
<<elseif [conditional_expression2]>>
template_option2
...
<<else>>
default_template_option
<</if>>

Thanks

Hi Tahir, that’s a better solution, thanks.
It will be nicer, anyway, if dataSet.readXml could directly try to transform string data in date/boolean/number when building the DataSet according to their value.

Thanks U !

Simone

Hi Simone,

Thanks for your inquiry.

*simone.padovan:

The DataSet created through dataSet.readXml() doesn’t seem to have the correct datatypes (or linq reporting engine doesn’t).

For example it doesn’t handle boolean values or date correctly.

If i have an xml containing this attribute:
1950-04-01T00:00:00+01:00

and try to output it on the template using format options for date like this:
<<[identity.first().birthDate]:“dd.MM.yyyy”>>

the pdf will output the string value and not the correct date:
1950-04-01T00:00:00+01:00*

In your scenario, you can achieve your requirements by using one of following solutions.

*1. Using an XML schema that explicitly specifies the type of the birthDate column as “xs:dateTime” in xsd file.

  1. Without using an XML schema. Solution shared in my previous post.*

Please consider the following xml. There is no information of datatype either the value of birthDate is string or date. So, XML schema should be specified for this using DataSet.readXmlSchema method.

1950-04-01T00:00:00+01:00

This behavior is implemented by the built-in
.Net class. The Java version of the DataSet class (that we have
introduced) works the same way.

Ok, thank u very much

The issues you have found earlier (filed as WORDSJAVA-1152) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.