On 7/7/05, Adrian Herscu <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am trying to build a Maven plugin for validating XML. Currently I have
> this code:
>
> <!-- assume ${schema.type.uri} is http://www.w3.org/2001/XMLSchema -->
> <core:set
> var="verifierFactory"
> value=
> "${org.iso_relax.verifier.VerifierFactory.newInstance(schema.type.uri)}" />
I'm reasonably sure the above variable will be null.
> <!-- assume everything in ${file.set} is an XML file -->
> <ant:fileScanner var="fileSet">
> <ant:fileset dir="${file.set}" />
> </ant:fileScanner>
>
> <validate:verifier
> var="verifier"
> factory="${verifierFactory}"
> uri="schema.uri" />
>
> <!-- THIS DOES NOT WORK -- RETURNS AN EMPTY STRING -->
> <echo>Validating using ${verifierFactory.getClass().toString()}</echo>
>
> <core:forEach items="${fileSet.iterator()}" var="file">
> <echo>Validating ${file}</echo>
>
> <validate:validate var="validationResult" verifier="${verifier}">
> <core:include uri="file:///${file}" />
> </validate:validate>
>
> <echo>Validation result: ${validationResult}</echo>
> </core:forEach>
>
> There are several problems with this code:
>
> 1. If the schema file pointed by ${schema.uri} references other schema
> file by using a relative URL, then that URL is resolved relatively to
> the location from where the validation process was started (the path
> from where Maven was launched), instead of being resolved relatively to
> the first schema file location (this is what XML schema validators do --
> checked with MSXML3.0 and with Xerces).
Is that because you are validating the body of the validate tag?
> 2. If the schema instance (i.e. the validated file) contains an
> "xsi:schemaLocation" attribute in its root element then this error is
> thrown:
> <error column="-1" line="-1">unexpected attribute
> "xsi:schemaLocation"</error>
> and the ${validationResult} is set to 'false'.
Is this an issue with the validator or the validate tag?
> 3. If the validation failed once (like in #3), then errors are not
> thrown anymore, only the ${validationResult} is set to 'false'.
I'm not too familiar with the validate tag lib, but maybe you need a
new error handler??
> 4. If <core:include uri="..." /> references a local file path then that
> file path must be prepended with "file:///", otherwise it is prepended
> at run-time with the process launch path. For example:
> - local file path: E:\myxmldir\foo.xml
> - process launch path: E:\myworkdir
> then Jelly will seek for something impossible:
> E:\myworkdir\E:\myxmldir\foo.xml
>
> Thanks a lot for your time,
> Adrian.
--
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]