Linq + xml + xsd

I try to use linq repot engine with xml and xsd but this error comes out when i try to create dataset from xml (using xsd):

java.lang.NullPointerException
at com.aspose.words.net.System.Data.zzU.zzZ(Unknown Source)
at com.aspose.words.net.System.Data.zzU.zzZ(Unknown Source)
at com.aspose.words.net.System.Data.zzU.zzZ(Unknown Source)
at com.aspose.words.net.System.Data.zzU.zzYWc(Unknown Source)
at com.aspose.words.net.System.Data.DataSet.readXml(Unknown Source)
at com.aspose.words.net.System.Data.DataSet.readXml(Unknown Source)

Code:

DataSet dataSet = new DataSet();
if (merger.getXsd() != null)
{
    dataSet.readXmlSchema(new ByteArrayInputStream(merger.getXsd().getBytes(StandardCharsets.UTF_8)));
}
dataSet.readXml(new ByteArrayInputStream(dati.getBytes(StandardCharsets.UTF_8)));

I attach source code

Thanks

Hi Simone,

Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for Java 15.8.0 and have not found the shared issue. Please use Aspose.Words for Java 15.8.0. I have attached the output document with this post for your kind reference. Please let us know if you have any more queries.

Hi Tahir, i’m using version 15.8.0 too as you can see from pom.xml.
Please check that u are using correct version of testPdf…i get the error on this line (bold one) and only if i read xml schema:

DataSet dataSet = new DataSet();
if (merger.getXsd() != null)
{
    dataSet.readXmlSchema(new ByteArrayInputStream(merger.getXsd().getBytes(StandardCharsets.UTF_8)));
}
dataSet.readXml(new ByteArrayInputStream(dati.getBytes(StandardCharsets.UTF_8))); 

Thanks

Hi Simone,

Thanks for your inquiry. I have tested the scenario using following code example and have not found any exception. Could you please check this scenario using following code example and let us know if you still face any issue? Please test this code using Aspose.Words for Java 15.8.0.

DataSet dataSet = new DataSet();

