dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: XSLT
Expertise: Advanced
Sep 13, 2006

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Read the First Line of a Text File

This code shows you how to use the instance methods from the FileReader and BufferedReader classes with a Xalan 2 processor to read the first line from a text file.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"  
xmlns:FR="xalan://java.io.FileReader"
xmlns:BR="xalan://java.io.BufferedReader">
	                          
<xsl:output method="html" version="4.01" encoding="ISO-8859-1" indent="yes" media-
type="text/html" />	          
 
<xsl:variable name="file_reader" select=
"FR:new(string('C://Data_Local//XML//XSLT//in.txt'))" />
<xsl:variable name="buffered_reader" select="BR:new($file_reader)" />
<xsl:variable name="read" select="BR:readLine($buffered_reader)" />

<xsl:template  match="/">	
  <html>
  <body> 			
     <h3><xsl:value-of select="$read" /></h3>	
...
Note: This tip was tested on Xalan, version 2.7.0.

Leonard Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date