Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
RE: jdom-interest Digest, Vol 25, Issue 8

RE: jdom-interest Digest, Vol 25, Issue 8

2006-08-15       - By Pete Keyes

 Back
This should do what you're want:
=============================================================
import org.jdom.*;
import org.jdom.output.*;
import org.jdom.transform.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

private Document translate(Document xmlDoc, String xslDocUrl) {
   StreamSource streamSource = new StreamSource(xslDocUrl);
   Transformer transformer = TransformerFactory
       .newInstance().newTransformer(
          streamSource
   );

   JDOMResult jdomResult = new JDOMResult();
   transformer.transform(new JDOMSource(xmlDoc), jdomResult);

   return jdomResult.getDocument();
}
=============================================================

...Pete

Starbucks Coffee Co.
2401 Utah Ave. S
Seattle, WA. 98134
(w)206.318.5933


-- --Original Message-- --
From: jdom-interest-bounces@(protected)
[mailto:jdom-interest-bounces@(protected)] On Behalf Of
jdom-interest-request@(protected)
Sent: Tuesday, August 15, 2006 12:00 PM
To: jdom-interest@(protected)
Subject: jdom-interest Digest, Vol 25, Issue 8

Send jdom-interest mailing list submissions to
  jdom-interest@(protected)

To subscribe or unsubscribe via the World Wide Web, visit
  http://www.jdom.org/mailman/listinfo/jdom-interest
or, via email, send a message with subject or body 'help' to
  jdom-interest-request@(protected)

You can reach the person managing the list at
  jdom-interest-owner@(protected)

When replying, please edit your Subject line so it is more specific
than "Re: Contents of jdom-interest digest..."


Today's Topics:

  1. problems applying XSL transform to JDOM (wkrick@(protected))
  2. Re: problems applying XSL transform to JDOM (Thomas Scheffler)
  3. Re: problems applying XSL transform to JDOM (Mattias Jiderhamn)
  4. Re: problems applying XSL transform to JDOM
     (wkrick@(protected))
  5. RE: problems applying XSL transform to JDOM (Edelson, Justin)
  6. Re: problems applying XSL transform to JDOM (Thomas Scheffler)
  7. Re: problems applying XSL transform to JDOM (Bart Locanthi)


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --

Message: 1
Date: Mon, 14 Aug 2006 15:22:36 -0700
From: wkrick@(protected)
Subject: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest@(protected)
Message-ID: <20060814152236.cbu7fryey7e8swgc@(protected)>
Content-Type: text/plain;   charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1;   DelSp="Yes";
  format="flowed"

I'm using JDOM 1.0 with Java 1.4.2.

I'm trying to use the method shown here to apply an XSL transform to  
my JDOM document...

http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html

It appears to get stuck in a loop and hangs on this line...

xmlOutputter.output(sourceDoc, sourceOut);

... no exceptions are thrown.

Has anyone else used the method illustrated at the link above and  
gotten it to work?


Is there an easier way?  Basically, I have a JDOM Document object in  
my application, I want to apply an XSL transform and write out the XML  
result to a file.


-- ---- ---- ---- ---- ---- --

Message: 2
Date: Tue, 15 Aug 2006 08:08:11 +0200
From: Thomas Scheffler <thomas.scheffler@(protected)>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest@(protected)
Message-ID: <200608150808.11700.thomas.scheffler@(protected)>
Content-Type: text/plain;  charset="iso-8859 (See http://iso-8859.ora-code.com)-1"

Am Dienstag, 15. August 2006 00:22 schrieb wkrick@(protected):
> I'm using JDOM 1.0 with Java 1.4.2.
>
> I'm trying to use the method shown here to apply an XSL transform to
> my JDOM document...
>
> http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html

I just looked over it a bit. Basically you would rather use JdomSource
instead
of StreamSource. All that piped sources are also not needed. They are
the
source of your hang and should be used in different threads only.

regards

Thomas


-- ---- ---- ---- ---- ---- --

