Problem with double quotes in xsl


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Problem with double quotes in xsl

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    5

    Problem with double quotes in xsl

    Hi, I am a web developer for a company in Greece and I came across with a problem with NO solution ( well no easy solution)

    The problem is:

    I have a text box in HTML and I am getting its contents from an XML document Eg.
    <input type="text" name="myText">
    <xsl:attrinbute name="value"><xsl:value-of select="Document/text"/></xsl:attribute>
    </input>
    The XML that is used is this:
    <Document>
    <text>
    -- A simple sentence "with" double quotes --
    </text>
    </Document>

    When I produce this output to my browser, within the textbox I get this value:
    -- A simple sentence
    Instead of -- A simple sentence "with" double quotes --

    The truth is that I can solve this problem with javascript but I donít have the time to start parsing the string for finding double quotes Is there any solution to this?

  2. #2
    Join Date
    Dec 2004
    Posts
    32
    Have you tried using disable-output-escaping="yes" on your value-of ?

  3. #3
    Join Date
    Feb 2005
    Posts
    5
    Hi alantin

    Yes i have tried that and nothing happened

    I have got the same output even when my XML is like this:
    <Document>
    <text>
    -- A simple sentence &quot;with&quot; double quotes --
    </text>
    </Document>

    or this:

    <Document>
    <text>
    <![CDATA[-- A simple sentence &quot;with&quot; double quotes --]]>
    </text>
    </Document>

    I think that the problem arise at the moment that the XSLT translates the contents of the <text> element.
    In other words when the XSLT converts the &quot; to " then this value is being strored in HTML like this:
    <input type="text" name="myText" value="-- A simple sentence "with" double quotes --"/>

    this line of code will produce a text box with this value:-- A simple sentence

  4. #4
    Nigel McFarlane is offline Former moderator, account closed
    Join Date
    Nov 2003
    Location
    I live on the 'net
    Posts
    229
    The only legal option for your XML document is to use &quot; so that's a start.
    Nigel McFarlane, Author: "Firefox Hacks", "Rapid Application Development with Mozilla"

  5. #5
    Join Date
    Feb 2005
    Posts
    5
    uuups!!!
    I found the problem.
    I am working for a company and i didnt realised that there were a piece of code that transform all the &amp; to & and all the &quot; to "
    Since these are being transformed then the generated HTML is the following:

    <input type="text" name="myText" value="-- A simple sentence "with" double quotes --"/>
    which is wrong

    Thanks guys for you replies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center