code: protected void initDocument(CmsObject cms, Document document, String encoding, CmsXmlContentDefinition definition) {
  
          initDocument(document, encoding, definition);
          // check invalid links
          if (cms != null) {
              // this will remove all invalid links
              getHandler().invalidateBrokenLinks(cms, this);
          }
      }
docs: Initializes an XML document based on the provided document, encoding and content definition.<p>
  
  Checks the links and removes invalid ones in the initialized document.<p>
  
  @param cms the current users OpenCms content
  @param document the base XML document to use for initializing
  @param encoding the encoding to use when marshalling the document later
  @param definition the content definition to use