Message: 3
Date: Tue, 15 Aug 2006 08:32:15 +0200
From: Mattias Jiderhamn <mj-lists@(protected)>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: wkrick@(protected), jdom-interest@(protected)
Message-ID: <7.0.1.0.0.20060815082641.01bbe980@(protected)>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 2006-08-15 00:22, wkrick@(protected) wrote:
>I'm using JDOM 1.0 with Java 1.4.2.
>
>I'm trying to use the method shown here to apply an XSL transform to
>my JDOM document...
>
>http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html
>
>It appears to get stuck in a loop and hangs on this line...
>
>xmlOutputter.output(sourceDoc, sourceOut);
>
>... no exceptions are thrown.
>
>Has anyone else used the method illustrated at the link above and
>gotten it to work?

No. Seems overly complicated to me.


>Is there an easier way?  Basically, I have a JDOM Document object in
>my application, I want to apply an XSL transform and write out the XML
>result to a file.

  TransformerFactory factory = TransformerFactory.newInstance();
  Transformer transformer = factory.newTransformer( new
StreamSource(xslFile) );

  JDOMSource xmlSource = new JDOMSource(document);
  StreamResult result = new StreamResult(outputFile);

  transformer.transform(source, result);



-- ---- ---- ---- ---- ---- --

Message: 4
Date: Tue, 15 Aug 2006 07:57:58 -0700
From: wkrick@(protected)
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest@(protected)
Message-ID: <20060815075758.eobzo4zpz9cwwggk@(protected)>
Content-Type: text/plain;   charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1;   DelSp="Yes";
  format="flowed"

Quoting Mattias Jiderhamn <mj-lists@(protected)>:

> At 2006-08-15 00:22, wkrick@(protected) wrote:
>> I'm trying to use the method shown here to apply an XSL transform to
>> my JDOM document...
>>
>> http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html
>>
>> Is there an easier way?  Basically, I have a JDOM Document object in
>> my application, I want to apply an XSL transform and write out the
XML
>> result to a file.
>
>
>   TransformerFactory factory = TransformerFactory.newInstance();
>   Transformer transformer = factory.newTransformer( new
> StreamSource(xslFile) );
>
>   JDOMSource xmlSource = new JDOMSource(document);
>   StreamResult result = new StreamResult(outputFile);
>
>   transformer.transform(source, result);
>

Thanks for the help.

Transform doesn't appear to have any methods that return a JDOM  
Document.  Is there some way to transform a JDOM document object and  
not write directly to a file?





-- ---- ---- ---- ---- ---- --

Message: 5
Date: Tue, 15 Aug 2006 11:20:17 -0400
From: "Edelson, Justin" <Justin.Edelson@(protected)>
Subject: RE: [jdom-interest] problems applying XSL transform to JDOM
To: <wkrick@(protected)>, <jdom-interest@(protected)>
Message-ID:
 
<76EE76A58EBABE449AFE89DA92696F4401AFCBDD@(protected)
>
 
Content-Type: text/plain;   charset="us-ascii"

> Transform doesn't appear to have any methods that return a JDOM  
> Document.  Is there some way to transform a JDOM document object and  
> not write directly to a file?
Check out the JDOMResult class.

-- --Original Message-- --
From: jdom-interest-bounces@(protected)
[mailto:jdom-interest-bounces@(protected)] On Behalf Of
wkrick@(protected)
Sent: Tuesday, August 15, 2006 10:58 AM
To: jdom-interest@(protected)
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM

Quoting Mattias Jiderhamn <mj-lists@(protected)>:

> At 2006-08-15 00:22, wkrick@(protected) wrote:
>> I'm trying to use the method shown here to apply an XSL transform to
>> my JDOM document...
>>
>> http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html
>>
>> Is there an easier way?  Basically, I have a JDOM Document object in
>> my application, I want to apply an XSL transform and write out the
XML
>> result to a file.
>
>
>   TransformerFactory factory = TransformerFactory.newInstance();
>   Transformer transformer = factory.newTransformer( new
> StreamSource(xslFile) );
>
>   JDOMSource xmlSource = new JDOMSource(document);
>   StreamResult result = new StreamResult(outputFile);
>
>   transformer.transform(source, result);
>

