[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: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2016 17:40:04 -0000
Re:  How to determine the end-of-line marker in  unpars
On 9 May 2016 at 18:17, Costello, Roger L. costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi Folks,
>
> 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
>
> Below is code that I wrote to determine the end-of-line marker used in the unparsed-text. Is there a better way to determine the end-of-line marker?
>
> Note: $file is a variable that contains the unparsed-text.
>
> <xsl:variable name="end-of-line">
>         <xsl:choose>
>                 <!-- CR + LF (decimal 13 followed by decimal 10) -->
>                 <xsl:when test="contains($file, codepoints-to-string((13, 10)))">
>                         <xsl:value-of select="codepoints-to-string((13, 10))"/>
>                 </xsl:when>
>                 <!-- LF  (decimal 10) -->
>                 <xsl:when test="contains($file, codepoints-to-string(10))">
>                         <xsl:value-of select="codepoints-to-string(10)"/>
>                 </xsl:when>
>                 <!-- CR  (decimal 13) -->
>                 <xsl:when test="contains($file, codepoints-to-string(13))">
>                         <xsl:value-of select="codepoints-to-string(13)"/>
>                 </xsl:when>
>                 <!-- Perhaps the input file consists of just one line and there is no end-of-line marker!
>                              What would be an appropriate value in this situation? An error? -->
>                 <xsl:otherwise>
>                         <xsl:value-of select="error(QName('http://example.com/', 'EOL-err'), 'No end-of-line symbol')"/>
>                 </xsl:otherwise>
>         </xsl:choose>
> </xsl:variable>

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.