Snippet: validating xml with xsd in Java

     
import java.io.Reader;
import java.io.StringReader;


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 org.springframework.core.io.ClassPathResource;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.xml.sax.SAXException;


....


String xmlFormated = "";
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

       ClassPathResource cpr = new ClassPathResource("my_xsd_file.xsd");
       Source schemaFile = new StreamSource( cpr.getFile()  );
       Schema schema = factory.newSchema(schemaFile);

       Validator validator = schema.newValidator();
       Reader reader = new StringReader(xmlFormated);
       Source source = new StreamSource(reader);


       try {
           validator.validate(source);
       } catch (SAXException e) {
        log.error(e);
       }


...

How to see maven modules as projects in Eclipse Package Explorer

When a user, not project's creator, downloads a maven project with modules inside. He/She sees a project that contains all modules. To get all modules as projects you can follow these tutorial:

1.- Download parent project
2.- On File menu, select import > Maven > Existing Maven Projects
3.- Push next
4.- Browse to downloaded project in Root Directory select list.
5.- Check pom.xml files listed below
6.- Push Finish

Now you can see the parent maven project and all modules as projects. All modules are synchronized with parent project.

Jasypt: Encryption on Java

Jasypt is a java library which allows the developer to add basic encryption capabilities to his/her projects with minimum effort, and without the need of having deep knowledge on how cryptography works.

  • High-security, standards-based encryption techniques, both for unidirectional and bidirectional encryption. Encrypt passwords, texts, numbers, binaries...
  • Transparent integration with Hibernate.
  • Suitable for integration into Spring-based applications and also transparently integrable with Spring Security.
  • Integrated capabilities for encrypting the configuration of applications (i.e. datasources).
  • Specific features for high-performance encryption in multi-processor/multi-core systems.
  • Open API for use with any JCE provider.

Copied from: http://www.jasypt.org
Adrià, I hope this help you in near future. And is Licensed under Apache Software License.