code: public static void makeTransformerFactorySecure (@Nonnull final TransformerFactory aFactory,
                                                     @Nullable final String... aAllowedExternalSchemes)
    {
      ValueEnforcer.notNull (aFactory, "Factory");
  
      try
      {
        aFactory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true);
  
        final String sCombinedSchemes = StringHelper.getImplodedNonEmpty (',', aAllowedExternalSchemes);
        if (sCombinedSchemes.length () > 0)
        {
          aFactory.setAttribute (XMLConstants.ACCESS_EXTERNAL_DTD, sCombinedSchemes);
          aFactory.setAttribute (XMLConstants.ACCESS_EXTERNAL_STYLESHEET, sCombinedSchemes);
          // external schema is unknown
        }
      }
      catch (final TransformerConfigurationException ex)
      {
        throw new InitializationException ("Failed to secure XML TransformerFactory", ex);
      }
    }
docs: Set the secure processing feature to a {@link TransformerFactory}. See
  https://docs.oracle.com/javase/tutorial/jaxp/properties/properties.html for
  details.
  
  @param aFactory
  The factory to secure. May not be <code>null</code>.
  @param aAllowedExternalSchemes
  Optional external URL schemes that are allowed to be accessed (as in
  "file" or "http")
  @since 9.1.2