Quantcast

xmerl_xsd can't find schema

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

xmerl_xsd can't find schema

Matti Oinas
Hi

I'm trying to validate XML using XML schema but
xmer_xsd:process_schema can't find schema in any other folder than the
current pwd().

>xmerl_xsd:process_schema("../include/user.xsd").
{error,enoent}

if I copy the user.xsd file into the folder returned by pwd() which
happens to be src and modify the path to point to that copy the
everything works just fine.

>xmerl_xsd:process_schema("user.xsd").
{ok,{xsd_state,"user.xsd",......

xmerl_scan can find the file in both folders

>xmerl_scan:file("../include/user.xsd").
{{xmlElement,'xs:schema','xs:schema',....
>xmerl_scan:file("user.xsd").
{{xmlElement,'xs:schema','xs:schema',....

It seems to be a bug or then I'm missing some point.

I'm using erlang from arch(32 bit) linux repositories.

Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0]
[hipe] [kernel-poll:false]
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: xmerl_xsd can't find schema

Ahmed Omar
It sounds like a big. xmerl_xsd for some reason will mess up your path.
I think this patch should solve your problem

index e56f147..3085bc7 100644
--- a/lib/xmerl/src/xmerl_xsd.erl
+++ b/lib/xmerl/src/xmerl_xsd.erl
@@ -288,9 +288,9 @@ process_schema(Schema) ->
 %% or a single error encountered during the processing.
 process_schema(Schema,Options) when is_list(Options) ->
     S = initiate_state(Options,Schema),
-    process_schema2(xmerl_scan:file(filename:join(S#xsd_state.xsd_base, Schema)),S,Schema);
+    process_schema2(xmerl_scan:file(filename:join(S#xsd_state.xsd_base, filename:basename(Schema))),S,Schema);
 process_schema(Schema,State) when is_record(State,xsd_state) ->
-    process_schema2(xmerl_scan:file(filename:join(State#xsd_state.xsd_base, Schema)),State,Schema).
+    process_schema2(xmerl_scan:file(filename:join(State#xsd_state.xsd_base, filename:basename(Schema))),State,Schema).
 
 process_schema2(Err={error,_},_,_) ->
     Err;

On Wed, Jun 29, 2011 at 1:22 PM, Matti Oinas <[hidden email]> wrote:
Hi

I'm trying to validate XML using XML schema but
xmer_xsd:process_schema can't find schema in any other folder than the
current pwd().

>xmerl_xsd:process_schema("../include/user.xsd").
{error,enoent}

if I copy the user.xsd file into the folder returned by pwd() which
happens to be src and modify the path to point to that copy the
everything works just fine.

>xmerl_xsd:process_schema("user.xsd").
{ok,{xsd_state,"user.xsd",......

xmerl_scan can find the file in both folders

>xmerl_scan:file("../include/user.xsd").
{{xmlElement,'xs:schema','xs:schema',....
>xmerl_scan:file("user.xsd").
{{xmlElement,'xs:schema','xs:schema',....

It seems to be a bug or then I'm missing some point.

I'm using erlang from arch(32 bit) linux repositories.

Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0]
[hipe] [kernel-poll:false]
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



--
Best Regards,
- Ahmed Omar
Follow me on twitter


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: xmerl_xsd can't find schema

Lars Thorsen
In reply to this post by Matti Oinas

Hi Matti,
I looked through the xmerl_xsd code and it is a bug in process_schema.
I must just check so the calls from xmerl_scan to xmerl_xsd when validating
an xml file works ok with the change.

A workaround while waiting for the fix is:

xmerl_xsd:process_schema(<xsd file without path>, [{xsdbase, <path to schema dir>}]).

There is just one thing that I wonder about, the only case that works for me when I use a path
to the schema is ../dir/file.xsd because ../dir/../dir/file.xsd is the same place.


Regards Lars


On 06/29/2011 01:22 PM, Matti Oinas wrote:

> Hi
>
> I'm trying to validate XML using XML schema but
> xmer_xsd:process_schema can't find schema in any other folder than the
> current pwd().
>
>> xmerl_xsd:process_schema("../include/user.xsd").
> {error,enoent}
>
> if I copy the user.xsd file into the folder returned by pwd() which
> happens to be src and modify the path to point to that copy the
> everything works just fine.
>
>> xmerl_xsd:process_schema("user.xsd").
> {ok,{xsd_state,"user.xsd",......
>
> xmerl_scan can find the file in both folders
>
>> xmerl_scan:file("../include/user.xsd").
> {{xmlElement,'xs:schema','xs:schema',....
>> xmerl_scan:file("user.xsd").
> {{xmlElement,'xs:schema','xs:schema',....
>
> It seems to be a bug or then I'm missing some point.
>
> I'm using erlang from arch(32 bit) linux repositories.
>
> Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0]
> [hipe] [kernel-poll:false]
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...