[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to determine the end-of-line marker in unpars

Subject: Re: How to determine the end-of-line marker in unparsed-text?
From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2016 18:36:35 -0000
Re:  How to determine the end-of-line marker in  unpars
At 2016-05-09 17:40 +0000, David Carlisle d.p.carlisle@xxxxxxxxx wrote:
On 9 May 2016 at 18:17, Costello, Roger L. costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> I am writing an XSLT program to read unparsed-text. I want my program to work regardless of the end-of-line marker used by the unparsed-text.
>
> Here are the end-of-line markers that are typically used in files, I think:
>
> CR + LF
> LF
> CR
>...
I think it's usually better to just write the code so that it works
with any EOL marker, any such test as you suggest above will get
confused with the (not uncommon) case of files with inconsistent line
endings for example.


For example if you have a text file file.txt then

<xsl:param name="filelinest"
       select="tokenize(unparsed-text('file.txt'),'[\r\n]+')"/>

will give you a sequence of strings where any combination of U+000A or
U+000D counts as a separator.

True, bit it won't give you empty lines that are sequences of end-of-line sequences.


The regex I use for this purpose is:

<xsl:param name="filelinest"
           select="tokenize(unparsed-text('file.txt'),'\r?\n|\r')"/>

... which I'm pretty sure will give one empty lines when they exist.

. . . . . . Ken


-- Check our site for free XML, XSLT, XSL-FO and UBL developer resources | Streaming hands-on XSLT/XPath 2 training @US$45: http://goo.gl/Dd9qBK | Crane Softwrights Ltd. _ _ _ _ _ _ http://www.CraneSoftwrights.com/s/ | G Ken Holman _ _ _ _ _ _ _ _ _ _ mailto:gkholman@xxxxxxxxxxxxxxxxxxxx | Google+ blog _ _ _ _ _ http://plus.google.com/+GKenHolman-Crane/posts | Legal business disclaimers: _ _ http://www.CraneSoftwrights.com/legal |


--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.