[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: XSLT and Java
- From: Dylan Walsh <Dylan.Walsh@Kadius.Com>
- To: Joel Beach <email@example.com>, firstname.lastname@example.org
- Date: Fri, 06 Jul 2001 17:31:38 +0100
Questions regarding XSLT, in general, are best dealt with at the XSL
list: email@example.com. There you will usually get a
complete and correct answer, promptly.
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:firstname.lastname@example.org]
> Sent: Friday, July 06, 2001 2:38 PM
> To: email@example.com
> 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
> file with a basic structure which looks something like the following.
> <Issue ID="1">
> <IssueName>Lentil-killing parasites</IssueName>
> <Paragraph>At the moment Lentil-killing
> are ravaging the Trial. This could affect
> people growing Lentils. As a precaution,
> we recommend that all farmers stop reading
> much science fiction. This goes for
> defining the XML formats for 340 projects
> as well.
> <MMObject ID="5">
> <MMName>Picture of plot</MMName>
> Each Issue has a unique ID, and I want to be able to apply an XSL
> 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
> that a parameter can be passed to it and a transform performed with
> stylesheet after the parameter is substituted. My current idea is to
> generate the stylesheet by printing out to a temp file, and then using
> 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
> DOMSource different?
> The xml-dev list is sponsored by XML.org, an initiative of OASIS
> 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: firstname.lastname@example.org