Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass HTML markup via parameters 1

Status
Not open for further replies.

rodic66

Programmer
Jan 19, 2005
3
US
Hi all,
I’ve stumbled across one problem, passing and displaying HTML markup via parameters.
Lets say I need to pass HTML string containing combo box to XSL and display it.

In JSP I set up parameters like this:
code:-------------------------------
Hashtable params = new Hashtable();
params.put("param1", value);
strCombo = “<select><option>Test Value</option></select>”;[/color red]
params.put("param2", strCombo);
--------------------------------------

in XSL I try to accept and display it:

code:---------------------------------
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:param name=" param1"></xsl:param>
<xsl:param name=" param2"></xsl:param>
<xsl:template match="/">
<xsl:copy-of select=”$param2”/>
</xsl:template>
</xsl:stylesheet>
------------------------------------------


and instead of combo box I see literal string print out,
I know that I’m on the rght path, because when I do this:


code:-----------------------------------
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput method="html"/>
<xsl:param name=" param1"></xsl:param>
<xsl:param name=" param2"><select><option>Test Value</option></select></xsl:param>
<xsl:template match="/">
<xsl:copy-of select=”$param2”/>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------

It will display combo box as it should. I’m definitely missing something, but what.
Please do not make suggestions like not passing HTML to XSL, it has to be like that, and that is that.
Thanks in advance
 
Have you tried creating an XML dom object and loading the string as XML and passing it as a parameter...

the way you are passing the param is as TEXT, which will be displayed as text...

This line is actually creating objects, not text...
<xsl:param name=" param2"><select><option>Test Value</option></select></xsl:param>

you should try either setting up the (msxml::DOMDocument) xml object and use the LoadXML method to load the text...

Or try using document.write to write the text as objects to the page...

something like:
Code:
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="html"/>
<xsl:param name="param1"></xsl:param>
<xsl:param name="param2"></xsl:param>
<xsl:template match="/">
  [b]<script>
    document.write '<xsl:value-of select="$param2"/>';
  </script>[/b]
</xsl:template>
</xsl:stylesheet>
Though, I'm not even sure that'll work... (actually I doubt it will, but I guess it's worth a try ;-))

Oh.. also, I'm not sure if it makes a difference but the quotes around $param2 in:
<xsl:copy-of select=”$param2”/>
Are not real quotes (")

You might try replacing them...

Good Luck...
-Josh

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks CubeE101,
<script>
document.write '<xsl:value-of select="$param2"/>';
</script>
would not work in my case, but I tried shove string to DOM object and pass it as a param - worked like a charm.
Thanks, good catch.
 
No problem, glad it worked for you...

Thanks for the star ;-)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top