@@ -143,6 +143,22 @@ static void schema_load_file(sdlCtx *ctx, xmlAttrPtr ns, xmlChar *location, xmlA
143
143
}
144
144
}
145
145
146
+ /* Returned uri must be freed by the caller. */
147
+ xmlChar * schema_location_construct_uri (const xmlAttr * attribute )
148
+ {
149
+ xmlChar * uri ;
150
+ xmlChar * base = xmlNodeGetBase (attribute -> doc , attribute -> parent );
151
+
152
+ if (base == NULL ) {
153
+ uri = xmlBuildURI (attribute -> children -> content , attribute -> doc -> URL );
154
+ } else {
155
+ uri = xmlBuildURI (attribute -> children -> content , base );
156
+ xmlFree (base );
157
+ }
158
+
159
+ return uri ;
160
+ }
161
+
146
162
/*
147
163
2.6.1 xsi:type
148
164
2.6.2 xsi:nil
@@ -196,15 +212,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
196
212
if (location == NULL ) {
197
213
soap_error0 (E_ERROR , "Parsing Schema: include has no 'schemaLocation' attribute" );
198
214
} else {
199
- xmlChar * uri ;
200
- xmlChar * base = xmlNodeGetBase (trav -> doc , trav );
201
-
202
- if (base == NULL ) {
203
- uri = xmlBuildURI (location -> children -> content , trav -> doc -> URL );
204
- } else {
205
- uri = xmlBuildURI (location -> children -> content , base );
206
- xmlFree (base );
207
- }
215
+ xmlChar * uri = schema_location_construct_uri (location );
208
216
schema_load_file (ctx , NULL , uri , tns , 0 );
209
217
xmlFree (uri );
210
218
}
@@ -216,15 +224,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
216
224
if (location == NULL ) {
217
225
soap_error0 (E_ERROR , "Parsing Schema: redefine has no 'schemaLocation' attribute" );
218
226
} else {
219
- xmlChar * uri ;
220
- xmlChar * base = xmlNodeGetBase (trav -> doc , trav );
221
-
222
- if (base == NULL ) {
223
- uri = xmlBuildURI (location -> children -> content , trav -> doc -> URL );
224
- } else {
225
- uri = xmlBuildURI (location -> children -> content , base );
226
- xmlFree (base );
227
- }
227
+ xmlChar * uri = schema_location_construct_uri (location );
228
228
schema_load_file (ctx , NULL , uri , tns , 0 );
229
229
xmlFree (uri );
230
230
/* TODO: <redefine> support */
@@ -245,14 +245,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
245
245
}
246
246
}
247
247
if (location ) {
248
- xmlChar * base = xmlNodeGetBase (trav -> doc , trav );
249
-
250
- if (base == NULL ) {
251
- uri = xmlBuildURI (location -> children -> content , trav -> doc -> URL );
252
- } else {
253
- uri = xmlBuildURI (location -> children -> content , base );
254
- xmlFree (base );
255
- }
248
+ uri = schema_location_construct_uri (location );
256
249
}
257
250
schema_load_file (ctx , ns , uri , tns , 1 );
258
251
if (uri != NULL ) {xmlFree (uri );}
0 commit comments