Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 28th, 2007, 02:25 AM
Authorized User
 
Join Date: Oct 2007
Location: , , .
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 :)

Reply With Quote
  #2 (permalink)  
Old November 28th, 2007, 04:02 AM
joefawcett's Avatar
Wrox Author
Points: 9,716, Level: 42
Points: 9,716, Level: 42 Points: 9,716, Level: 42 Points: 9,716, Level: 42
Activity: 9%
Activity: 9% Activity: 9% Activity: 9%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,067
Thanks: 1
Thanked 37 Times in 36 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)
Reply With Quote
  #3 (permalink)  
Old November 28th, 2007, 05:50 AM
Authorized User
 
Join Date: Oct 2007
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old November 28th, 2007, 07:18 AM
Authorized User
 
Join Date: Oct 2007
Location: , , .
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 :)

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03:28 AM



All times are GMT -4. The time now is 04:00 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.