A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
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]
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: display a tag information from xslt file.
XML document inside HTML tag.
Clarification needed regarding jsp:getProperty
Arrays and methods - not getting the results I expected
uploading data into JTable
toString method and output
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013