Statically initialize the XSLT templates that are cached for all future transforms.

@return the XSLT Templates.
186003
private static Templates initTemplates() {
		try {
			URL xsltURL = ThemeUtil.class.getResource(RESOURCE_NAME);
			if (xsltURL != null) {
				Source xsltSource = new StreamSource(xsltURL.openStream(), xsltURL.toExternalForm());
				TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl();
				Templates templates = factory.newTemplates(xsltSource);
				LOG.debug("Generated XSLT templates for: " + RESOURCE_NAME);
				return templates;
			} else {
				// Server-side XSLT enabled but theme resource not on classpath.
				throw new IllegalStateException(RESOURCE_NAME + " not on classpath");
			}
		} catch (IOException | TransformerConfigurationException ex) {
			throw new SystemException("Could not create transformer for " + RESOURCE_NAME, ex);
		}
	}
970674
public Iterable<SimpleXmlNode> getDescendents() {
    return new Iterable<SimpleXmlNode>() {
      @Override
      public Iterator<SimpleXmlNode> iterator() {
        return new DescendentsIterator(SimpleXmlNode.this);
      }
    };
  }
201327
@Override
	public Set<T> getAllChildNodes() {

		Set<T> allChildNodes = new HashSet();

		List<T> childNodes = treeGetChildren();

		for (final T child : childNodes) {

			allChildNodes.add(child);

			if (child instanceof LinkedTreeNode) {

				final LinkedTreeNode treeNode = (LinkedTreeNode)child;
				allChildNodes.addAll(treeNode.getAllChildNodes());
			}
		}

		return allChildNodes;
	}
268460
public void setTemplate(ElemTemplate template)
  {
    XPath matchXPath = template.getMatch();
    
    if (null == template.getName() && null == matchXPath)
    {  
      template.error(XSLTErrorResources.ER_NEED_NAME_OR_MATCH_ATTRIB,
          new Object[]{ "xsl:template" });
    }
    
    if (null != template.getName())
    {
      ElemTemplate existingTemplate = (ElemTemplate) m_namedTemplates.get(template.getName());
      if (null == existingTemplate)
      {
        m_namedTemplates.put(template.getName(), template);
      }
      else
      {
        int existingPrecedence =
                        existingTemplate.getStylesheetComposed().getImportCountComposed();
        int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
        if (newPrecedence > existingPrecedence)
        {
          // This should never happen
          m_namedTemplates.put(template.getName(), template);
        }
        else if (newPrecedence == existingPrecedence)
          template.error(XSLTErrorResources.ER_DUPLICATE_NAMED_TEMPLATE,
                       new Object[]{ template.getName() });
      }
    }

    

    if (null != matchXPath)
    {
      Expression matchExpr = matchXPath.getExpression();

      if (matchExpr instanceof StepPattern)
      {
        insertPatternInTable((StepPattern) matchExpr, template);
      }
      else if (matchExpr instanceof UnionPattern)
      {
        UnionPattern upat = (UnionPattern) matchExpr;
        StepPattern[] pats = upat.getPatterns();
        int n = pats.length;

        for (int i = 0; i < n; i++)
        {
          insertPatternInTable(pats[i], template);
        }
      }
      else
      {

        // TODO: assert error
      }
    }
  }
1120770
private List getTemplates() {

        ArrayList ret = new ArrayList();
        TreeMap templates = null;

        try {
            templates = CmsNewResourceXmlPage.getTemplates(getJsp().getCmsObject(), null);

            // loop through all templates and build the entries
            Iterator i = templates.entrySet().iterator();
            while (i.hasNext()) {
                Map.Entry entry = (Map.Entry)i.next();
                String title = (String)entry.getKey();
                String path = (String)entry.getValue();

                ret.add(new CmsSelectWidgetOption(path, false, title));
            }
        } catch (CmsException e) {
            // not necessary
        }

        return ret;
    }
147001
public function init()
    {
        $xf = new XsltFilter();
        $chain = new FilterChain($this->getProject());
        $chain->addXsltFilter($xf);
        $this->addFilterChain($chain);
        $this->xsltFilter = $xf;
    }
1165274
public Collection<ComponentBuilder> getComponentBuilders() {
        final Collection<ComponentBuilder> result = new ArrayList<>();
        result.addAll(_filterComponentBuilders);
        result.addAll(_transformerComponentBuilders);
        result.addAll(_analyzerComponentBuilders);
        return result;
    }
709918
protected function getTemplates()
    {
        if (empty($this->templates)) {
            $this->templates[] = $this->environment->loadTemplate($this::DEFAULT_TEMPLATE);
        }

        return $this->templates;
    }
267379
public Attributes<Entity<T>> getOrCreateAttributes()
   {
      Node node = childNode.getOrCreate("attributes");
      Attributes<Entity<T>> attributes = new AttributesImpl<Entity<T>>(this, "attributes", childNode, node);
      return attributes;
   }
