[jboss-svn-commits] JBL Code SVN: r6233 - in labs/jbossesb/workspace/rearchitecture/product/etc: . validation validation/src validation/src/org validation/src/org/jboss validation/src/org/jboss/soa validation/src/org/jboss/soa/esb validation/src/org/jboss/soa/esb/services validation/src/org/jboss/soa/esb/services/xml

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Sep 14 15:59:44 EDT 2006


Author: arvinder
Date: 2006-09-14 15:59:41 -0400 (Thu, 14 Sep 2006)
New Revision: 6233

Added:
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/build.xml
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/
   labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java
Log:
Initial entry

Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/build.xml
===================================================================

Added: labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java
===================================================================
--- labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java	2006-09-14 18:10:43 UTC (rev 6232)
+++ labs/jbossesb/workspace/rearchitecture/product/etc/validation/src/org/jboss/soa/esb/services/xml/XmlValidation.java	2006-09-14 19:59:41 UTC (rev 6233)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.services.xml;
+
+import org.xml.sax.SAXException;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.validation.Validator;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Schema;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.XMLConstants;
+import java.io.File;
+
+/**
+ * Class Description
+ *
+ * @author $Revision$
+ *         $Id$
+ */
+public class XmlValidation {
+
+    private String xmlFileToValidate = null;
+    private String xsdToValidateAgainst = null;
+
+    public static void main(String[] args) {
+
+    }
+
+    public boolean validate(String xml, String xsd) throws Exception {
+
+        boolean isValid = false;
+        DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        Document document = parser.parse(new File(xml));
+
+        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        Source schemaFile = new StreamSource(new File(xsd));
+        Schema schema = factory.newSchema(schemaFile);
+        Validator validator = schema.newValidator();
+
+        try {
+            validator.validate(new DOMSource(document));
+            isValid = true;
+        } catch (SAXException e) {
+
+        }
+        return isValid;
+    }
+
+
+
+
+
+}




More information about the jboss-svn-commits mailing list