[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSLT and Java

  • From: Dylan Walsh <Dylan.Walsh@K...>
  • To: Joel Beach <joelbeach@o...>, xml-dev@l...
  • Date: Fri, 06 Jul 2001 17:31:38 +0100

constructing a transformer
Questions regarding XSLT, in general, are best dealt with at the XSL
list: xsl-list@l.... There you will usually get a
complete and correct answer, promptly.

Some pointers:
To pass a parameter to a stylesheet, declare a top level xsl:param. 
Your java code can then set the value of that param using the
Transformer.setParameter() method before transformation. 

This approach is much cleaner that modifying the stylesheet each time.
If there are a *lot* of "issues", then you might consider extracting the
relevent "issue" before transformation, and passing that single "issue"
to the stylesheet. That approach might be faster as you are only
interested in one "issue". 

I don't know why you are getting the error when constructing a
Transformer from a DOM source.

> -----Original Message-----
> From:	Joel Beach [SMTP:joelbeach@o...]
> Sent:	Friday, July 06, 2001 2:38 PM
> To:	xml-dev@l...
> Subject:	XSLT and Java
> 
> Hi Everyone,
> 
> Not sure whether this is offtopic or not.
> 
> Just wondering if anyone has some suggestions on my problem. I have an
> XML
> file with a basic structure which looks something like the following.
> 
> <Issues>
>                 <Issue ID="1">
>                     <IssueName>Lentil-killing parasites</IssueName>
>                     <IssueDescription>
>                         <Paragraph>At the moment Lentil-killing
> parasites
>                             are ravaging the Trial. This could affect
> all
>                             people growing Lentils. As a precaution,
>                             we recommend that all farmers stop reading
> too
>                             much science fiction. This goes for
> students
>                             defining the XML formats for 340 projects
>                             as well.
>                         </Paragraph>
>                     </IssueDescription>
>                     <MultimediaItems>
>                         <MMObject ID="5">
>                             <Image>
>                                 <MMLocation>Image.jpg</MMLocation>
>                                 <MMName>Picture of plot</MMName>
>                                 <ImageWidth>640</ImageWidth>
>                                 <ImageHeight>480</ImageHeight>
>                                 <FileSize>80</FileSize>
>                             </Image>
>                         </MMObject>
>                     </MultimediaItems>
>                 </Issue>
>  </Issues>
> 
> Each Issue has a unique ID, and I want to be able to apply an XSL
> stylesheet
> in Java (using JAXP) so that I apply to only one Issue.
> 
> Basically, I was wondering if there was a way to write a stylesheet
> such
> that a parameter can be passed to it and a transform performed with
> the
> stylesheet after the parameter is substituted. My current idea is to
> naively
> generate the stylesheet by printing out to a temp file, and then using
> the
> temp file as my stylesheet. This is most likely to be slow. Is there a
> better way?
> 
> At first I thought about parsing the XSL stylesheet through the DOM,
> altering the appropriate node and then using the altered Document as a
> DOMSource for the XSLT transformer. However, using JAXP 1.1, I can't
> instantiate a Transformer using a DOMSource as an argument to the
> constructor. It always complains that stylesheet requires a version
> attribute. This attribute is present in the file (<xsl:stylesheet
> version="1.0" ...>).
> 
> Any ideas....is there some compatability problem. If I use a SAXSource
> or a
> StreamSource to make the Transformer, everything works out fine....why
> is
> DOMSource different?
> 
> Joel
> 
> 
> ------------------------------------------------------------------
> The xml-dev list is sponsored by XML.org, an initiative of OASIS
> <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@l...

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.