Thanks for the update C. I guess I'll go with that solution as well. Quoting "Helck, Christopher" <[EMAIL PROTECTED]>:
> I decided to go with a Junit solution. I first tried XMLUnit (which I've > used in the past to diff xml's -- worked like a charm), but gave up > because it doesn't seem to support schemas and I was getting weird > errors. Since I'm using Java 1.5 I used the javax.xml packages. > > I would prefer a maven based solution, but this does the trick for now. > Here's sample code. > > %<---------------------------------------------- > > package com.foobar; > > import java.io.File; > > import javax.xml.XMLConstants; > import javax.xml.transform.Source; > import javax.xml.transform.stream.StreamSource; > import javax.xml.validation.Schema; > import javax.xml.validation.SchemaFactory; > import javax.xml.validation.Validator; > > import junit.framework.Assert; > import junit.framework.Test; > import junit.framework.TestCase; > import junit.framework.TestSuite; > > public class SchemaTest extends AbstractTestCase { > > public SchemaTest(String name) throws Exception { > super(name); > } > > public void testErrors() throws Exception { > validate("xdocs/Foo.xsd", "/conf/ComplexTest.xml"); > } > > public void testSimple() throws Exception { > validate("xdocs/Foo.xsd", "/conf/Simple.xml"); > } > > private void validate(String schemaFileName, String xmlFileName) > throws Exception { > Source xmlSource = new > StreamSource(this.getClass().getResourceAsStream(xmlFileName)); > > SchemaFactory factory = > SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); > Schema schema = factory.newSchema(new > File(getTestFile(schemaFileName))); > Validator validator = schema.newValidator(); > validator.validate(xmlSource); > } > > public static Test suite() { > return new TestSuite(SchemaTest.class); > } > > } > > %<--------------------------------------------------------- > > Regards, > C. Helck > > -----Original Message----- > From: Ben Anderson [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 23, 2004 7:29 AM > To: Maven Users List > Subject: Re: How do I test a schema > > > That's funny - I was trying to do this yesterday, but gave up. You'll > need the validate plugin jar here: > http://jakarta.apache.org/commons/jelly/libs/validate/index.html > I'm not sure where you're supposed to stick these jars. I put it in > $MAVEN_HOME/lib and that worked, but it's probably supposed to go > somewhere else. There's also some documentation there, but no examples. > Here's what I had thus far: > > <goal name="validate"> > <!--we need to create a new java.io.File <u:new ... > <v:verifier var="mySchema" file=".../> > <v:validate var="isValid" verifier="mySchema"> > some xml - possibly importing a file somehow. > </v:validate> > --> > </goal> > > of course this doesn't work. Maybe together we can figure it out. -Ben > > Quoting "Helck, Christopher" <[EMAIL PROTECTED]>: > > > I'd like to automate testing a XML schema under maven, but I don't > > have a clue how to begin :-). I have a schema and some example XML > > files. I'd like to validate the files against the schema. Any help is > > appreciated. > > > > Thanks, > > C. Helck > > > > > > > > > > The information contained in this e-mail is confidential. This e-mail > > is intended only for the stated addressee. If you are not an > > addressee, you must not disclose, copy, circulate or in any other way > > use or rely on the information contained in this e-mail. if you have > > received this e-mail in error, please inform us immediately and delete > > > it and all copies from your system. > > > > EBS Dealing Resources International Limited. Registered address: > > 55-56 Lincoln's Inn Fields, London WC2A 3LJ, United Kingdom. > > Registered number 2633663. > > > > EBS Dealing Resources, Inc, registered in Delaware. Address: 535 > > Madison Avenue, 24th Floor, New York, NY 10022, USA, and One upper > > Pond road, Building F - Floor 3, Parsippany, NJ 07054, USA. > > > > EBS Dealing Resources Japan Limited, a Japanese Corporation. Address: > > Asteer Kayabacho Bldg, 6th Floor, 1-6-1, Shinkawa, Chuo-Ku, Tokyo > > 104-0033, Japan. > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > The information contained in this e-mail is confidential. This e-mail is > intended only for the stated addressee. If you are not an addressee, you > must not disclose, copy, circulate or in any other way use or rely on the > information contained in this e-mail. if you have received this e-mail in > error, please inform us immediately and delete it and all copies from your > system. > > EBS Dealing Resources International Limited. Registered address: 55-56 > Lincoln's Inn Fields, London WC2A 3LJ, United Kingdom. Registered number > 2633663. > > EBS Dealing Resources, Inc, registered in Delaware. Address: 535 Madison > Avenue, 24th Floor, New York, NY 10022, USA, and One upper Pond road, > Building F - Floor 3, Parsippany, NJ 07054, USA. > > EBS Dealing Resources Japan Limited, a Japanese Corporation. Address: Asteer > Kayabacho Bldg, 6th Floor, 1-6-1, Shinkawa, Chuo-Ku, Tokyo 104-0033, Japan. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]