473,405 Members | 2,294 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,405 software developers and data experts.

Read a plain file from XSLT 1.0

I'd like to read a one-line text file using an XSLT transformation.
I'm using libxslt, so I have to use XSLT 1.0.

This post:

http://www.stylusstudio.com/xsllist/...post50080.html

is promising, but I'm afraid I can't decipher it. Can anybody help?

Thanks,

Peter
Jun 27 '08 #1
2 6279
In article <f2**********************************@w7g2000hsa.g ooglegroups.com>,
ps******@googlemail.com <ps******@googlemail.comwrote:
>I'd like to read a one-line text file using an XSLT transformation.
I'm using libxslt, so I have to use XSLT 1.0.

This post:

http://www.stylusstudio.com/xsllist/...post50080.html

is promising, but I'm afraid I can't decipher it. Can anybody help?
Mike is suggesting that you create another, XML, file that includes
your text file as an entity.

Suppose hello.txt contains your text - "hello world" for example.
Create hello.xml containing

<!DOCTYPE foo [
<!ENTITY ent SYSTEM "hello.txt">
]>
<foo>&ent;</foo>

Then when you read foo.xml with the document function it will be as
if you had a file containing <foo>hello world</foo>. Of course,
you'll be in trouble if the file contains text that is ill-formed
XML.

As an extension to this idea, to save creating a separate file, you
could put an entity reference to the text file *in the xslt stylesheet
itself*, and use document("") to refer to the stylesheet. To do this
the name of the text file would have to be fixed.

-- Richard
--
:wq
Jun 27 '08 #2
The other solution is to find or create an extension function which will
read and return the text file's contents. The advantage of this approach
is that, since you're returning it as data, it doesn't have to be a
well-formed XML Document Fragment; it can contain unbalanced <, >, -,
and & characters.

Depending on the details of your processor -- and what your stylesheet
actually does with the data -- it might still have to respect XML 1.0's
limitations on the legal character set. Unless the extension also
implements some custom escaping solution like <my:char ucode="3095"/>.

But this involves carving a large path into dubiously-portable
solutions. A better answer might be to write a separate preprocessor
tool which reads that file and writes out a safely XMLified version,
dealing with all of these issues in some appropriate manner... and then
have your stylesheet read and process that XML.
Jun 27 '08 #3

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

Similar topics

16
by: Chuck Amadi | last post by:
Sorry to bovver you again (again) here's script. I still can't see why the get_payload() doesn't produce the plain text message body of an emails in the testwwws users mailbox. As you can see I...
3
by: pradeep gummi | last post by:
I have an XML FILE that is to be converted to Plain Text using an XSL file. Since I just want plain text, I do not want to set any root element during transformation.And if I do not any root...
2
by: Marcelo | last post by:
Hi Guys, I have the following question. I have a Xerox DJDE File that I want to convert to PDF.
7
by: JerryW | last post by:
I just reinstalled .NET 2003 (after repeated attempts to get ASP.NET Web Applications to work). I first did a complete uninstall of .NET 2003, .NET Framework 1.1, and IIS. I also completely deleted...
6
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory...
10
by: Stan R. | last post by:
Hi. I'm an old programmer whose been finally reading up on xml the past week. The concepts of xml, dtd, and xsl seem pretty straight forward to me. I understand that xsl (as xslt for...
3
by: realmerl | last post by:
Hi All. I'm trying to transform a html document into plain text via xslt. Simple you say! (i hope) I have got it working, by using the magnificent <xsl:value-of select="."/>. This returns the...
3
by: ManWithNoName | last post by:
Hi! I am trying to load files that contain non-standard (and non-English) characters (e.g. µ), and need some help in understanding how the XSLT document() function interprets non-standard (and...
2
by: saritha2008 | last post by:
Hi, As part of transforming one form of xml to another form, i need to do the below mentioned transformation: My Input XML: <rss> <channel> <item> <assignee...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.