code: public static Document unmarshalHelper(InputSource source, EntityResolver resolver, boolean validate)
      throws CmsXmlException {
  
          if (null == source) {
              throw new CmsXmlException(Messages.get().container(Messages.ERR_UNMARSHALLING_XML_DOC_1, "source==null!"));
          }
  
          try {
              SAXReader reader = new SAXReader();
              if (resolver != null) {
                  reader.setEntityResolver(resolver);
              }
              reader.setMergeAdjacentText(true);
              reader.setStripWhitespaceText(true);
              if (!validate) {
                  reader.setValidation(false);
                  reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
              } else {
                  reader.setValidation(true);
              }
              return reader.read(source);
          } catch (DocumentException e) {
              String systemId = source != null ? source.getSystemId() : "???";
              throw new CmsXmlException(
                  Messages.get().container(Messages.ERR_UNMARSHALLING_XML_DOC_1, "(systemId = " + systemId + ")"),
                  e);
          } catch (SAXException e) {
              String systemId = source != null ? source.getSystemId() : "???";
              throw new CmsXmlException(
                  Messages.get().container(Messages.ERR_UNMARSHALLING_XML_DOC_1, "(systemId = " + systemId + ")"),
                  e);
          }
      }
docs: Helper to unmarshal (read) xml contents from an input source into a document.<p>
  
  Using this method ensures that the OpenCms XML entity resolver is used.<p>
  
  Important: The encoding provided will NOT be used during unmarshalling,
  the XML parser will do this on the base of the information in the source String.
  The encoding is used for initializing the created instance of the document,
  which means it will be used when marshalling the document again later.<p>
  
  @param source the XML input source to use
  @param resolver the XML entity resolver to use
  @param validate if the reader should try to validate the xml code
  
  @return the unmarshalled XML document
  
  @throws CmsXmlException if something goes wrong