ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Aston <jeremyas...@yahoo.co.uk>
Subject Re: XMLValidate with schema
Date Thu, 27 May 2004 15:42:54 GMT
This is a very basic example that does work.  I will
work on it to try and get a catalog to work as well.

One thing to note is that Xerces had (and I believe
still contains) a 'feature' that means it can only
validate against the first XSD if more than one
namespace is specfied.  That shafts the whole thing
anyways!  I've tried using jing for multiple xsd
validation but cannot get that to work.

Anyways...

build.xml

<?xml version="1.0" encoding="UTF-8"?>

<project name="validate-test" default="validate">
	
	<target name="validate" description="Validate doc
files">
		<echo>${java.class.path}</echo>
		<xmlvalidate
			failonerror="no"
			lenient="no"
			warn="yes"
			file="test.xml"
			classname="org.apache.xerces.parsers.SAXParser"
			classpath="/java/xalan-j_2_6_0/bin/xercesImpl.jar">
			<attribute
name="http://apache.org/xml/features/validation/schema"
 value="true"/>
		</xmlvalidate>	
	</target>

</project>

test.xml

<?xml version="1.0" encoding="UTF-8"?>
<test xsi:noNamespaceSchemaLocation="schema/test.xsd"
xmlns="" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<aaa/>
</test>


schema/test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="" elementFormDefault="qualified">
	<xs:element name="test">
		<xs:complexType mixed="false">
			<xs:choice>
			<xs:element name="aaa" type="xs:string"/>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>

You will need to change the path the to Xerces and the
xsd is in a sub folder.

Hope that helps start the process of sorting this once
and for all!

Rgds

Jeremy


 --- michael.giroux@objectweb.org wrote: > I have the
same problem, and have the additional
> requirement that I need 
> support for xmlcatalog to allow schema files to be
> located locally.
> 
> 
> Michael Giroux
> 
> 
> 
> 
> "WISE, Jon" <jwise@glos.ac.uk>
> 05/27/2004 05:30 AM
> Please respond to "Ant Users List"
> 
>  
>         To:     <user@ant.apache.org>
>         cc: 
>         Subject:        XMLValidate with schema
> 
> 
> I am finding it difficult to get XMLValidate to
> validate XML against a 
> schema. 
> 
> With many alternative attempts I get either
> 'successful validation' when 
> it there is an error in the xml, or 'element not
> defined' or 'parser 
> doesn't recognize feature
>
http://apache.org/xml/properties/schema/external-schemaLocation'
> 
> Does anyone have a set of files (i.e. build.xml,
> aaa.xml and aaa.xsd) for 
> a simple example to help me on the way? 
> 
> Jon Wise
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>  


	
	
		
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message