Create a new {@link XSLTTransformation} using the given location of the source XSLT file within the given {@link ClassLoader}.
492329
public static XSLTTransformationLocation using(String location, ClassLoader classLoader)
    {
        XSLTTransformation tansformation = new XSLTTransformation();
        /*
         * ClassLoader instance needed to see the file passed in the location
         */
        tansformation.contextClassLoader = classLoader;
        tansformation.template = location;
        return tansformation;
    }
146900
public static Program create(Location location, ClassLoader classLoader) throws IOException {
    return new DefaultProgram(location, classLoader);
  }
384595
public static TransformerFactory newTransformerFactory( String factoryClassName, ClassLoader classLoader )
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
    {
        // use reflection to avoid JAXP 1.4 (and hence JDK6) requirement

        Class<?>[] methodTypes = new Class[] { String.class, ClassLoader.class };

        Method method = TransformerFactory.class.getDeclaredMethod( "newInstance", methodTypes );

        Object[] methodArgs = new Object[] { factoryClassName, classLoader };

        return (TransformerFactory) method.invoke( null, methodArgs );
    }
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);
		}
	}
66959
@SuppressWarnings("static-method")
	protected ClassLoader createClassLoader(Iterable<File> jarsAndFolders, ClassLoader parentClassLoader) {
		return new URLClassLoader(Iterables.toArray(Iterables.transform(jarsAndFolders, from -> {
			try {
				final URL url = from.toURI().toURL();
				assert url != null;
				return url;
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}), URL.class), parentClassLoader);
	}
911507
@SuppressWarnings({ "unchecked", "rawtypes" })
    public <T> T createProxy(ClassLoader classLoader) {

        LettuceAssert.notNull(classLoader, "ClassLoader must not be null");

        Class<?>[] interfaces = this.interfaces.toArray(new Class[0]);

        return (T) Proxy.newProxyInstance(classLoader, interfaces, new InterceptorChainInvocationHandler(interceptors));
    }
1013924
public static XMLReader createXMLReader() throws SAXException, ParserConfigurationException, FactoryConfigurationError {
        try {
            return (XMLReader) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() throws SAXException, ParserConfigurationException, FactoryConfigurationError {
                    Thread currThread = Thread.currentThread();
                    ClassLoader oldLoader = currThread.getContextClassLoader();
                    currThread.setContextClassLoader(ParserFactory.class.getClassLoader());
                    try {
                        /**
                         * Changed to use pluggable parser version. Needed for JDK 1.4.1
                         */
                        return SAXParserFactory.newInstance().newSAXParser().getXMLReader();
                        //return XMLReaderFactory.createXMLReader();
                    }
                                        finally {
                                            currThread.setContextClassLoader(oldLoader);
                                        }
                                    }
            });
        } catch (PrivilegedActionException pae) {
            Throwable t = pae.getCause();
            if (t instanceof SAXException) {
                throw (SAXException) t;
            } else if (t instanceof ParserConfigurationException) {
                throw (ParserConfigurationException) t;
            } else if (t instanceof FactoryConfigurationError) {
                throw (FactoryConfigurationError) t;
            }
        }
        return null;
    }
365239
@Override
    public boolean addTransformer(final ClassFileTransformer cft) {
        transformers.add(cft);

        // Also recursively register with parent(s), until a non-AppClassLoader or GlobalSharedLibrary loader is encountered.
        if (parent instanceof AppClassLoader) {
            if (Util.isGlobalSharedLibraryLoader(((AppClassLoader) parent))) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "addTransformer - skipping parent loader because it is a GlobalSharedLibrary");
                }
            } else {
                return ((AppClassLoader) parent).addTransformer(cft);
            }
        }
        return true;
    }
1318718
@SuppressWarnings("unchecked")
	public T newInstance(ClassLoader classLoader) {
		try {
			return (T) compile(classLoader).getConstructor(Object[].class)
					// Because Constructor.newInstance(Object... initargs), we need to load
					// references into a new Object[], otherwise it cannot be compiled.
					.newInstance(new Object[] {references});
		} catch (Exception e) {
			throw new RuntimeException(
				"Could not instantiate generated class '" + className + "'", e);
		}
	}
881116
public static Pipe newPipe(final XMLStreamReader parser)
    {
        final XmlInput xmlInput = new XmlInput(parser);
        return new Pipe()
        {
            protected Input begin(Pipe.Schema<?> pipeSchema) throws IOException
            {
                //final String simpleName = pipeSchema.wrappedSchema.messageName();

                try
                {
                    if(parser.nextTag() != START_ELEMENT || 
                            !pipeSchema.wrappedSchema.messageName().equals(parser.getLocalName()))
                    {
                        throw new XmlInputException("Expected token START_ELEMENT: " + 
                                pipeSchema.wrappedSchema.messageName());
                    }
                    
                    if(parser.nextTag() == END_ELEMENT)
                    {
                        //if(!simpleName.equals(parser.getLocalName()))
                        //    throw new XmlInputException("Expecting token END_ELEMENT: " + 
                        //            simpleName);
                        
                        // empty message;
                        return null;
                    }
                }
                catch(XMLStreamException e)
                {
                    throw new XmlInputException(e);
                }
                
                return xmlInput;
            }
            
            protected void end(Pipe.Schema<?> pipeSchema, Input input, 
                    boolean cleanupOnly) throws IOException
            {
                if(cleanupOnly)
                {
                    try
                    {
                        parser.close();
                    }
                    catch (XMLStreamException e)
                    {
                        // ignore
                    }
                    return;
                }
                
                assert input == xmlInput;
                
                //final String simpleName = pipeSchema.wrappedSchema.messageName();
                //final String localName = parser.getLocalName();
                
                try
                {
                    parser.close();
                }
                catch (XMLStreamException e)
                {
                    // end of pipe transfer ... ignore
                }
                
                /*if(!simpleName.equals(localName))
                {
                    throw new XmlInputException("Expecting token END_ELEMENT: " + 
                            simpleName);
                }*/
            }
        };
    }
