Reading XSLT from Java

C

cybernerdsx2

Hi,

I am new to XSLT and I would like to use Java to read up the XSLT
content and add in a few tags in into the template below:

<xsl:template name="hwSpecs">
<!-- adding new tags into here from Java -->
</xsl:template>

So, what kind of parser or tools can I use in my Java source code to
deal with this?

Many thanks.

Mike
 
J

Johannes Koch

cybernerdsx2 said:
I am new to XSLT and I would like to use Java to read up the XSLT
content and add in a few tags in into the template below:

<xsl:template name="hwSpecs">
<!-- adding new tags into here from Java -->
</xsl:template>

So, what kind of parser or tools can I use in my Java source code to
deal with this?

XSLT is XML-based, so you can use e.g. an XML DOM parser to do that.
 
C

cybernerdsx2

Thanks. Can I use JDOM for doing that?
Any simple example to, say, read the tag <xsl:template name="hwSpecs"> ?
 
J

Johannes Koch

cybernerdsx2 said:
Thanks. Can I use JDOM for doing that?

I think you can.
Any simple example to, say, read the tag <xsl:template name="hwSpecs"> ?

I don't use JDOM. But there should be a method to read all template
elements from XSLT 1.0 namespace. Then get the element with the specific
name attribute value.
 
M

Martin Honnen

cybernerdsx2 wrote:

I am new to XSLT and I would like to use Java to read up the XSLT
content and add in a few tags in into the template below:

<xsl:template name="hwSpecs">
<!-- adding new tags into here from Java -->
</xsl:template>

So, what kind of parser or tools can I use in my Java source code to
deal with this?

Java 1.4 and later has XSLT 1.0 support so one way to do that is to
write an XSLT 1.0 stylesheet that processes an input stylesheet and
generates a new output stylesheet. After all, XSLT is XML so you can use
XSLT itself to process and to generate XSLT.

Or you could write a Java program using the W3C DOM to parse the input
stylesheet into a DOM tree and then use the DOM API to add elements.
Then you need to serialize to DOM tree to get a new XML document file.

Besides those tools built-in for Java 1.4 or 1.5 you can of course have
a look at the various third party implementations for XSLT, DOM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top