Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2010, 02:34 PM
Registered User
 
Join Date: Jun 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Not able to parse text file using document().

Hi,

I am not able to parse a text file to output another text file using document().

When I keep the content of the text file somthing like "Hello" it works fine. However it throws an error for the below content:
CNN --- The Latest Updates
http://www.cnn.com/?nid=

Judge denies request to maintain deepwater drilling ban
http://www.cnn.com/2010/US/06/24/gul...ndex.html?nid=
New Orleans, Louisiana (CNN) -- Paving the way for deepwater drilling to resume in the Gulf of Mexico, a federal judge on Thursday denied a request to keep a moratorium in place pending a government appeal.

McCain to "Meet"
http://www.cnn.com/2010/US/06/24/gul...ndex.html?nid=
Senator to talk generals Sunday with Gregory. Plus: Panetta headlining “This Week.”

Three-State Tour
http://www.cnn.com/2010/US/06/24/gul...ndex.html?nid=


Error:
"XTDE1200: Failed to read input file"

Could you please suggest an idea how we can parse the possible content of text file to output another text file.

Please note: The text file which needs to be parsed are the external files (feeds in text format) whose contents are dynamic and may have special characters also.

Thanks,
avarma
 
Old June 24th, 2010, 03:55 PM
Registered User
 
Join Date: Jun 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Actually I tried with document() function but nothing gets displayed from the included text file, when I try using
unparsed-text(concat('filename.txt'), 'UTF-8') it throws the below error:
XTDE1200: Failed to read input file

Please provide some suggestion.

Thanks,
avarma
 
Old June 24th, 2010, 04:40 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The document() function can only be used to read XML. I'm surprised it's simply returning nothing: that is permitted behaviour with XSLT 1.0 but not with 2.0. What processor are you using?

The most likely reason for unparsed-text() giving an error is that you got the argument wrong. Incidentally your call on concat() should also have failed, because concat() requires two or more arguments. (With one argument, it's just pointless).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 24th, 2010, 04:54 PM
Registered User
 
Join Date: Jun 2010
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Michael,

I am using xslt 2.0

When I am using unparsed-text() it is failing because I have double quotes as special character in my included text file:
“This Week.”

Since the included text file will have dynamic content so it is not feasible to replace/ ignore the n number of special characters or html tags in it. So is there any other possible solution to handle html tags, special character, entity etc.. in this case.

Thanks,
avarma.
 
Old June 24th, 2010, 05:18 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

unparsed-text() should be able to read any text file, it should not fail because the file contains double-quote characters. The whole point is that it doesn't parse the contents of the file so it doesn't care what it contains. If you can demonstrate that it works when the file doesn't contain these characters, and fails when it does, then you should raise a bug with the vendor of your XSLT processor.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to Parse Query Text neha2007 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 June 13th, 2007 07:21 AM
parse a csv file shinny Pro Java 4 September 11th, 2006 06:26 AM
parse error xml load document asp.net academics2006 ASP.NET 1.0 and 1.1 Basics 0 March 13th, 2006 03:21 PM
data parse from text file mameworld Java Basics 1 January 14th, 2006 06:30 AM
Parse text files and save in sub directories malesd VB How-To 2 March 1st, 2004 09:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.