344774
protected final DelegateClassLoader createClassLoader(PluginSource source,
            ClassLoader parent) {
        final Stream<URL> urls = Require.nonNullResult(source.getPluginURLs(),
                "pluginSource.getPluginURLs");
        return DelegateClassLoader.forPlugins(urls, parent);
    }
736304
public void setTransform(final Document xsltdoc)
            throws TransformerConfigurationException {
        //
        //  scan transform source for xsl:output elements
        //    and extract encoding, media (mime) type and output method
        //
        String encodingName = null;
        mediaType = null;
        String method = null;
        NodeList nodes = xsltdoc.getElementsByTagNameNS(
                XSLT_NS,
                "output");
        for(int i = 0; i < nodes.getLength(); i++) {
            Element outputElement = (Element) nodes.item(i);
            if (method == null || method.length() == 0) {
                method = outputElement.getAttributeNS(null, "method");
            }
            if (encodingName == null || encodingName.length() == 0) {
                encodingName = outputElement.getAttributeNS(null, "encoding");
            }
            if (mediaType == null || mediaType.length() == 0) {
                mediaType = outputElement.getAttributeNS(null, "media-type");
            }
        }

        if (mediaType == null || mediaType.length() == 0) {
            if ("html".equals(method)) {
                mediaType = "text/html";
            } else if ("xml".equals(method)) {
                mediaType = "text/xml";
            } else {
                mediaType = "text/plain";
            }
        }

        //
        //  if encoding was not specified,
        //     add xsl:output encoding=US-ASCII to XSLT source
        //
        if (encodingName == null || encodingName.length() == 0) {
            Element transformElement = xsltdoc.getDocumentElement();
            Element outputElement = xsltdoc.
                    createElementNS(XSLT_NS, "output");
            outputElement.setAttributeNS(null, "encoding", "US-ASCII");
            transformElement.insertBefore(outputElement, transformElement.getFirstChild());
            encoding = Charset.forName("US-ASCII");
        } else {
            encoding = Charset.forName(encodingName);
        }

        DOMSource transformSource = new DOMSource(xsltdoc);
        
        templates = transformerFactory.newTemplates(transformSource);

    }
218041
public ClassSource create(final String source) {
    checkNotNull(source);

    String trimmed = source.trim();
    log.trace("Creating class-source from: {}", trimmed);

    // First try and parse the source as a URL
    try {
      return new ClassSourceImpl(new URL(trimmed), null, null);
    }
    catch (MalformedURLException e) {
      log.trace("Not a URL", e);
    }

    // FIXME: This is _slightly_ problematic as if you have a valid file ref
    // FIXME: but the file is missing then it will be treated as inline instead of as a file

    // Then as a File
    try {
      File file = new File(trimmed).getCanonicalFile();
      if (file.exists()) {
        return new ClassSourceImpl(null, file, null);
      }
    }
    catch (IOException e) {
      log.trace("Not a File", e);
    }

    // Else it is an inline
    return new ClassSourceImpl(null, null, new InlineImpl(source));
  }
1008440
private static Document createSurroundingXMLResp() throws ParserConfigurationException {
        final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        return document;
    }
1094002
public void transform(Source pIn) throws JspException {
        try {
            // Create transformer
            Transformer transformer = TransformerFactory.newInstance()
                    .newTransformer(getSource(mStylesheetURI));

            // Store temporary output in a bytearray, as the transformer will
            // usually try to flush the stream (illegal operation from a custom
            // tag).
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            StreamResult out = new StreamResult(os);

            // Perform the transformation
            transformer.transform(pIn, out);

            // Write the result back to the JSP writer
            pageContext.getOut().print(os.toString());
        }
        catch (MalformedURLException murle) {
            throw new JspException(murle.getMessage(), murle);
        }
        catch (IOException ioe) {
            throw new JspException(ioe.getMessage(), ioe);
        }
        catch (TransformerException te) {
            throw new JspException("XSLT Trandformation failed: " + te.getMessage(), te);
        }
    }
356908
private static List<TransformationDescription> loadDescrtipionsFromXMLInputSource(InputSource source,
            String fileName) throws Exception {
        XMLReader xr = XMLReaderFactory.createXMLReader();
        TransformationDescriptionXMLReader reader = new TransformationDescriptionXMLReader(fileName);
        xr.setContentHandler(reader);
        xr.parse(source);
        return reader.getResult();
    }
54621
public TreeBuilder<T> convert(ContentConverter<T> converter, PathSelector pathSelector,
            ResourceSelector<T> resourceSelector) {
        return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, pathSelector, resourceSelector));
    }