[jboss-dev-forums] [Design of POJO Server] - Re: JAXB Deployer
anil.saldhana@jboss.com
do-not-reply at jboss.com
Wed Mar 18 16:40:54 EDT 2009
"alesj" wrote : How would you do this?
Sorry my fault. That is only when you get the marshaller/unmarshaller of JAXB.
| /**
| * Get the JAXB Marshaller
| * @param pkgName The package name for the jaxb context
| * @param schemaLocation location of the schema to validate against
| * @return Marshaller
| * @throws Exception
| */
| public static Marshaller getValidatingMarshaller(String pkgName, String schemaLocation)
| throws Exception
| {
| Marshaller marshaller = getMarshaller(pkgName);
| marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
| //Validate against schema
| ClassLoader tcl = SecurityActions.getContextClassLoader();
| URL schemaURL = tcl.getResource(schemaLocation);
| if(schemaURL == null)
| throw new IllegalStateException("Schema URL is null:" + schemaLocation);
| SchemaFactory scFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
| Schema schema = scFact.newSchema(schemaURL);
| marshaller.setSchema(schema);
|
| return marshaller;
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4219248#4219248
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4219248
More information about the jboss-dev-forums
mailing list