je fais unmarshal pour recuperer les donnes de mon fichier xml mais il me retourne nulle pour une liste de valeurs. Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 package Impex; import java.util.ArrayList; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="impex") public class Impex { private ArrayList<Macro> headmacro; private ArrayList<Operation> operations; private String globalcomment ; public String getGlobalcomment() { return globalcomment; } public void setGlobalcomment(String globalcomment) { this.globalcomment = globalcomment; } public ArrayList<Macro> getHeadmacro() { return headmacro; } @XmlElementWrapper(name = "headmacro") // XmlElement sets the name of the entities in collection @XmlElement(name = "macro") public void setHeadmacro(ArrayList<Macro> headmacro) { this.headmacro = headmacro; } public ArrayList<Operation> getOperations() { return operations; } @XmlElementWrapper(name = "operations") // XmlElement sets the name of the entities in collection @XmlElement(name = "operation") public void setOperations(ArrayList<Operation> operations) { this.operations = operations; } @Override public String toString(){ return(" [headmacro=" + this.getHeadmacro() + ", operations=" + this.getOperations() + ", globcomm=" + this.getGlobalcomment()+"]"); } } package Impex; import java.util.ArrayList; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "operation") public class Operation { @XmlElement(name = "comment") private String commentaire; private Header header; @XmlElementWrapper(name = "datas") // XmlElement sets the name of the entities in collection @XmlElement(name = "enregistrement") ArrayList<Enregistrement> datass; public Operation() { } public String getCommentaire() { return commentaire; } public void setCommentaire(String commentaire) { this.commentaire = commentaire; } public Header getHeader() { return header; } public void setHeader(Header header) { this.header = header; } public ArrayList<Enregistrement> getDatas() { return datass; } @XmlElementWrapper(name = "datas") @XmlElement(name = "enregistrement") public void setDatas(ArrayList<Enregistrement> datas) { this.datass = datas; } @Override public String toString() { return ("Oper [comment=" + this.getCommentaire() + ", header=" + this.getHeader() + ", data=" + this.getDatas() + "]"); } } package Impex; import java.util.ArrayList; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "enregistrement") public class Enregistrement { //@XmlElementWrapper(name = "enregistrement") //@XmlElement(name = "data") private ArrayList<String> enregistrements; // private String comment; public Enregistrement() { } public ArrayList<String> getEnregistrement() { return enregistrements; } @XmlElementWrapper(name = "enregistrement") @XmlElement(name = "data") public void setEnregistrement(ArrayList<String> enregistrements) { this.enregistrements = enregistrements; } @Override public String toString() { return ("enreg [datas=" + this.getEnregistrement() + "]"); } }
Mon fichier xml:
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 <impex> <globalcomment> [y] hybris Platform Copyright (c) 2017 SAP SE or an SAP affiliate company. All rights reserved. This software is the confidential and proprietary information of SAP ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement you entered into with SAP. ----------------------------------------------------------------------- Import the CMS content for the Amds site </globalcomment> <headmacro> <macro> <name>$contentCatalog</name> <value>AMDS-FR_ContentCatalog</value> </macro> <macro> <name>$contentCV</name> <value>catalogVersion(CatalogVersion.catalog(Catalog.id[default=$contentCatalog]),CatalogVersion.version[default=Staged])[default=$contentCatalog:Staged]</value> </macro> <macro> <name>$siteResource</name> <value>jar:com.arcelormittal.amds.ecom.initialdata.constants.AmdsInitialdataConstants/amdsinitialdata/import/sampledata/contentCatalogs/contentCatalog</value> </macro> <macro> <name>$jarResourceCms</name> <value>jar:com.arcelormittal.amds.ecom.initialdata.constants.AmdsInitialdataConstants/amdsinitialdata/import/sampledata/cockpits/cmscockpit</value> </macro> </headmacro> <operations> <operation> <comment> jarResourceCms=jar:com.arcelormittal.amds.ecom.core.constants.AmdsCoreConstants/amdscore/import/cockpits/cmscockpit Create PageTemplates These define the layout for pages "FrontendTemplatename" is used to define the JSP that should be used to render the page for pages with multiple possible layouts. "RestrictedPageTypes" is used to restrict templates to page types </comment> <header> <operationName>INSERT_UPDATE</operationName> <item>PageTemplate</item> <listcolonne> <colonne unique="true">$contentCv</colonne> <colonne unique="true">uid</colonne> <colonne>name</colonne> <colonne>frontendTemplatename</colonne> <colonne>restrictedPageTypes</colonne> <colonne default="true">active</colonne> </listcolonne> </header> <datas> <enregistrement> <data>kk</data> <data></data> <data>ProductDetailsPageTemplate</data> <data>Product Details Page Template</data> <data>product/productLayout3Page</data> <data>ProductPage</data> </enregistrement> <enregistrement> <data>sdzdz</data> <data></data> <data>ProductListPageTemplate</data> <data>Product List Page Template</data> <data>category/productListPage</data> <data>CategoryPage</data> </enregistrement> </datas> </operation> <operation> <comment> Add Velocity templates that are in the CMS Cockpit. These give a better layout for editing pages The FileLoadervalueTranslator loads a File into a String property. The templates could also be inserted in-line in this file. </comment> <header> <operationName>UPDATE</operationName> <item>PageTemplate</item> <listcolonne> <colonne unique="true">contentCv</colonne> <colonne unique="true">uid</colonne> <colonne Translator="de.hybris.platform.commerceservices.impex.impl.FileLoadervalueTranslator">velocityTemplate</colonne> </listcolonne> </header> <datas> <enregistrement> <data>hh</data> <data></data> <data>ProductDetailsPageTemplate</data> <data>jarResourceCms/structure-view/structure_productDetails2PageTemplate.vm</data> </enregistrement> <enregistrement> <data>dd</data> <data>ggg</data> <data>CategoryPageTemplate</data> <data>jarResourceCms/structure-view/structure_categoryPageTemplate.vm</data> </enregistrement> </datas> </operation> </operations> </impex>
et qu on je run j obtiens toutes les valeurs des elements sauf celles des enregistreme
data=[enreg [datas=null]
Partager