327319
public ImmutableList<TemplateMetadata> getTemplates(CallNode node) {
    if (node instanceof CallBasicNode) {
      String calleeName = ((CallBasicNode) node).getCalleeName();
      TemplateMetadata template = basicTemplatesOrElementsMap.get(calleeName);
      return template == null ? ImmutableList.of() : ImmutableList.of(template);
    } else {
      String calleeName = ((CallDelegateNode) node).getDelCalleeName();
      return delTemplateSelector.delTemplateNameToValues().get(calleeName);
    }
  }
1322306
protected Set<String> findTemplateNames() {
    final Set<String> results = new HashSet<String>();
    if (templatePrimaryDir == null) {
      return results;
    }
    templatePrimaryDir.listFiles(
        new FileFilter() {

          @Override
          public boolean accept(File file) {
            if (file.isFile()) {
              String name = file.getName();
              if (!name.equals(Constants.SELECT_BY_ID_SQL_TEMPLATE)
                  && !name.equals(Constants.SELECT_BY_ID_AND_VERSION_SQL_TEMPLATE)) {
                if (name.endsWith(Constants.SQL_TEMPLATE_EXTENSION)) {
                  results.add(name);
                }
              }
            }
            return false;
          }
        });
    return results;
  }
983875
function xsltChildNodes(input, template, output) {
  // Clone input context to keep variables declared here local to the
  // siblings of the children.
  var context = input.clone();
  for (var i = 0; i < template.childNodes.length; ++i) {
    xsltProcessContext(context, template.childNodes[i], output);
  }
}
896379
public function getTemplates()
    {
        $templates = SSViewer::get_templates_by_class($this, '', __CLASS__);
        // Prefer any custom template
        if ($this->getTemplate()) {
            array_unshift($templates, $this->getTemplate());
        }
        return $templates;
    }
1269818
public java.util.List<LaunchTemplate> getLaunchTemplates() {
        if (launchTemplates == null) {
            launchTemplates = new com.amazonaws.internal.SdkInternalList<LaunchTemplate>();
        }
        return launchTemplates;
    }
1034086
@SuppressWarnings("unchecked")
    public TemplateWrapper[] getKnownTemplates() {
        if (mTemplateOrdering == null) {
            setTemplateOrdering("name");
        }

        Comparator<TemplateWrapper> comparator = 
            BeanComparator.forClass(TemplateWrapper.class).orderBy("name");
        Set<TemplateWrapper> known = new TreeSet<TemplateWrapper>(comparator);

        TemplateLoader.Template[] loaded = mTeaServletEngine
            .getTemplateSource().getLoadedTemplates();

        if (loaded != null) {
            for (int j = 0; j < loaded.length; j++) {
                TeaServletAdmin.TemplateWrapper wrapper =
                    new TemplateWrapper(loaded[j], TeaServletInvocationStats.getInstance()
                        .getStatistics(loaded[j].getName(), null), TeaServletInvocationStats.getInstance()
                        .getStatistics(loaded[j].getName(), "__substitution"),
                        TeaServletRequestStats.getInstance().getStats(loaded[j].getName()));

                try {
                    known.add(wrapper);
                } catch (ClassCastException cce) {
                    mTeaServletEngine.getLog().warn(cce);
                }
            }
        }

        String[] allNames = mTeaServletEngine.getTemplateSource()
            .getKnownTemplateNames();
        if (allNames != null) {
            for (int j = 0; j < allNames.length; j++) {
                TeaServletAdmin.TemplateWrapper wrapper =
                    new TemplateWrapper(allNames[j], TeaServletInvocationStats.getInstance()
                        .getStatistics(allNames[j], null), TeaServletInvocationStats.getInstance()
                        .getStatistics(allNames[j], "__substitution"),
                        TeaServletRequestStats.getInstance().getStats(allNames[j]));
                try {
                    known.add(wrapper);
                } catch (ClassCastException cce) {
                    mTeaServletEngine.getLog().warn(cce);
                }
            }
        }

        List<TemplateWrapper> v = new ArrayList<TemplateWrapper>(known);
        
        Collections.sort(v, mTemplateOrdering);
        
//        return (TeaServletAdmin.TemplateWrapper[])known.toArray(new TemplateWrapper[known.size()]);
        return v.toArray(new TemplateWrapper[v.size()]);
    }
435149
public XMLFilter newXMLFilter(Templates templates)
          throws TransformerConfigurationException
  {
    try 
    {
      return new TrAXFilter(templates);
    } 
    catch( TransformerConfigurationException ex ) 
    {
      if( m_errorListener != null) 
      {
        try 
        {
          m_errorListener.fatalError( ex );
          return null;
        } 
        catch( TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        }
        catch( TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException(ex1);
        }
      }
      throw ex;
    }
  }
253833
private StringBuilder getXSLTBase() {
        StringBuilder result = new StringBuilder(XML_DECLARATION)
            .append(XMLUnit.getXSLTStart());
        String tmp = result.toString();
        int close = tmp.lastIndexOf('>');
        if (close == -1) {
            close = tmp.length();
        }
        result.insert(close, getNamespaceDeclarations());
        return result;
    }