Thanks for the help.

Transform doesn't appear to have any methods that return a JDOM  
Document.  Is there some way to transform a JDOM document object and  
not write directly to a file?



__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)



-- ---- ---- ---- ---- ---- --

Message: 6
Date: Tue, 15 Aug 2006 17:27:54 +0200
From: Thomas Scheffler <thomas.scheffler@(protected)>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest@(protected)
Message-ID: <200608151727.55100.thomas.scheffler@(protected)>
Content-Type: text/plain;  charset="iso-8859 (See http://iso-8859.ora-code.com)-1"

Am Dienstag, 15. August 2006 16:57 schrieb wkrick@(protected):
> Quoting Mattias Jiderhamn <mj-lists@(protected)>:
> > At 2006-08-15 00:22, wkrick@(protected) wrote:
> >> I'm trying to use the method shown here to apply an XSL transform
to
> >> my JDOM document...
> >>
> >> http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html
> >>
> >> Is there an easier way?  Basically, I have a JDOM Document object
in
> >> my application, I want to apply an XSL transform and write out the
XML
> >> result to a file.
> >
> >   TransformerFactory factory = TransformerFactory.newInstance();
> >   Transformer transformer = factory.newTransformer( new
> > StreamSource(xslFile) );
> >
> >   JDOMSource xmlSource = new JDOMSource(document);
> >   StreamResult result = new StreamResult(outputFile);
> >
> >   transformer.transform(source, result);
>
> Thanks for the help.
>
> Transform doesn't appear to have any methods that return a JDOM
> Document.  Is there some way to transform a JDOM document object and
> not write directly to a file?

StreamSource       StreamResult
-- ---- ---- ----- =  -- ---- ---- ----
JDOMSource                   x

What might "x" be? Try to find it in the JDOM Javadocs: a great place
for
finding answers on JDOM.

regards

Thomas


-- ---- ---- ---- ---- ---- --

Message: 7
Date: Tue, 15 Aug 2006 08:51:25 -0700
From: "Bart Locanthi" <bnl@(protected)>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: "wkrick@(protected)" <wkrick@(protected)>
Cc: jdom-interest@(protected)
Message-ID:
  <fc072ec0608150851i4d40f401mb4d839986ce37ee9@(protected)>
Content-Type: text/plain; charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1; format=flowed

one of the output forms is dom. of course you can get data back!

On 8/15/06, wkrick@(protected) <wkrick@(protected)> wrote:
> Quoting Mattias Jiderhamn <mj-lists@(protected)>:
>
> > At 2006-08-15 00:22, wkrick@(protected) wrote:
> >> I'm trying to use the method shown here to apply an XSL transform
to
> >> my JDOM document...
> >>
> >> http://www-128 (See http://www-128.ora-code.com).ibm.com/developerworks/java/library/x-tipjdom.html
> >>
> >> Is there an easier way?  Basically, I have a JDOM Document object
in
> >> my application, I want to apply an XSL transform and write out the
XML
> >> result to a file.
> >
> >
> >   TransformerFactory factory = TransformerFactory.newInstance();
> >   Transformer transformer = factory.newTransformer( new
> > StreamSource(xslFile) );
> >
> >   JDOMSource xmlSource = new JDOMSource(document);
> >   StreamResult result = new StreamResult(outputFile);
> >
> >   transformer.transform(source, result);
> >
>
> Thanks for the help.
>
> Transform doesn't appear to have any methods that return a JDOM
> Document.  Is there some way to transform a JDOM document object and
> not write directly to a file?
>
>
>
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____
> To control your jdom-interest membership:
>
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
>


-- ---- ---- ---- ---- ---- --

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

End of jdom-interest Digest, Vol 25, Issue 8
********************************************

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.