Creates a new Transformer instance using cached XSLT Templates. There will be one cached template. Transformer
instances are not thread-safe and cannot be reused (they can after the transformation is complete).

@return A new Transformer instance.
775086
private static Transformer newTransformer() {

		if (TEMPLATES == null) {
			throw new IllegalStateException("TransformXMLInterceptor not initialized.");
		}

		try {
			return TEMPLATES.newTransformer();
		} catch (TransformerConfigurationException ex) {
			throw new SystemException("Could not create transformer for " + RESOURCE_NAME, ex);
		}
	}
890286
public function getXmlMapperInstance()
    {
        if (!isset($this->_xmlMapper)) {
            $this->_xmlMapper = new XmlMapper($this->_getXmlConfigDriver());
        }
        return $this->_xmlMapper;
    }
1157819
public Basic<EmbeddableAttributes<T>> getOrCreateBasic()
   {
      List<Node> nodeList = childNode.get("basic");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new BasicImpl<EmbeddableAttributes<T>>(this, "basic", childNode, nodeList.get(0));
      }
      return createBasic();
   }
151186
public OneToOne<EmbeddableAttributes<T>> getOrCreateOneToOne()
   {
      List<Node> nodeList = childNode.get("one-to-one");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new OneToOneImpl<EmbeddableAttributes<T>>(this, "one-to-one", childNode, nodeList.get(0));
      }
      return createOneToOne();
   }
1187612
public FacesConfigRendererType<FacesConfigRenderKitType<T>> getOrCreateRenderer()
   {
      List<Node> nodeList = childNode.get("renderer");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigRendererTypeImpl<FacesConfigRenderKitType<T>>(this, "renderer", childNode, nodeList.get(0));
      }
      return createRenderer();
   }
1139339
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ XMLEventReader.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return XMLEventReader.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
                                  (ContentHandle<C>) new XMLEventReaderHandle() : null;
        return handle;
      }
    };
  }
1112431
public static @Extension ContentMappings newInstance() throws IOException {
        ContentMappings mappings = Persistence.load(ContentMappings.class);
        if (mappings == null) {
            mappings = (ContentMappings) new XmlProxy().readResolve();
        }
        return mappings;
    }
691445
@Override
    public final Transformer getTransformer(
            HttpServletRequest request, HttpServletResponse response) {
        final Resource stylesheetResource = this.getStylesheetResource(request);
        try {
            return this.xmlUtilities.getTransformer(stylesheetResource);
        } catch (TransformerConfigurationException e) {
            throw new RuntimeException(
                    "Failed to get Transformer for stylesheet: " + stylesheetResource, e);
        } catch (IOException e) {
            throw new RuntimeException("Failed to load stylesheet: " + stylesheetResource, e);
        }
    }
77020
@XmlElementDecl(namespace = "http://www.opengis.net/gml", name = "transformationRef")
    public JAXBElement<TransformationRefType> createTransformationRef(TransformationRefType value) {
        return new JAXBElement<TransformationRefType>(_TransformationRef_QNAME, TransformationRefType.class, null, value);
    }
