[jelly] Still have schema validation problems

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[jelly] Still have schema validation problems

Adrian Herscu
Hi all (especially Dion),

I have found a validation example here:
http://cvs.apache.org/viewcvs/jakarta-commons/jelly/jelly-tags/validate/src/test/org/apache/commons/jelly/tags/validate/suite.jelly?rev=HEAD

Based on that example I tried this:

  1 <validate:verifier
  2   var="verifier"
  3   uri="myschemapath/foo.xsd" />

  4 <core:catch var="exception">
  5   <validate:assertValid var="validFlag" verifier="${verifier}">
  6     <foo
  7       xsi:schemaLocation="foo_ns myschemapath/foo.xsd"
  8       xmlns="foo_ns"
  9       xmlns:base="base_ns"
10       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
11       <a>blah</a>
12       <base:a>trah</base:a>
13     </foo>
14   </validate:assertValid>
15 </core:catch>

16 <echo>Valid: ${validFlag}</echo>
17 <echo>Exception: ${exception}</echo>

My problems are:
=================
1) Line #7, although valid XML, triggers this exception:
<validate:assertValid> The XML is not valid according to the schema:
error : line: -1 column: -1 message: unexpected attribute
"xsi:schemaLocation"
After deleting line #7 the validation succeeds.

2) Because of the previous problem I cannot use <core:include>, to load
that document. (Or, should I use something else?)

3) The foo.xsd schema imports a base.xsd schema. While using a
standalone schema validator (like MS-XML) the import path is resolved
relatively to myschemapath/. While using the above script, imports are
resolved relatively to the program's launch path -- so the imported
schemas are not found.
After changing the paths of the imported schema to be relative to the
launch path the validation succeeds.

Please help!!!!!

...and thanks for your time,
Adrian.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jelly] Still have schema validation problems

Adrian Herscu
Adrian Herscu wrote:

> Hi all (especially Dion),
>
> I have found a validation example here:
> http://cvs.apache.org/viewcvs/jakarta-commons/jelly/jelly-tags/validate/src/test/org/apache/commons/jelly/tags/validate/suite.jelly?rev=HEAD 
>
>
> Based on that example I tried this:
>
>  1 <validate:verifier
>  2   var="verifier"
>  3   uri="myschemapath/foo.xsd" />
>
>  4 <core:catch var="exception">
>  5   <validate:assertValid var="validFlag" verifier="${verifier}">
>  6     <foo
>  7       xsi:schemaLocation="foo_ns myschemapath/foo.xsd"
>  8       xmlns="foo_ns"
>  9       xmlns:base="base_ns"
> 10       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> 11       <a>blah</a>
> 12       <base:a>trah</base:a>
> 13     </foo>
> 14   </validate:assertValid>
> 15 </core:catch>
>
> 16 <echo>Valid: ${validFlag}</echo>
> 17 <echo>Exception: ${exception}</echo>
>
> My problems are:
> =================
> 1) Line #7, although valid XML, triggers this exception:
> <validate:assertValid> The XML is not valid according to the schema:
> error : line: -1 column: -1 message: unexpected attribute
> "xsi:schemaLocation"
> After deleting line #7 the validation succeeds.
>
> 2) Because of the previous problem I cannot use <core:include>, to load
> that document. (Or, should I use something else?)
>
> 3) The foo.xsd schema imports a base.xsd schema. While using a
> standalone schema validator (like MS-XML) the import path is resolved
> relatively to myschemapath/. While using the above script, imports are
> resolved relatively to the program's launch path -- so the imported
> schemas are not found.
> After changing the paths of the imported schema to be relative to the
> launch path the validation succeeds.

Also checked with MSV like this:

E:\mylaunchpath>java -jar %MSV_HOME%\msv.jar -warning -strict
myschemapath\foo.xsd foo_instance.xml

...and imported schemas are resolved relatively to myschemapath/ (not to
the program launch path).

>
> Please help!!!!!
>
> ...and thanks for your time,
> Adrian.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jelly] Still have schema validation problems

Paul Libbrecht
Adrian,

I have a quick fix: move the namespace declaration of xsi somewhat
above. (e.g. at the jelly element).
(note that outputting such attributes, however, needs the patch of
Diogo at JELLY-213).

