[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Netscape XSL and ' charcter


Subject: RE: [xsl] Netscape XSL and ' charcter
From: "Deshpande, Gururaj" <gururaj.deshpande@xxxxxxxxxxxx>
Date: Tue, 9 Apr 2002 19:15:33 -0400

> [Deshpande, Gururaj]
> 
> > May be this is dumb question! Could you please tell me How can I
> > capture and save the output of the transform. I have only XSL and XML
> with
> > me and I am doing client transformation.
> >
> 
> Load the file into Mozilla.  After it has displayed, save it using the
> File/Save As menu item.  This will show you the HTML.  It may look a
> little
> strange since Mozilla adds some odd identifiers onto the element names,
> but
> your javascript will be visible in there.
> 
> With Internet Explorer, use View/Source instead.
> 
	[Gururaj]
	Your solutions don't work on both Netscape and IE. Both show XML
source file. When you say mozilla, I suppose it is not Netscape.
	I can't use Mozilla as I have to write code for IE and Netscape
only. 

	Viewing HTML is a possibility on IE by installing separate tool
available on MSDN.
	
http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/ms
dn-files/027/000/543/msdncompositedoc.xml    I don't know of any such tool
for Netscape. 

> > > > 2) How can I use   <xsl:attribute name="href">,  instead of your
> > > > solution.
> > > >
> 
> What I posted was not specific to Netscape.
> 
> To use xsl:attribute, what you had would proably have been OK once you
> fixed
> the errors and got everything nesting correctly - and got rid of the
> xsl:text.
> 
> Tom P
> 
> 
	[Gururaj]  

	I have number of points to make.
	
----------------------------------------------------------------------------
---------------------------

	I don't see any errors in XSL.  Now when I click on the hyperlink, I
get javascript error 'test not defined', which means that Netscape is not
able to find the javascript function. How do we call javascript function in
XSL file on Netscape?

	
----------------------------------------------------------------------------
----------------------

	Continuing our discussion......
	xsl:attribute does not work on Netscape because Netscape shows
&apos; instead of single quote. How do we tell Netscape to disable escaping?
	This following example does not work in Netscape but works in IE.
	<a>	<xsl:attribute name="href">
			javascript:test('<xsl:value-of select="prodxml"/>')
		</xsl:attribute><xsl:value-of select="equipmentno"/></a>
	</a>	
	
----------------------------------------------------------------------------
-------------------------------		
	I can do this in many ways on IE. All these methods work fine in IE
and execute the javascript.

	Method 1. (in this example I am using &quot; instead of &apos;)

	<a><xsl:attribute name="href">
			 <xsl:value-of
select="concat('javascript:test(&quot;',prodxml,'&quot;)')"/>
		 </xsl:attribute>
		<xsl:value-of select="equipmentno"/>
	</a>

	Method 2.  (repeating again)

	<a><xsl:attribute name="href">
			 javascript:test('<xsl:value-of select="prodxml"/>')
		 </xsl:attribute>
		<xsl:value-of select="equipmentno"/>
	</a>
	Method 3.

	<a><xsl:attribute name="href">
			 javascript:test(&apos;<xsl:value-of
select="prodxml"/>&apos;)
		 </xsl:attribute>
		<xsl:value-of select="equipmentno"/>
	</a>

	Method 4.

	<xsl:variable name="temp1">javascript:test('</xsl:variable>
	<xsl:variable name="temp2">')</xsl:variable>
	<a>
		<xsl:attribute name="href">
				<xsl:value-of
select="concat($temp1,prodxml,$temp2)"/>
		</xsl:attribute>
		<xsl:value-of select="equipmentno"/>
	</a>

	None of these methods work on Netscape. Why ? Netscape always
converts  '   to &apos; and what I get is
javascript:test(&apos;prod39.xml&apos;), but what I want is
javascript:test('prod39.xml')

	
----------------------------------------------------------------------------
--------------

	By the way, all my XSLs work fine in IE 5+ (MSXML 3) without any
problems. I am only trying to fine tune my XSLs for Netscape and that is
where I am having problems. What I am developing is a pure client only
solution using XML, XSL and javascript. I don't have any server support.
	I am pasting the XSL again for you point out where am I going wrong.


	
----------------------------------------------------------------------------
--------------

	Who is not following XML standards -- Is it IE or Netscape?!
	
----------------------------------------------------------------------------
-------------

	Thanks

	equipment.xsl
	
----------------------------------------------------------------------------
---------------------
	<?xml version='1.0' encoding="iso-8859-1"?>
	<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html"/>
	<xsl:template match="/">
	   <html>
	      <head>
	         <title></title>
	      </head>
		<SCRIPT language="JavaScript">
			<xsl:comment><![CDATA[
				function test(avalue) {
					alert(avalue);
				}
			]]></xsl:comment></SCRIPT>
	      <body>	
			<table border="0" width="95%" cellspacing="2"
cellpadding="0" align="center">
			<tr>
			    <td>Equipment No.</td>
			    <td>Description</td>
			    <td>Manufacture No.</td>
			    <td>Contract No.</td>
			</tr>
			<xsl:apply-templates select="plant/dept/eqpt"/> 
			</table>
	            	
	      </body>
	   </html>
	</xsl:template>
	<xsl:template match="plant/dept/eqpt">
		<xsl:for-each select=".">
			<xsl:sort select="equipmentno"/>
	        	<tr><td><a href="javascript:test('{prodxml}')">
					<xsl:value-of
select="equipmentno"/></a>
			    </td>
			    <td><xsl:value-of select="description"/></td>
			    <td><xsl:value-of select="manufactureno"/></td>
			    <td><xsl:value-of select="contractno"/></td>  
			</tr>
		</xsl:for-each>
	</xsl:template>
	</xsl:stylesheet>
	
----------------------------------------------------------------------------
---------------------------------------
	XML file 
	<?xml version="1.0" encoding="iso-8859-1"?>
	<?xml-stylesheet type="text/xsl" href="equipment.xsl"?>
	<plant>
	    <dept deptid="231" deptname="Drier Crusher Department"
deptno="010">
	        <eqpt eqptid="39">
	            <equipmentno>010.AS100</equipmentno>
	            <description>High-top airslide 300 12 200</description>
	            <contractno>99-20043</contractno>
	            <manufactureno>5.704620</manufactureno>
	            <pdb_number>20837</pdb_number>
	            <prodxml>prod39.xml</prodxml>
	        </eqpt>
	        <eqpt eqptid="38">
	            <equipmentno>010.AS200</equipmentno>
	            <description>Low-bottom airslide 200 12
100</description>
	            <contractno/>
	            <manufactureno/>
	            <pdb_number>20837</pdb_number>
	            <prodxml>prod38.xml</prodxml>
	        </eqpt>
	        <eqpt eqptid="37">
	            <equipmentno>010.AS300</equipmentno>
	            <description>No-bottom airslide 200 12 100</description>
	            <contractno/>
	            <manufactureno/>
	            <pdb_number>20837</pdb_number>
	            <prodxml>prod37.xml</prodxml>
	        </eqpt>
	    </dept>
	</plant>
	
----------------------------------------------------------------------------
------------------------------

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords