473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reading XML file via XSL

All,

Please help in the following.

I am new to XML and XSL.

I have written one XSL as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:USOURCE="USOURCE.DICT">
<xsl:template match="UNIFACE/TABLE/OCC[USOURCE:UTEXT]">
<html>
<h2>Y_WRITE</h2>
<xsl:value-of select="USOURCE:UTEXT" />
</html>
</xsl:template></xsl:stylesheet>

This is to extract UTEXT element contents from one xml file. But these
contents consist of multiple lines. When I run the xml using the above
XSL, multiple lines on in USOURCE:UTEXT get printed on single line.
That is, all the newlines get removed.
Is there any way in which I can preserve the newlines in the text of
XML element and give the same output?

Jul 20 '05 #1
6 3418


sh*************@indiatimes.com wrote:

I am new to XML and XSL.

I have written one XSL as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:USOURCE="USOURCE.DICT">
<xsl:template match="UNIFACE/TABLE/OCC[USOURCE:UTEXT]">
<html>
<h2>Y_WRITE</h2>
<xsl:value-of select="USOURCE:UTEXT" />
</html>
</xsl:template></xsl:stylesheet>

This is to extract UTEXT element contents from one xml file. But these
contents consist of multiple lines. When I run the xml using the above
XSL, multiple lines on in USOURCE:UTEXT get printed on single line.
That is, all the newlines get removed.
Is there any way in which I can preserve the newlines in the text of
XML element and give the same output?


Sounds more like a HTML problem to me, in HTML there is the <pre>
element so you might want to use <pre> to wrap the content you have e.g.

<xsl:template match="/">
<html>
<head>
<title>some title</title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>

<xsl:template match="USOURCE:UTEXT">
<pre><xsl:value-of select="." /></pre>
</xsl:template>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Thank a lot Martin.
That solved my problem.
Any pointers the following?
Instead of displaying HTML output, I want to capture the output in a
text file. Is it possible?
Thanks again

Shailesh

Jul 20 '05 #3


sh*************@indiatimes.com wrote:

Instead of displaying HTML output, I want to capture the output in a
text file. Is it possible?


Well if you are using an XSLT processor from the command line then you
probably only need to do
processor file.xml file.xsl > output.txt
or similar depending on the syntax that command line shell wants.
I don't know which XSLT processor you use, you might want to check its
documentation for details.
And if you need text output instead of HTML output then you need
<xsl:output method="text" />
in the stylesheet.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
I tried using
<xsl:output method="text" />
But the output opens in browser only.
Also, the same original problem, 'Output on one line', comes. Here I
cannot use <pre>.
Any solution?
Sorry for the trouble.
Thanks in advance

Shailesh

Jul 20 '05 #5


sh*************@indiatimes.com wrote:
I tried using
<xsl:output method="text" />
But the output opens in browser only.


Well if you use the browser's XSLT processor then of course it renders
into the browser.
If you want to create a file then you need use a processor you can run
from the command line or using an API in a programming language of your
choice.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #6
Thanks a lot for your guidance.
Any good translator, which I can download for this purpose?

sh*************@indiatimes.com wrote:
I tried using
<xsl:output method="text" />
But the output opens in browser only.
Also, the same original problem, 'Output on one line', comes. Here I
cannot use <pre>.
Any solution?
Sorry for the trouble.
Thanks in advance

Shailesh


Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
1
by: Need Helps | last post by:
Hello. I'm writing an application that writes to a file a month, day, year, number of comments, then some strings for the comments. So the format for each record would look like:...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.