This made me, however realize that the following, simpler script yields
the same exception and shows that there's something malfunctioning in
static tags having attributes in a non-empty namespace which explains
some of your issues:
  <j:jelly xmlns:j="jelly:core">
   <foo xmlns:xx="lolo" xx:att2="lala"/>
  </j:jelly>
I filed this as JELLY-214.
Tell us, however, if the quick fix works for you.

thanks

paul




Le 15 juil. 05, à 15:51, Adrian Herscu a écrit :

>>  1 <validate:verifier
>>  2   var="verifier"
>>  3   uri="myschemapath/foo.xsd" />
>>  4 <core:catch var="exception">
>>  5   <validate:assertValid var="validFlag" verifier="${verifier}">
>>  6     <foo
>>  7       xsi:schemaLocation="foo_ns myschemapath/foo.xsd"
>>  8       xmlns="foo_ns"
>>  9       xmlns:base="base_ns"
>> 10       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> 11       <a>blah</a>
>> 12       <base:a>trah</base:a>
>> 13     </foo>
>> 14   </validate:assertValid>
>> 15 </core:catch>
>> 16 <echo>Valid: ${validFlag}</echo>
>> 17 <echo>Exception: ${exception}</echo>
>> My problems are:
>> =================
>> 1) Line #7, although valid XML, triggers this exception:
>> <validate:assertValid> The XML is not valid according to the schema:
>> error : line: -1 column: -1 message: unexpected attribute
>> "xsi:schemaLocation"
>> After deleting line #7 the validation succeeds.
>> 2) Because of the previous problem I cannot use <core:include>, to
>> load that document. (Or, should I use something else?)
>> 3) The foo.xsd schema imports a base.xsd schema. While using a
>> standalone schema validator (like MS-XML) the import path is resolved
>> relatively to myschemapath/. While using the above script, imports
>> are resolved relatively to the program's launch path -- so the
>> imported schemas are not found.
>> After changing the paths of the imported schema to be relative to the
>> launch path the validation succeeds.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jelly] Still have schema validation problems

Adrian Herscu
Thanks for your reply, Paul.
Moving the xsi namespace declaration will not help me -- I need to load
those XML documents and validate them at build time.

I tried to use the parse tag:
<jxml:parse var="classDocument" xml="${classFileURL}" />
<core:set var="validFlag" value="${classVerifier.verify(classDocument)}" />

this provides an workaround for the xsi problem.

Still, this does not solve problem #3 -- the schema import path is
resolved relatively to the program launch path :-(

Thanks for your help,
Adrian.


Paul Libbrecht wrote:

> Adrian,
>
> I have a quick fix: move the namespace declaration of xsi somewhat
> above. (e.g. at the jelly element).
> (note that outputting such attributes, however, needs the patch of Diogo
> at JELLY-213).
>
> This made me, however realize that the following, simpler script yields
> the same exception and shows that there's something malfunctioning in
> static tags having attributes in a non-empty namespace which explains
> some of your issues:
>  <j:jelly xmlns:j="jelly:core">
>   <foo xmlns:xx="lolo" xx:att2="lala"/>
>  </j:jelly>
> I filed this as JELLY-214.
> Tell us, however, if the quick fix works for you.
>
> thanks
>
> paul
>
>
>
>
> Le 15 juil. 05, ? 15:51, Adrian Herscu a ?crit :
>
>>>  1 <validate:verifier
>>>  2   var="verifier"
>>>  3   uri="myschemapath/foo.xsd" />
>>>  4 <core:catch var="exception">
>>>  5   <validate:assertValid var="validFlag" verifier="${verifier}">
>>>  6     <foo
>>>  7       xsi:schemaLocation="foo_ns myschemapath/foo.xsd"
>>>  8       xmlns="foo_ns"
>>>  9       xmlns:base="base_ns"
>>> 10       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>> 11       <a>blah</a>
>>> 12       <base:a>trah</base:a>
>>> 13     </foo>
>>> 14   </validate:assertValid>
>>> 15 </core:catch>
>>> 16 <echo>Valid: ${validFlag}</echo>
>>> 17 <echo>Exception: ${exception}</echo>
>>> My problems are:
>>> =================
>>> 1) Line #7, although valid XML, triggers this exception:
>>> <validate:assertValid> The XML is not valid according to the schema:
>>> error : line: -1 column: -1 message: unexpected attribute
>>> "xsi:schemaLocation"
>>> After deleting line #7 the validation succeeds.
>>> 2) Because of the previous problem I cannot use <core:include>, to
>>> load that document. (Or, should I use something else?)
>>> 3) The foo.xsd schema imports a base.xsd schema. While using a
>>> standalone schema validator (like MS-XML) the import path is resolved
>>> relatively to myschemapath/. While using the above script, imports
>>> are resolved relatively to the program's launch path -- so the
>>> imported schemas are not found.
>>> After changing the paths of the imported schema to be relative to the
>>> launch path the validation succeeds.
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jelly] Still have schema validation problems