dataSet.readXml(new ByteArrayInputStream("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<iscrizionePdf>
    <identita><cap>zipCode</cap><cellulare></cellulare><codiceFiscale>SNTSMN80H15A952N</codiceFiscale><cognome>Represented</cognome><dataDiNascita>1950-04-01T00:00:00+01:00</dataDiNascita><email>testuser@siag.it</email><linguaPreferita>de</linguaPreferita><localitaEstera>locationName</localitaEstera><localitaEsteraDiNascita>?</localitaEsteraDiNascita><nome>Test</nome><numeroCivico>streetNumber</numeroCivico><sesso>M</sesso><statoDe>nameDE</statoDe><statoIt>nameIT</statoIt><strada>street</strada><telefono></telefono><tipoPersona>PersonaFisica</tipoPersona><utenteCollegatoCodiceFiscale>SNTSMN80H15A952N</utenteCollegatoCodiceFiscale><utenteCollegatoCognome>Testuser</utenteCollegatoCognome><utenteCollegatoNome>Testuser</utenteCollegatoNome></identita><istanza xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                xsi:type=\"iscrizione\">
        <anno>2015</anno><cellulare>222</cellulare><dichiarazioniMendaci>true</dichiarazioniMendaci><domicilio><cap>39100</cap><civicoStrada><codice>7850</codice><numero>16</numero><strada><areaIt>VIA</areaIt><codice>2160</codice><descrizioneDe>DELAI-STRASSE</descrizioneDe><descrizioneIt>DELAI</descrizioneIt></strada></civicoStrada><comune><capoluogo>true</capoluogo><codiceIstat>021008</codiceIstat><descrizioneDe>BOZEN</descrizioneDe><descrizioneIt>BOLZANO</descrizioneIt><provincia><codiceIstat>021</codiceIstat><descrizione>BOLZANO/BOZEN</descrizione><siglaAuto>BZ</siglaAuto></provincia></comune></domicilio><email>testuser@siag.it</email><familyPlus>false</familyPlus><importo>54</importo><informativa>true</informativa><minori>
            <assistenzaPersonale>true</assistenzaPersonale><certificatoMedico>1</certificatoMedico><classe>1</classe><codiceFiscale>PDVSMN71L22A952V</codiceFiscale><cognome>4562222X</cognome><dataNascita>2002-01-01T00:00:00+01:00</dataNascita><dieta>
                <codice>NOCARNE</codice><descrizioneDe>
                    Menu
                    ohne jede Art von Fleisch
                </descrizioneDe><descrizioneIt>
                    Menu senza
                    alcun tipo di carne
                </descrizioneIt>
            </dieta><malattie>
                <codice>ALLERGIE</codice><descrizioneDe>Allergien/Unvertraglichkeiten</descrizioneDe><descrizioneIt>
                    Allergie/intolleranze
                    varie
                </descrizioneIt>
            </malattie><nome>2^12</nome><oreAssistenza>0</oreAssistenza><scuola>
                <civico>
                    <codice>7427</codice><numero>38</numero><strada>
                        <areaIt>VIA</areaIt><codice>1710</codice><descrizioneDe>CLAUDIA-AUGUSTA-STRASSE</descrizioneDe><descrizioneIt>
                            CLAUDIA
                            AUGUSTA
                        </descrizioneIt>
                    </strada>
                </civico><codice>662</codice><descrizioneDe>
                    DANTE
                    ALIGHIERI (KINDERGARTEN)
                </descrizioneDe><descrizioneIt>
                    DANTE
                    ALIGHIERI
                    (MATERNA)
                </descrizioneIt><email>scuolamaternadante@tin.it</email><lingua>IT</lingua><telefono>
                    0471
                    28 25
                    98
                </telefono><tipo>Materna</tipo>
            </scuola><turni>
                <codice>1</codice><daData>2015-06-22T00:00:00+02:00</daData><descrizioneDe>
                    1
                    turno
                </descrizioneDe><descrizioneIt>
                    1
                    turno
                </descrizioneIt><aData>2015-06-26T00:00:00+02:00</aData>
            </turni>
        </minori><minoriResidentiBolzano>true</minoriResidentiBolzano><potestaGenitoriale>
            <codice>GEN</codice><descrizioneDe>Elternteil</descrizioneDe><descrizioneIt>
                Esercente
                responsabilitá
                genitoriale
            </descrizioneIt>
        </potestaGenitoriale><residenza>
            <cap>39100</cap><civicoStrada>
                <codice>11445</codice><numero>96</numero><strada>
                    <areaIt>VIA</areaIt><codice>6960</codice><descrizioneDe>ST.-VIGIL-STRASSE</descrizioneDe><descrizioneIt>
                        SAN
                        VIGILIO
                    </descrizioneIt>
                </strada>
            </civicoStrada><comune><capoluogo>true</capoluogo><codiceIstat>021008</codiceIstat><descrizioneDe>BOZEN</descrizioneDe><descrizioneIt>BOLZANO</descrizioneIt><provincia><codiceIstat>021</codiceIstat><descrizione>BOLZANO/BOZEN</descrizione><siglaAuto>BZ</siglaAuto></provincia></comune>
        </residenza><ricevutaPagamento>true</ricevutaPagamento><telefono>222</telefono>
    </istanza><domicilioCivico>16</domicilioCivico><domicilioViaDe>DELAI-STRASSE</domicilioViaDe><domicilioViaIt>
        VIA
        DELAI
    </domicilioViaIt><residenzaCivico>96</residenzaCivico><residenzaViaDe>ST.-VIGIL-STRASSE</residenzaViaDe><residenzaViaIt>
        VIA
        SAN VIGILIO
    </residenzaViaIt>
</iscrizionePdf>".getBytes(StandardCharsets.UTF_8)));


String xsd = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"  version=\"1.0\">\n"
                + "<xs:element name=\"indirizzo\" type=\"indirizzo\" />\n"
                + "<xs:element name=\"iscrizione\" type=\"iscrizione\" />\n"
                + "<xs:element name=\"iscrizionePdf\" type=\"iscrizionePdf\" />\n"
                + "<xs:element name=\"istanzaBase\" type=\"istanzaBase\" />\n"
                + "<xs:element name=\"istanzaPdf\" type=\"istanzaPdf\" />\n"
                + "<xs:element name=\"minore\" type=\"minore\" />\n"
                + "<xs:element name=\"turno\" type=\"turno\" />\n"
                + "<xs:complexType name=\"iscrizionePdf\"><xs:complexContent><xs:extension base=\"istanzaPdf\"><xs:sequence><xs:element minOccurs=\"0\" name=\"domicilioCivico\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"domicilioViaDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"domicilioViaIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"residenzaCivico\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"residenzaViaDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"residenzaViaIt\" type=\"xs:string\" /></xs:sequence></xs:extension></xs:complexContent></xs:complexType>\n"
                + "<xs:complexType name=\"istanzaPdf\"><xs:sequence><xs:element minOccurs=\"0\" name=\"identita\" type=\"identita\" /><xs:element minOccurs=\"0\" name=\"istanza\" type=\"istanzaBase\" /></xs:sequence></xs:complexType>\n"
                + "<xs:complexType name=\"identita\"><xs:sequence><xs:element minOccurs=\"0\" name=\"cap\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"cellulare\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codiceFiscale\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codiceIstatComune\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codiceIstatComuneDiNascita\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"cognome\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"comuneDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"comuneDiNascitaDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"comuneDiNascitaIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"comuneIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"dataDiNascita\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"email\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"linguaPreferita\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"localitaEstera\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"localitaEsteraDiNascita\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"nome\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"numeroCivico\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"partitaIva\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"provinciaDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"provinciaIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"ragioneSocialeDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"ragioneSocialeIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"sesso\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"statoDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"statoIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"strada\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"telefono\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"tipoPersona\" type=\"tipoPersona\" /><xs:element minOccurs=\"0\" name=\"utenteCollegatoCodiceFiscale\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"utenteCollegatoCognome\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"utenteCollegatoNome\" type=\"xs:string\" /> </xs:sequence> </xs:complexType>\n"
                + "<xs:complexType abstract=\"true\" name=\"istanzaBase\"><xs:sequence /></xs:complexType>\n" 
                + "<xs:complexType name=\"iscrizione\"> <xs:complexContent> <xs:extension base=\"istanzaBase\"> <xs:sequence> <xs:element name=\"anno\" type=\"xs:int\" /><xs:element minOccurs=\"0\" name=\"cellulare\" type=\"xs:string\" /><xs:element name=\"dichiarazioniMendaci\" type=\"xs:boolean\" /><xs:element minOccurs=\"0\" name=\"domicilio\" type=\"indirizzo\" /><xs:element minOccurs=\"0\" name=\"email\" type=\"xs:string\" /><xs:element name=\"familyPlus\" type=\"xs:boolean\" /><xs:element minOccurs=\"0\" name=\"importo\" type=\"xs:decimal\" /><xs:element name=\"informativa\" type=\"xs:boolean\" /><xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"minori\" nillable=\"true\" type=\"minore\" /><xs:element name=\"minoriResidentiBolzano\" type=\"xs:boolean\" /><xs:element minOccurs=\"0\" name=\"potestaGenitoriale\" type=\"dominio\" /><xs:element minOccurs=\"0\" name=\"residenza\" type=\"indirizzo\" /><xs:element name=\"ricevutaPagamento\" type=\"xs:boolean\" /><xs:element minOccurs=\"0\" name=\"telefono\" type=\"xs:string\" /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>\n"
                + "<xs:complexType name=\"indirizzo\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"cap\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"civico\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"civicoStrada\" type=\"civico\" /><xs:element minOccurs=\"0\" name=\"comune\" type=\"comune\" /><xs:element minOccurs=\"0\" name=\"via\" type=\"xs:string\" /> </xs:sequence> </xs:complexType>\n" 
                + "<xs:complexType name=\"civico\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"barrato\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codice\" type=\"xs:string\" /><xs:element name=\"numero\" type=\"xs:int\" /><xs:element minOccurs=\"0\" name=\"scala\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"strada\" type=\"strada\" /> </xs:sequence> </xs:complexType>\n" 
                + "<xs:complexType name=\"strada\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"areaDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"areaIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codice\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"descrizioneDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"descrizioneIt\" type=\"xs:string\" /> </xs:sequence> </xs:complexType>\n" 
                + "<xs:complexType name=\"comune\"> <xs:sequence> <xs:element name=\"capoluogo\" type=\"xs:boolean\" /><xs:element minOccurs=\"0\" name=\"codiceIstat\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"dataFine\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"descrizioneDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"descrizioneIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"provincia\" type=\"provincia\" /> </xs:sequence> </xs:complexType>\n"
                + "<xs:complexType name=\"provincia\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"codiceIstat\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"dataFine\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"descrizione\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"siglaAuto\" type=\"xs:string\" /> </xs:sequence> </xs:complexType>\n" + "<xs:complexType name=\"minore\"> <xs:sequence> <xs:element name=\"assistenzaPersonale\" type=\"xs:boolean\" /><xs:element minOccurs=\"0\" name=\"certificatoMedico\" type=\"xs:short\" /><xs:element minOccurs=\"0\" name=\"classe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codiceFiscale\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"cognome\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"dataNascita\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"dieta\" type=\"dominio\" /><xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"malattie\" nillable=\"true\" type=\"dominio\" /><xs:element minOccurs=\"0\" name=\"nome\" type=\"xs:string\" /><xs:element name=\"oreAssistenza\" type=\"xs:int\" /><xs:element minOccurs=\"0\" name=\"scuola\" type=\"scuola\" /><xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"turni\" nillable=\"true\" type=\"turno\" /> </xs:sequence> </xs:complexType>\n"
                + "<xs:complexType name=\"dominio\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"altro\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"codice\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"dataFine\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"descrizioneDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"descrizioneIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"numero\" type=\"xs:decimal\" /> </xs:sequence> </xs:complexType>\n" 
                + "<xs:complexType name=\"scuola\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"civico\" type=\"civico\" /><xs:element minOccurs=\"0\" name=\"codice\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"dataFine\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"descrizioneDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"descrizioneIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"email\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"fax\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"istitutoComprensivo\" type=\"scuola\" /><xs:element minOccurs=\"0\" name=\"lingua\" type=\"lingua\" /><xs:element minOccurs=\"0\" name=\"telefono\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"tipo\" type=\"tipoScuola\" /> </xs:sequence> </xs:complexType>\n"
                + "<xs:complexType name=\"turno\"> <xs:sequence> <xs:element minOccurs=\"0\" name=\"codice\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"daData\" type=\"xs:dateTime\" /><xs:element minOccurs=\"0\" name=\"descrizioneDe\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"descrizioneIt\" type=\"xs:string\" /><xs:element minOccurs=\"0\" name=\"aData\" type=\"xs:dateTime\" /> </xs:sequence> </xs:complexType>\n" 
                + "<xs:simpleType name=\"tipoPersona\"> <xs:restriction base=\"xs:string\"> <xs:enumeration value=\"PersonaFisica\" /><xs:enumeration value=\"PersonaGiuridica\" /> </xs:restriction> </xs:simpleType>\n" 
                + "<xs:simpleType name=\"lingua\"> <xs:restriction base=\"xs:string\"> <xs:enumeration value=\"DE\" /><xs:enumeration value=\"IT\" /> </xs:restriction> </xs:simpleType>\n"
                + "<xs:simpleType name=\"tipoScuola\"> <xs:restriction base=\"xs:string\"> <xs:enumeration value=\"Materna\" /><xs:enumeration value=\"Elementare\" /><xs:enumeration value=\"Media\" /><xs:enumeration value=\"Superiore\" /><xs:enumeration value=\"Musica\" /><xs:enumeration value=\"IstitutoComprensivo\" /> </xs:restriction> </xs:simpleType>\n" 
                + "</xs:schema>"; 

dataSet.readXmlSchema(new ByteArrayInputStream(xsd.getBytes(StandardCharsets.UTF_8 )));

Hi Tahir,

as your documentation says, readXmlSchema should come before readXml. If you change the order of the commands in this way, you should get the error i receive.

I confirm you that if i follow the “wrong order” (xml and then xsd) i get no error, but in this case the xml schema has no effect on the dataset…

Thanks

Simone

Hi Simone,

Thanks for sharing the detail. 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 WORDSJAVA-1158. 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.

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


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

With 15.9.0 now comes this error:

java.lang.IndexOutOfBoundsException: Table ‘iscrizionePdf’: values length (1) should be equal to the DataTable columns count(0)!
at com.aspose.words.net.System.Data.DataRowCollection.add(Unknown Source)

Hi Simone,

Thanks for your inquiry. I have tested the scenario using shared xml and xsd files and have not found the shared issue. I have used the following code to test this scenario. I have attached the xml and xsd files with this post for your kind reference.

DataSet dataSet =   new   DataSet();
String xsd =  ReadAllText ( MyDir  + "input.xsd");
dataSet.readXmlSchema(  new   ByteArrayInputStream(xsd.getBytes(StandardCharsets. UTF_8 )));
dataSet.readXml( MyDir  + "in.xml");
public static String ReadAllText(String filename) throws IOException {
    String s = "";
    InputStreamReader isr = new InputStreamReader(new FileInputStream(filename));
    BufferedReader br = new BufferedReader(isr);
    StringBuilder sb = new StringBuilder(10000);
    while ((s = br.readLine()) != null)
        sb.append(s);
    return sb.toString();
}

Tahir…in the way you propose the xds is not elaborated at all.

If i put on the template this: <<[identita.first().dataDiNascita] :"dd.MM.yyyy">> it is not handled as a date fleld but as as string (even the xsd tells this is a date).

And if i reference a field which is not in the xml but is declared in the xsd
an error occours.

By the way there is this method: DataSet.readXmlSchema(String xmlPath) which seems do do exactly what you were trying to do…but it should not be different as reading it from string…

Hope to recevie fixes as soon as possible, i’m tired to post problem on the forum…and i know that it doesn’t depend on you.

Thanks

Hi Simone,

Thanks for sharing the
detail.

simone.padovan:

If i put on the template this: <<[identita.first().dataDiNascita] :"dd.MM.yyyy">> it is not handled as a date fleld but as as string (even the xsd tells this is a date).

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 WORDSJAVA-1180. 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.

simone.padovan:

By the
way there is this method: DataSet.readXmlSchema(String xmlPath) which
seems do do exactly what you were trying to do…but it should not be
different as reading it from string…

Yes, you can also use overloaded method DataSet.readXmlSchema(String xmlPath)

If i use DataSet.readXmlSchema(String xmlPath) the behaviour is different and the error i’ve reported is thrown.

Simone

Hi Simone,

Thanks for sharing the
detail. 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 WORDSJAVA-1181. 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,

Thanks for your patience.

It is to inform you that our development team has completed the work on the issue (WORDSJAVA-1181)
and has come to a conclusion that this issue and the
undesired behavior you’re observing is actually not a bug in
Aspose.Words. So, we have closed this issue as ‘Not a Bug’.

It seems that the shared xml schema is not valid. .NET DataSet.ReadXmlSchema method also throws exception for your shared schema file.

Hi Tahir,

i’ve validated the xml file against the xsd i’ve shared, with this online tool and it seems ok.

http://www.utilities-online.info/xsdvalidation/?save=b828c054-41ca-408f-a603-dbd9d1135f22-xsdvalidation#.VidTzUazmFU

I’ve generated the xml schema via JAXB directly from the original object.

Could you please tell me what seems to be wrong with it ?

Thanks

Hi Simone,

Thanks for your inquiry. The loading a DataSet from XML in Aspose.Words for Java tries to mimic same behavior as .NET does :
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/dataset-datatable-dataview/loading-a-dataset-from-xml

However, I have logged the shared issue detail in our issue tracking system. We will inform you as soon as there is any update available on this issue.

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


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

No, it’s not been resolved either…Same error occours.
Simone

Hi Simone,

Thanks for your inquiry. We have tested again WORDSJAVA-1180 and have found that this issue has been fixed. Please execute the following code to check this issue. We have attached the input xsd, xml and output Docx with this post for your kind reference.

DataSet dataSet = new DataSet();
dataSet.readXmlSchema(MyDir + "input.xsd");
dataSet.readXml(MyDir + "input.xml");
System.out.println(dataSet.getTables().get("Student").getColumns().get("birthDate").getDataType());
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("<<foreach [s in Student]>>");
builder.writeln("<<[s.birthDate]:”yyy.MM.dd”>>");
builder.writeln("<<[s.Name]>>");
builder.writeln("<</foreach>>");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, dataSet);
doc.save(MyDir + "Out.docx");

Hi Tahir, the problem is that it does not work with my xsd (it’s in the project i’ve attached days ago).

The xml and the xsd i use are correct (i’ve tested them with an online xml tester), but comes an error.