@@ -143,6 +143,22 @@ static void schema_load_file(sdlCtx *ctx, xmlAttrPtr ns, xmlChar *location, xmlA
143143 }
144144}
145145
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+
146162/*
1471632.6.1 xsi:type
1481642.6.2 xsi:nil
@@ -196,15 +212,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
196212 if (location == NULL ) {
197213 soap_error0 (E_ERROR , "Parsing Schema: include has no 'schemaLocation' attribute" );
198214 } 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 );
208216 schema_load_file (ctx , NULL , uri , tns , 0 );
209217 xmlFree (uri );
210218 }
@@ -216,15 +224,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
216224 if (location == NULL ) {
217225 soap_error0 (E_ERROR , "Parsing Schema: redefine has no 'schemaLocation' attribute" );
218226 } 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 );
228228 schema_load_file (ctx , NULL , uri , tns , 0 );
229229 xmlFree (uri );
230230 /* TODO: <redefine> support */
@@ -245,14 +245,7 @@ int load_schema(sdlCtx *ctx, xmlNodePtr schema)
245245 }
246246 }
247247 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 );
256249 }
257250 schema_load_file (ctx , ns , uri , tns , 1 );
258251 if (uri != NULL ) {xmlFree (uri );}
0 commit comments