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

XSLT and Java

  • From: Joel Beach <joelbeach@o...>
  • To: xml-dev@l...
  • Date: Fri, 06 Jul 2001 23:37:45 +1000

growing lentils
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


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.