Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:55:30+00:00 2026-05-30T06:55:30+00:00

How do I make the unparsed-text-lines() function effectively available to both XSLT 2.0 and

  • 0

How do I make the unparsed-text-lines() function effectively available to both XSLT 2.0 and XSLT 3.0 processors in the one style-sheet?

I thought that I could use the function-available() function like so, but this returns a syntax error for an XSLT 2.0 processor.

<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:fn="http://www.w3.org/2005/xpath-functions" 
  xmlns:local="local" 
  version="2.0" exclude-result-prefixes="xs fn local">

<xsl:function name="local:unparsed-text-lines" as="xs:string+">
 <xsl:param name="href" as="xs:string" />
 <xsl:choose>
  <xsl:when test="function-available('fn:unparsed-text-lines')">
   <!-- XSLT 3.0 -->
   <xsl:sequence select="fn:unparsed-text-lines($href)" />
  </xsl:when>
  <xsl:otherwise>
   <!-- XSLT 2.0 -->
   <xsl:sequence select="fn:tokenize(fn:unparsed-text($href), '\r\n|\r|\n')[not(position()=last() and .='')]" />
  </xsl:otherwise>
 </xsl:choose>
</xsl:function>

etc.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:55:31+00:00Added an answer on May 30, 2026 at 6:55 am

    The problem is:

    <xsl:when>

    is a run-time operator, and the compiler doesn’t know at compile time that its result will be true() or false().

    Solution: Use the use-when attribute.

    The transformation becomes something like this:

    <xsl:stylesheet
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:local="local"
          version="2.0" exclude-result-prefixes="xs local">
    
        <xsl:function name="local:unparsed-text-lines" as="xs:string+">
         <xsl:param name="href" as="xs:string" />
           <xsl:sequence select="fn:unparsed-text-lines($href)"
                 use-when="function-available('unparsed-text-lines')" />
           <xsl:sequence use-when="not(function-available('unparsed-text-lines'))"
            select="tokenize(unparsed-text($href), '\r\n|\r|\n')
                        [not(position()=last()
                            and
                              .=''
                            )
                        ]" />
        </xsl:function>
    </xsl:stylesheet>
    

    and now no error is raised.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I make code to display multiple pages (max. 5 lines/page) with persons from one
I make a j2me application that almost all of it, are text files. size:
To make a JavaScript class with a public method I'd do something like: function
I make some script, that have modal window on fancybox and on load it's
I make multiple queries to my DB from my python code that uses pyodbc
make order portfolie contacts vacancies about company I add style for it in jquery-script:
Want make a mind map like the following: Image link is not available anymore.
I make one action method for 2 activities (new input and edit), and there
Make javaScript and CSS External Source . Does that mean I should use JavaScript
I make a distributed embedded application that will make use of several micro-controllers. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.