Subject: RE: [xsl] XSL fragment within Javascript not-well formed!!!!! From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> Date: Wed, 26 May 2004 10:53:53 -0400 |
> From: Steve Brown [mailto:stevebrown@xxxxxxxxx] > Here is my trouble... > I would like to dynamically generate the test condition for a > 'when' element using javascript. But, I can't even get the > code below to work because the > "MSXML2.FreeThreadedDOMDocument.3.0" parser expects the > closing 'when' tag before the closing script tag. > > <script type="text/javascript"> > <![CDATA[document.write(']]><xsl:choose><xsl:when > test="FName='Steve'"><![CDATA[');]]> > </script> > The parser is closing the CDATA block when it finds the ']]>' in document.write. What follows is not well-formed, so the parser complains. I think you need to rethink your approach. Using javascript code to write html into a page can be fine, and generating that code using a stylesheet can be fine - I do both of them myself. But you rarely if ever need to use a CDATA block (and HTML does not understand CDATA), and you should always create complete nodes, not partial nodes. In your following post, you said you want to change contents of a table based on user selections,and when that happens the select lists need to change too. I suggest that you store that table data in javascript form, probably using lists and associative arrays,and use javascript within the page to rearrange the table and to reload the select lists using the stored data. You can have the stylesheet write the javascript *containing the data* into the page, but you won't need to change the styesheet and rerun it after that. This approach will be much easier to develop and maintain. You will be able to mock up the page by hand and get the javascript working right, separate from stylesheet development. And the results will work across more browsers and platforms than your current approach, which will apparently be limited to IE. Cheers, Tom P
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL fragment within Javas, Steve Brown | Thread | [xsl] Escape caracters, SMITH Neil |
[xsl] XSLT to SVG markup, David M Carriger | Date | RE: [xsl] CDATA elements in XSLT, Dario Romero |
Month |