TEXTAREA and XSL

Discussion in 'XML' started by Gadrin77, May 2, 2004.

  1. Gadrin77

    Gadrin77 Guest

    I noticed when displaying the contents of a CDATA node inside a
    TEXTAREA using
    MSXML and XSL, I get an extra space before the data.

    at first I thought I hadn't "tightened up" the XSL, but then even when
    I did
    this...

    <textarea rows="24" cols="80"><xsl:value-of
    select="/Root/Child/Data"/></textarea>

    I still got a leading whitespace. During testing the data is only the
    string "Unknown."

    Is this common to others?

    I noticed TEXTAREAs are a bit different when using XSL.

    I also noticed the string value you pass to an XSL parameter using
    ..addparameter of the IXSLProcessor can't handle large strings of data
    (it's about 3KB of data), to pass on and display inside the XSL.
     
    Gadrin77, May 2, 2004
    #1
    1. Advertising

  2. Gadrin77 wrote:

    > I noticed when displaying the contents of a CDATA node inside a
    > TEXTAREA using
    > MSXML and XSL, I get an extra space before the data.
    >
    > at first I thought I hadn't "tightened up" the XSL, but then even when
    > I did
    > this...
    >
    > <textarea rows="24" cols="80"><xsl:value-of
    > select="/Root/Child/Data"/></textarea>
    >
    > I still got a leading whitespace. During testing the data is only the
    > string "Unknown."
    >
    > Is this common to others?
    >
    > I noticed TEXTAREAs are a bit different when using XSL.


    You haven't told us which version of MSXML you use and how you transform.
    When I try the following ASP page with MSXML 4

    <%@ Language="VBScript" %>
    <%
    Option Explicit
    Dim XmlDocument, XslDocument, Loaded
    Set XmlDocument = Server.CreateObject("Msxml2.DOMDocument.4.0")
    XmlDocument.async = False
    Loaded = XmlDocument.load(Server.MapPath("test20040503.xml"))
    If Loaded Then
    Set XslDocument = Server.CreateObject("Msxml2.DOMDocument.4.0")
    XslDocument.async = False
    Loaded = XslDocument.load(Server.MapPath("test20040503Xsl.xml"))
    If Loaded Then
    XmlDocument.transformNodeToObject XslDocument, Response
    Else
    Response.Write "Error loading stylesheet.<br>" & VbCrLf
    End If
    Else
    Response.Write "Error loading XML file.<br>" & VbCrLf
    End If

    Set XmlDocument = Nothing
    Set XslDocument = Nothing

    %>

    to transform the following XML

    <?xml version="1.0" encoding="UTF-8"?>
    <root><![CDATA[Kibology for all.]]></root>

    with the following stylesheet that sets the output method to html

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

    <xsl:eek:utput method="html" encoding="UTF-8" />

    <xsl:template match="/">
    <html>
    <head>
    <title>textarea test</title>
    </head>
    <body>
    <form action="">
    <textarea rows="5" cols="80"><xsl:value-of select="root"
    /></textarea>
    </form>
    </body>
    </html>
    </xsl:template>

    </xsl:stylesheet>

    I do not get any leading spaces in the textarea, indeed the output of
    the ASP page is the following HTML:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>textarea test</title>
    </head>
    <body>
    <form action=""><textarea rows="5" cols="80">Kibology for
    all.</textarea></form>
    </body>
    </html>

    Maybe you are not using html as your output method??

    Even if I change the ASP page to use MSXML 3 (Msxml2.DOMDocument.3.0) I
    don't get any whitespace.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 3, 2004
    #2
    1. Advertising

  3. Gadrin77

    Gadrin77 Guest

    > You haven't told us which version of MSXML you use and how you transform.
    > When I try the following ASP page with MSXML 4
    >


    MSXML 4 SP2 I'm not using ASP, but rather a client app using MSIE 6.


    >
    > Maybe you are not using html as your output method??
    >


    no my output declaration does specifically say HTML, but the rest of the
    page is fine.

    normalize-space or something?

    okay just tried normalize-space and it strips the CRLF from the data, so
    forget that.

    just tried it with the output="html" declaration and I got the same thing
    as the original.

    I guess I can take care of it on the data side, where I trim any leading
    whitespace, but boy is this weird.
     
    Gadrin77, May 3, 2004
    #3
  4. Gadrin77 wrote:

    >>You haven't told us which version of MSXML you use and how you transform.
    >>When I try the following ASP page with MSXML 4
    >>

    >
    >
    > MSXML 4 SP2 I'm not using ASP, but rather a client app using MSIE 6.


    It is difficult to guess what could go wrong, maybe you can post some
    code or a URL so that we can see what goes on and where the white space
    comes from.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 4, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas S.

    XSL: textarea with xsl code???

    Thomas S., Feb 5, 2004, in forum: XML
    Replies:
    1
    Views:
    1,254
    Markus Spath
    Feb 5, 2004
  2. Replies:
    1
    Views:
    3,687
    A. Bolmarcich
    May 27, 2005
  3. Augustus
    Replies:
    1
    Views:
    397
    Ken Schaefer
    Sep 10, 2003
  4. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    362
    Anthony Jones
    Feb 5, 2006
  5. Replies:
    1
    Views:
    357
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page