481485
public static <T> T createInstanceByElement(XMLStreamReader reader, Class<T> clazz, Set<String> attrNames) {
        if (reader == null || clazz == null || attrNames == null)
            return null;

        try {
            T instance = clazz.newInstance();

            int count = reader.getAttributeCount();
            int matchCount = attrNames.size();

            for (int i = 0; i < count && matchCount > 0; ++i) {
                String name = reader.getAttributeLocalName(i);
                String value = reader.getAttributeValue(i);

                if (attrNames.contains(name)) {
                    Field field = clazz.getDeclaredField(name);
                    field.setAccessible(true);
                    field.set(instance, value);
                    matchCount--;
                }
            }
            return instance;
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (SecurityException e) {
            throw new RuntimeException(e);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
    }
1091198
public static DocumentBuilder createDocumentBuilder()
	{
		try
		{
			DocumentBuilderFactory factory = DOCUMENT_BUILDER_FACTORY.get();

			if (factory == null)
			{
				factory = createDocumentBuilderFactory();

				DOCUMENT_BUILDER_FACTORY = new SoftReference<>(factory);
			}

			return factory.newDocumentBuilder();
		}
		catch (ParserConfigurationException e)
		{
			throw new RuntimeException("Error creating DocumentBuilder: " + e.getMessage(), e);
		}
	}
1252079
public FacesConfigComponentType<FacesConfigType<T>> getOrCreateComponent()
   {
      List<Node> nodeList = childNode.get("component");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigComponentTypeImpl<FacesConfigType<T>>(this, "component", childNode, nodeList.get(0));
      }
      return createComponent();
   }
1068418
public void execute(
          TransformerImpl transformer)
            throws TransformerException
  {

    if (transformer.isRecursiveAttrSet(this))
    {
      throw new TransformerException(
        XSLMessages.createMessage(
          XSLTErrorResources.ER_XSLATTRSET_USED_ITSELF,
          new Object[]{ m_qname.getLocalPart() }));  //"xsl:attribute-set '"+m_qname.m_localpart+
    }

    transformer.pushElemAttributeSet(this);
    super.execute(transformer);

    ElemAttribute attr = (ElemAttribute) getFirstChildElem();

    while (null != attr)
    {
      attr.execute(transformer);

      attr = (ElemAttribute) attr.getNextSiblingElem();
    }

    transformer.popElemAttributeSet();
  }
948285
public static JusFragment newInstance() {
		JusFragment fragment = new JusFragment();
		Bundle args = new Bundle();
		fragment.setArguments(args);
		return fragment;
	}
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;
   }
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;
    }
  }
