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 February 22nd, 2008, 03:40 PM
Registered User
 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing HTML in a Variable

I'm trying to store HTML in a Variable. I will process code, input info into the HTML and then pass it on... Here is an example:

Code:
      <xsl:when test="contains($string, '[URL]')">
        <xsl:variable name="contentBefore" select="substring-before($string, '')" />http://<br />
&nbsp;&nbsp;&nbsp;&nb...$string, '        ')" />
        <xsl:variable name="href" select="substring-before(substring-after($string, ''), '')" />
        <xsl:variable name="hyperlink">
          <a href="{$href}">
            <xsl:value-of select="$href" />
          </a>
        </xsl:variable>
        <xsl:call-template name="processContent">
          <xsl:with-param name="string" select="concat(concat($contentBefore, $hyperlink),$contentAfter)" />
        </xsl:call-template>
      </xsl:when>

...

  [Other Whens to Proccess other Tags]

...

      <xsl:otherwise>
        <xsl:value-of select="$string" />
      </xsl:otherwise>
I want to process a Code Tag and translate it into HTML Tag. Previously I set something similar up to where it processed each tag and displayed it as it processed, however, complications occur when several code Tags such as an image link consisting or url code tag and a img code tag would cause blank data to come out. Others such as bold color tags... which is bold tag and color tag... etc....

The code is processed and the value-of its posted... but none of the html is. so instead of getting:
Code:
<a href="nowhere/">nowhere</a>
I just get:
Code:
nowhere
Any ideas??

 
Old February 22nd, 2008, 03:51 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You've created a variable $hyperlink whose value is a tree of HTML nodes, and then you've supplied this as an argument to concat(). The concat() function converts the tree to a string, which is done by taking the text nodes and ignoring the elements. You seem to be imagining that this will serialize the tree of nodes as lexical XML - that's not what happens.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing data to a variable Mikect VB Databases Basics 1 April 16th, 2007 01:53 PM
storing Javascript variable to ASP variable rupen Classic ASP Basics 5 April 10th, 2007 07:06 AM
Storing an include in a variable trufla Beginning PHP 1 May 21st, 2006 10:52 PM
Getting oracle value and storing in xslt variable msj_vijay XSLT 0 December 29th, 2005 04:21 AM
Storing Value from Variable into Text File DaBigPolska Beginning VB 6 2 January 7th, 2005 05:34 PM





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