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

Pete Keyes PKeyes at starbucks.com
Tue Aug 15 13:19:52 PDT 2006


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 at jdom.org
[mailto:jdom-interest-bounces at jdom.org] On Behalf Of
jdom-interest-request at jdom.org
Sent: Tuesday, August 15, 2006 12:00 PM
To: jdom-interest at jdom.org
Subject: jdom-interest Digest, Vol 25, Issue 8

Send jdom-interest mailing list submissions to
	jdom-interest at jdom.org

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 at jdom.org

You can reach the person managing the list at
	jdom-interest-owner at jdom.org

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 at eio-online.com)
   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 at eio-online.com)
   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 at eio-online.com
Subject: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest at jdom.org
Message-ID: <20060814152236.cbu7fryey7e8swgc at www.eio-online.com>
Content-Type: text/plain;	charset=ISO-8859-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.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 at uni-jena.de>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest at jdom.org
Message-ID: <200608150808.11700.thomas.scheffler at uni-jena.de>
Content-Type: text/plain;  charset="iso-8859-1"

Am Dienstag, 15. August 2006 00:22 schrieb wkrick at eio-online.com:
> 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.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 at expertsystems.se>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: wkrick at eio-online.com, jdom-interest at jdom.org
Message-ID: <7.0.1.0.0.20060815082641.01bbe980 at expertsystems.se>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 2006-08-15 00:22, wkrick at eio-online.com 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.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 at eio-online.com
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest at jdom.org
Message-ID: <20060815075758.eobzo4zpz9cwwggk at www.eio-online.com>
Content-Type: text/plain;	charset=ISO-8859-1;	DelSp="Yes";
	format="flowed"

Quoting Mattias Jiderhamn <mj-lists at expertsystems.se>:

> At 2006-08-15 00:22, wkrick at eio-online.com wrote:
>> I'm trying to use the method shown here to apply an XSL transform to
>> my JDOM document...
>>
>> http://www-128.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 at mtvn.com>
Subject: RE: [jdom-interest] problems applying XSL transform to JDOM
To: <wkrick at eio-online.com>, <jdom-interest at jdom.org>
Message-ID:
	
<76EE76A58EBABE449AFE89DA92696F4401AFCBDD at ROOMRAIDERS.mtvn.ad.viacom.com
>
	
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 at jdom.org
[mailto:jdom-interest-bounces at jdom.org] On Behalf Of
wkrick at eio-online.com
Sent: Tuesday, August 15, 2006 10:58 AM
To: jdom-interest at jdom.org
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM

Quoting Mattias Jiderhamn <mj-lists at expertsystems.se>:

> At 2006-08-15 00:22, wkrick at eio-online.com wrote:
>> I'm trying to use the method shown here to apply an XSL transform to
>> my JDOM document...
>>
>> http://www-128.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@yourhost.com



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

Message: 6
Date: Tue, 15 Aug 2006 17:27:54 +0200
From: Thomas Scheffler <thomas.scheffler at uni-jena.de>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: jdom-interest at jdom.org
Message-ID: <200608151727.55100.thomas.scheffler at uni-jena.de>
Content-Type: text/plain;  charset="iso-8859-1"

Am Dienstag, 15. August 2006 16:57 schrieb wkrick at eio-online.com:
> Quoting Mattias Jiderhamn <mj-lists at expertsystems.se>:
> > At 2006-08-15 00:22, wkrick at eio-online.com wrote:
> >> I'm trying to use the method shown here to apply an XSL transform
to
> >> my JDOM document...
> >>
> >> http://www-128.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 at google.com>
Subject: Re: [jdom-interest] problems applying XSL transform to JDOM
To: "wkrick at eio-online.com" <wkrick at eio-online.com>
Cc: jdom-interest at jdom.org
Message-ID:
	<fc072ec0608150851i4d40f401mb4d839986ce37ee9 at mail.google.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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

On 8/15/06, wkrick at eio-online.com <wkrick at eio-online.com> wrote:
> Quoting Mattias Jiderhamn <mj-lists at expertsystems.se>:
>
> > At 2006-08-15 00:22, wkrick at eio-online.com wrote:
> >> I'm trying to use the method shown here to apply an XSL transform
to
> >> my JDOM document...
> >>
> >> http://www-128.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@yourhost.com
>


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

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

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



More information about the jdom-interest mailing list