OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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