Adrian Herscu
Paul, any news about these issues?

Adrian Herscu wrote:

> Thanks for your reply, Paul.
> Moving the xsi namespace declaration will not help me -- I need to load
> those XML documents and validate them at build time.
>
> I tried to use the parse tag:
> <jxml:parse var="classDocument" xml="${classFileURL}" />
> <core:set var="validFlag" value="${classVerifier.verify(classDocument)}" />
>
> this provides an workaround for the xsi problem.
>
> Still, this does not solve problem #3 -- the schema import path is
> resolved relatively to the program launch path :-(
>
> Thanks for your help,
> Adrian.
>
>
> Paul Libbrecht wrote:
>
>> Adrian,
>>
>> I have a quick fix: move the namespace declaration of xsi somewhat
>> above. (e.g. at the jelly element).
>> (note that outputting such attributes, however, needs the patch of
>> Diogo at JELLY-213).
>>
>> This made me, however realize that the following, simpler script
>> yields the same exception and shows that there's something
>> malfunctioning in static tags having attributes in a non-empty
>> namespace which explains some of your issues:
>>  <j:jelly xmlns:j="jelly:core">
>>   <foo xmlns:xx="lolo" xx:att2="lala"/>
>>  </j:jelly>
>> I filed this as JELLY-214.
>> Tell us, however, if the quick fix works for you.
>>
>> thanks
>>
>> paul
>>
>>
>>
>>
>> Le 15 juil. 05, ? 15:51, Adrian Herscu a ?crit :
>>
>>>>  1 <validate:verifier
>>>>  2   var="verifier"
>>>>  3   uri="myschemapath/foo.xsd" />
>>>>  4 <core:catch var="exception">
>>>>  5   <validate:assertValid var="validFlag" verifier="${verifier}">
>>>>  6     <foo
>>>>  7       xsi:schemaLocation="foo_ns myschemapath/foo.xsd"
>>>>  8       xmlns="foo_ns"
>>>>  9       xmlns:base="base_ns"
>>>> 10       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>>> 11       <a>blah</a>
>>>> 12       <base:a>trah</base:a>
>>>> 13     </foo>
>>>> 14   </validate:assertValid>
>>>> 15 </core:catch>
>>>> 16 <echo>Valid: ${validFlag}</echo>
>>>> 17 <echo>Exception: ${exception}</echo>
>>>> My problems are:
>>>> =================
>>>> 1) Line #7, although valid XML, triggers this exception:
>>>> <validate:assertValid> The XML is not valid according to the schema:
>>>> error : line: -1 column: -1 message: unexpected attribute
>>>> "xsi:schemaLocation"
>>>> After deleting line #7 the validation succeeds.
>>>> 2) Because of the previous problem I cannot use <core:include>, to
>>>> load that document. (Or, should I use something else?)
>>>> 3) The foo.xsd schema imports a base.xsd schema. While using a
>>>> standalone schema validator (like MS-XML) the import path is
>>>> resolved relatively to myschemapath/. While using the above script,
>>>> imports are resolved relatively to the program's launch path -- so
>>>> the imported schemas are not found.
>>>> After changing the paths of the imported schema to be relative to
>>>> the launch path the validation succeeds.
>>
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]