111554
public void transformSelectedNodes(TransformerImpl transformer)
            throws TransformerException
  {

    final XPathContext xctxt = transformer.getXPathContext();
    final int sourceNode = xctxt.getCurrentNode();
    DTMIterator sourceNodes = m_selectExpression.asIterator(xctxt, sourceNode);
    VariableStack vars = xctxt.getVarStack();
    int nParams = getParamElemCount();
    int thisframe = vars.getStackFrame();

    boolean pushContextNodeListFlag = false;
      
    try
    {

            xctxt.pushCurrentNode(DTM.NULL);
            xctxt.pushCurrentExpressionNode(DTM.NULL);
            xctxt.pushSAXLocatorNull();
            transformer.pushElemTemplateElement(null);
      final Vector keys = (m_sortElems == null)
                          ? null
                          : transformer.processSortKeys(this, sourceNode);

      // Sort if we need to.
      if (null != keys)
        sourceNodes = sortNodes(xctxt, keys, sourceNodes);
            
      final SerializationHandler rth = transformer.getSerializationHandler();
//      ContentHandler chandler = rth.getContentHandler();
      final StylesheetRoot sroot = transformer.getStylesheet();
      final TemplateList tl = sroot.getTemplateListComposed();
      final boolean quiet = transformer.getQuietConflictWarnings();
      
      // Should be able to get this from the iterator but there must be a bug.
      DTM dtm = xctxt.getDTM(sourceNode);
      
      int argsFrame = -1;
      if(nParams > 0)
      {
        // This code will create a section on the stack that is all the 
        // evaluated arguments.  These will be copied into the real params 
        // section of each called template.
        argsFrame = vars.link(nParams);
        vars.setStackFrame(thisframe);
        
        for (int i = 0; i < nParams; i++) 
        {
          ElemWithParam ewp = m_paramElems[i];
          XObject obj = ewp.getValue(transformer, sourceNode);

          vars.setLocalVariable(i, obj, argsFrame);
        }
        vars.setStackFrame(argsFrame);
      }
      
      xctxt.pushContextNodeList(sourceNodes);
      pushContextNodeListFlag = true;
      
      IntStack currentNodes = xctxt.getCurrentNodeStack();
      
      IntStack currentExpressionNodes = xctxt.getCurrentExpressionNodeStack();     
      
      // pushParams(transformer, xctxt);
      
      int child;
      while (DTM.NULL != (child = sourceNodes.nextNode()))
      {
        currentNodes.setTop(child);
        currentExpressionNodes.setTop(child);

        if(xctxt.getDTM(child) != dtm)
        {
          dtm = xctxt.getDTM(child);
        }
        
        final int exNodeType = dtm.getExpandedTypeID(child);

        final int nodeType = dtm.getNodeType(child);

        final QName mode = transformer.getMode();

        ElemTemplate template = tl.getTemplateFast(xctxt, child, exNodeType, mode, 
                                      -1, quiet, dtm);

        // If that didn't locate a node, fall back to a default template rule.
        // See http://www.w3.org/TR/xslt#built-in-rule.
        if (null == template)
        {
          switch (nodeType)
          {
          case DTM.DOCUMENT_FRAGMENT_NODE :
          case DTM.ELEMENT_NODE :
            template = sroot.getDefaultRule();
            // %OPT% direct faster?
            break;
          case DTM.ATTRIBUTE_NODE :
          case DTM.CDATA_SECTION_NODE :
          case DTM.TEXT_NODE :
            // if(rth.m_elemIsPending || rth.m_docPending)
            //  rth.flushPending(true);
            transformer.pushPairCurrentMatched(sroot.getDefaultTextRule(), child);
            transformer.setCurrentElement(sroot.getDefaultTextRule());
            // dtm.dispatchCharactersEvents(child, chandler, false);
            dtm.dispatchCharactersEvents(child, rth, false);
            transformer.popCurrentMatched();
            continue;
          case DTM.DOCUMENT_NODE :
            template = sroot.getDefaultRootRule();
            break;
          default :

            // No default rules for processing instructions and the like.
            continue;
          }
        }
        else
        {
        	transformer.setCurrentElement(template);
        }
                
        transformer.pushPairCurrentMatched(template, child);

        int currentFrameBottom;  // See comment with unlink, below
        if(template.m_frameSize > 0)
        {
          xctxt.pushRTFContext();
          currentFrameBottom = vars.getStackFrame();  // See comment with unlink, below
          vars.link(template.m_frameSize);
          // You can't do the check for nParams here, otherwise the 
          // xsl:params might not be nulled.
          if(/* nParams > 0 && */ template.m_inArgsSize > 0)
          {
            int paramIndex = 0;
            for (ElemTemplateElement elem = template.getFirstChildElem(); 
                 null != elem; elem = elem.getNextSiblingElem()) 
            {
              if(Constants.ELEMNAME_PARAMVARIABLE == elem.getXSLToken())
              {
                ElemParam ep = (ElemParam)elem;
                
                int i;
                for (i = 0; i < nParams; i++) 
                {
                  ElemWithParam ewp = m_paramElems[i];
                  if(ewp.m_qnameID == ep.m_qnameID)
                  {
                    XObject obj = vars.getLocalVariable(i, argsFrame);
                    vars.setLocalVariable(paramIndex, obj);
                    break;
                  }
                }
                if(i == nParams)
                  vars.setLocalVariable(paramIndex, null);
              }
              else
                break;
              paramIndex++;
            }
            
          }
        }
        else
        	currentFrameBottom = 0;

        // And execute the child templates.
        // Loop through the children of the template, calling execute on 
        // each of them.
        for (ElemTemplateElement t = template.m_firstChild; 
             t != null; t = t.m_nextSibling)
        {
          xctxt.setSAXLocator(t);
          try
          {
          	transformer.pushElemTemplateElement(t);
          	t.execute(transformer);
          }
          finally
          {
          	transformer.popElemTemplateElement();
          }
        }
        
        if(template.m_frameSize > 0)
        {
          // See Frank Weiss bug around 03/19/2002 (no Bugzilla report yet).
          // While unlink will restore to the proper place, the real position 
          // may have been changed for xsl:with-param, so that variables 
          // can be accessed.  
          // of right now.
          // More:
          // When we entered this function, the current 
          // frame buffer (cfb) index in the variable stack may 
          // have been manually set.  If we just call 
          // unlink(), however, it will restore the cfb to the 
          // previous link index from the link stack, rather than 
          // the manually set cfb.  So, 
          // the only safe solution is to restore it back 
          // to the same position it was on entry, since we're 
          // really not working in a stack context here. (Bug4218)
          vars.unlink(currentFrameBottom);
          xctxt.popRTFContext();
        }
          
        transformer.popCurrentMatched();
        
      } // end while (DTM.NULL != (child = sourceNodes.nextNode()))
    }
    catch (SAXException se)
    {
      transformer.getErrorListener().fatalError(new TransformerException(se));
    }
    finally
    {
      // Unlink to the original stack frame
      if(nParams > 0)
        vars.unlink(thisframe);
      xctxt.popSAXLocator();
      if (pushContextNodeListFlag) xctxt.popContextNodeList();
      transformer.popElemTemplateElement();
      xctxt.popCurrentExpressionNode();
      xctxt.popCurrentNode();
      sourceNodes.detach();
    }
  }