Package javax.xml.transform

Examples of javax.xml.transform.Templates


   */
  public TransformerHandler newTransformerHandler(Source src)
          throws TransformerConfigurationException
  {

    Templates templates = newTemplates(src);
    if( templates==null ) return null;
   
    return newTransformerHandler(templates);
  }
View Full Code Here


  public Transformer newTransformer(Source source)
          throws TransformerConfigurationException
  {
    try
    {
      Templates tmpl=newTemplates( source );
      /* this can happen if an ErrorListener is present and it doesn't
         throw any exception in fatalError.
         The spec says: "a Transformer must use this interface
         instead of throwing an exception" - the newTemplates() does
         that, and returns null.
      */
      if( tmpl==null ) return null;
      Transformer transformer = tmpl.newTransformer();
      transformer.setURIResolver(m_uriResolver);
      return transformer;
    }
    catch( TransformerConfigurationException ex )
    {
View Full Code Here

    }
   
    protected Templates getTemplatesFromAnnotation(Class<?> cls,
                                                   Annotation[] anns,
                                                   MediaType mt) {
        Templates t = null;
        XSLTTransform ann = getXsltTransformAnn(anns, mt);
        if (ann != null) {
            t = annotationTemplates.get(ann.value());
            if (t == null) {
                String path = ann.value();
View Full Code Here

        return t;
       
    }
   
    protected Templates getAnnotationTemplates(Annotation[] anns) {
        Templates t = null;
        XSLTTransform ann = AnnotationUtils.getAnnotation(anns, XSLTTransform.class);
        if (ann != null) {
            t = annotationTemplates.get(ann.value());
        }
        return t;
View Full Code Here

    }
   
   
   
    protected Templates getInTemplates(Annotation[] anns, MediaType mt) {
        Templates t = inTemplates != null ? inTemplates
            : inMediaTemplates != null ? inMediaTemplates.get(mt.getType() + "/" + mt.getSubtype()) : null;
        if (t == null) {   
            t = getAnnotationTemplates(anns);
        }
        return t;
View Full Code Here

        }
        return t;
    }
   
    protected Templates getOutTemplates(Annotation[] anns, MediaType mt) {
        Templates t = outTemplates != null ? outTemplates
            : outMediaTemplates != null ? outMediaTemplates.get(mt.getType() + "/" + mt.getSubtype()) : null;
        if (t == null) {   
            t = getAnnotationTemplates(anns);
        }
        return t;   
View Full Code Here

    @Override
    protected void marshalToOutputStream(Marshaller ms, Object obj, OutputStream os,
                                         Annotation[] anns, MediaType mt)
        throws Exception {
       
        Templates t = createTemplates(getOutTemplates(anns, mt), outParamsMap, outProperties);
        if (t == null && supportJaxbOnly) {
            super.marshalToOutputStream(ms, obj, os, anns, mt);
            return;
        }
        TransformerHandler th = null;
View Full Code Here

    TransformerFactory tfactory = TransformerFactory.newInstance();
   
    // Create a templates object, which is the processed,
    // thread-safe representation of the stylesheet.
    Templates templates = tfactory.newTemplates(new StreamSource(xslID));

    // Illustrate the fact that you can make multiple transformers
    // from the same template.
    Transformer transformer1 = templates.newTransformer();
    Transformer transformer2 = templates.newTransformer();
   
    System.out.println("\n\n----- transform of "+sourceID1+" -----");
   
    transformer1.transform(new StreamSource(sourceID1),
                          new StreamResult(new OutputStreamWriter(System.out)));
View Full Code Here

                                           String xslID_2, String xslID_3)
    throws TransformerException, TransformerConfigurationException, SAXException, IOException
  {
    TransformerFactory tfactory = TransformerFactory.newInstance();
   
    Templates stylesheet1 = tfactory.newTemplates(new StreamSource(xslID_1));
    Transformer transformer1 = stylesheet1.newTransformer();
   
     // If one success, assume all will succeed.
    if (tfactory.getFeature(SAXSource.FEATURE))
    {
      SAXTransformerFactory stf = (SAXTransformerFactory)tfactory;
View Full Code Here

  {
    TransformerFactory tfactory = TransformerFactory.newInstance();

    if (tfactory.getFeature(DOMSource.FEATURE))
    {
      Templates templates;

      {
        DocumentBuilderFactory dfactory =
          DocumentBuilderFactory.newInstance();
        dfactory.setNamespaceAware(true);
        DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
        org.w3c.dom.Document outNode = docBuilder.newDocument();
        Node doc = docBuilder.parse(new InputSource(xslID));
        DOMSource dsource = new DOMSource(doc);
        // If we don't do this, the transformer won't know how to
        // resolve relative URLs in the stylesheet.
        dsource.setSystemId(xslID);

        templates = tfactory.newTemplates(dsource);
      }

      Transformer transformer = templates.newTransformer();
      DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
      // Note you must always setNamespaceAware when building .xsl stylesheets
      dfactory.setNamespaceAware(true);
      DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
      org.w3c.dom.Document outNode = docBuilder.newDocument();
View Full Code Here

TOP

Related Classes of javax.xml.transform.Templates

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.