geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r1161623 - /geronimo/bundles/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java
Date Thu, 25 Aug 2011 16:12:53 GMT
Author: genspring
Date: Thu Aug 25 16:12:53 2011
New Revision: 1161623

URL: http://svn.apache.org/viewvc?rev=1161623&view=rev
Log:
addming the missed staic getSchema method

Modified:
    geronimo/bundles/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java

Modified: geronimo/bundles/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java?rev=1161623&r1=1161622&r2=1161623&view=diff
==============================================================================
--- geronimo/bundles/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java
(original)
+++ geronimo/bundles/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java
Thu Aug 25 16:12:53 2011
@@ -141,6 +141,22 @@ public class ValidationParser {
         }
     }
 
+    /**
+     * Get a Schema object from the specified resource name.
+     * @param xsd
+     * @return {@link Schema}
+     */
+    static Schema getSchema(String xsd) {
+        ClassLoader loader = PrivilegedActions.getClassLoader(ValidationParser.class);
+        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        URL schemaUrl = loader.getResource(xsd);
+        try {
+            return sf.newSchema(schemaUrl);
+        } catch (SAXException e) {
+            log.warn("Unable to parse schema: " + xsd, e);
+            return null;
+        }
+    }
 
     private void applyConfig(ValidationConfigType xmlConfig, ConfigurationImpl targetConfig)
{
         applyProviderClass(xmlConfig, targetConfig);



Mime
View raw message