File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Make it so: Java DB Connections & Transactions
this week in the
display a tag information from xslt file.
Joined: May 12, 2006
May 22, 2008 20:32:00
I have a doubt in displaying one tag information from XSLT using
Student id: John
Student Name: Visa
suppose i want to display only student name. into command prompt. How do i write a program using xslt.
Please guide me in this regards,
author and iconoclast
Joined: Jul 08, 2003
May 23, 2008 08:09:00
Welcome to JavaRanch!
The data you've shown here isn't XSLT or XML, so I'm a little confused as to what your question is. Running a valid XSLT transform on an XML file from Java can be as simple as this:
File xslFile, xmlFile, outputFile = ... TransformerFactory factory = TransformerFactory.newInstance(); Transformer t = factory.newTransformer(new StreamSource(xslFile)); t.transform(new StreamSource(xmlFile), new StreamResult(outputFile));
If you had XML that looked like
<?xml version="1.0"?> <Student> <id>John</id> <name>Visa</name> <department>111-222-333</department> <year>05/2008</year> </Student>
Then XSL to extract just the name might look like
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="no"/> <xsl:template match="Student"> <xsl:value-of select="name"/> </xsl:template> </xsl:stylesheet>
Hope something in here helps.
[ May 23, 2008: Message edited by: Ernest Friedman-Hill ]
[Jess in Action]
I agree. Here's the link:
subject: display a tag information from xslt file.
toString method and output
uploading data into JTable
XML document inside HTML tag.
Arrays and methods - not getting the results I expected
Clarification needed regarding jsp:getProperty
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015