xsl-list
[Top] [All Lists]

[xsl] difficulty using xsl:analyze-string

2018-07-18 00:34:00
Hi all,
   I'm trying to run a small XSLT 2.0 stylesheet, using Saxon-EE 9.7.0.19
embedded in Oxygen XML Editor. I'm having some difficulty using
the xsl:analyze-string instruction.

My current XSLT 2.0 transform is,

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                         version="2.0">

    <xsl:output method="html"/>

    <xsl:template match="/">
        <html>
          <head>
             <title>test</title>
          </head>
          <body>
              <xsl:analyze-string select="'hello world\nexperimenting with
XSLT\nhow are you'" regex="\n">
                  <xsl:matching-substring>
                      <br/>
                  </xsl:matching-substring>
                  <xsl:non-matching-substring>
                      <xsl:value-of select="."/>
                  </xsl:non-matching-substring>
              </xsl:analyze-string>
          </body>
        </html>
    </xsl:template>

</xsl:stylesheet>

The above XSLT transform doesn't take any other XML input. I'm current
having the above XSLT stylesheet as an input XML (which is a dummy XML
input) to the transform.

As you can see, the xsl:analyze-string's select attribute has a hard-coded
string.

I'm expecting an output like following, from the transform,

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>test</title>
   </head>
   <body>hello world<br/>experimenting with XSLT<br/>how are you</body>
</html>

(i.e \n replaced with <br/>)

But instead I'm getting following output,

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>test</title>
   </head>
   <body>hello world\nexperimenting with XSLT\nhow are you</body>
</html>

(the input string is not broken as per the semantics of xsl:analyze-string)

Any help to resolve this would be great.



-- 
Regards,
Mukul Gandhi
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>