Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2007, 03:25 AM
Authorized User
 
Join Date: Oct 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default html part inside xml

Hi, i am trying to put a peace of xhtml inside xml for an ajax application. The problem i have is that my server script (php) sees the xhtml inside the xml as other xml. I think i need to wrap the xhtml node inside a CDATA tag but i cant seem to find out how. My xhtml gets generated by a xsl template. I convert one tag of the source into some xhtml like so :
Code:
<xsl:template match="status">
    <xsl:variable name="translations" select="$lang.vote/translations/info[lang($language)]" />
    <xsl:variable name="status" select="." />
    <xsl:variable name="message" select="$translations/status[@code=$status]" />
    <xsl:copy>
        <xsl:call-template name="statusText">
            <xsl:with-param name="status">
                <xsl:value-of select="$status" />
            </xsl:with-param>
            <xsl:with-param name="message">
                <xsl:value-of select="$message" />
            </xsl:with-param>
        </xsl:call-template>
    </xsl:copy>
</xsl:template>
i tried to add cdata-section-elements="status" to my xsl:output tag but that didn't do anything. I think i can put the cdata in my statusText template but that template also gets used by pages that don't use ajax. Any help would be apreciated. P.S. What i am trying to do is convert my xml to json, i found an xsl stylesheet that converts xml to json, but there i also had the same problem, so now i am trying to retrieve the xml in php and then use in php convert the xml to an array and then json_encode it, if this is isn't logical please give me an alternative :)

 
Old November 28th, 2007, 05:02 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I'd advise against trying to put xhtml inside another XML document as CDATA, it will lead to problems down the line. What exactly is the problem that you're experiencing?

--

Joe (Microsoft MVP - XML)
 
Old November 28th, 2007, 06:50 AM
Authorized User
 
Join Date: Oct 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well, i am trying to make an ajax page where i get the following xml: <status>1</status>. I want to convert the 1 to the following: <p style="#0000FF">success</p>. After that i want to output json so that my ajax.js can easily address the html to a div, if you know how to this an other way please advise me

 
Old November 28th, 2007, 08:18 AM
Authorized User
 
Join Date: Oct 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

my problem is kinda solved, i now use xml2json from google code to transform my xml into json, i now only send status and message (no html) through json and use the javascript to add the html, i think this will work for me, think xhtml in xml is indeed not such a good idee :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get html code for the selected part of the suryasimha General .NET 2 August 27th, 2007 02:32 PM
How to get html code for the selected part of the suryasimha ASP.NET 1.x and 2.0 Application Design 3 July 19th, 2007 12:00 PM
Rendering HTML inside XML through XSL - HELP !!! jilly XSLT 6 May 23rd, 2007 10:36 AM
viewing xml inside an html file Tomi XML 1 August 2nd, 2006 05:06 AM
put part of html in string DOM Dj Kat Javascript How-To 3 February 22nd, 2006 04:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.