Subject: Re: document.write & copy-of From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 26 Oct 2000 17:32:26 +0100 |
Lee, > <xsl:element name="A"> > <xsl:attribute name="href"> > javascript:Popup=window.open('','IntlPopup','alwaysRaised=1,dependent=1,heig ht=300,location=0,menubar=1,personalbar=0,scrollbars=0,status=0,toolbar=0,wi dth=590,resizable=0'); > Popup.focus(); > Popup.document.write(' > <TABLE> > <xsl:copy-of select="tr"/> > </TABLE> > '); > </xsl:attribute> > Enlarge this table > </xsl:element> If you look at the code above, you'll see that you're setting the @href attribute on the generated A element to a string inside which (as far as the XSLT processor's concerned) you're creating a TABLE element, and a number of copies of other elements as well. XSLT processors justifiably won't let you put elements within attribute content: you have to escape the < and >. This means that you can't simply copy the tr elements across - you have to output them as serialised XML. I wrote this template earlier today for a similar problem: <xsl:template match="*" mode="serialise"> <xsl:text /><<xsl:value-of select="name()" /> <xsl:for-each select="@*"> <xsl:text> </xsl:text> <xsl:value-of select="name()" /> <xsl:text />="<xsl:value-of select="." />"<xsl:text /> </xsl:for-each> <xsl:text>></xsl:text> <xsl:apply-templates mode="serialise" /> <xsl:text /></<xsl:value-of select="name()" />><xsl:text /> </xsl:template> So, you can either replace the above with: <xsl:element name="A"> <xsl:attribute name="href"> javascript:Popup=window.open('','IntlPopup','alwaysRaised=1,dependent=1,heig ht=300,location=0,menubar=1,personalbar=0,scrollbars=0,status=0,toolbar=0,wi dth=590,resizable=0'); Popup.focus(); Popup.document.write(' <TABLE> <xsl:apply-templates select="tr" mode="serialise" /> </TABLE> '); </xsl:attribute> Enlarge this table </xsl:element> Or you can use CDATA sections so that you don't have to worry about escaping the < and > around the TABLE element: <xsl:element name="A"> <xsl:attribute name="href"> <![CDATA[javascript:Popup=window.open('','IntlPopup','alwaysRaised=1,depende nt=1,height=300,location=0,menubar=1,personalbar=0,scrollbars=0,status=0,too lbar=0,width=590,resizable=0'); Popup.focus(); Popup.document.write(' <TABLE>]]> <xsl:apply-templates select="tr" mode="serialise" /> <![CDATA[</TABLE> ');]]> </xsl:attribute> Enlarge this table </xsl:element> The resultant output will be: <A href="javascript:Popup=window.open('','IntlPopup','alwaysRaised=1,dependent= 1,height=300,location=0,menubar=1,personalbar=0,scrollbars=0,status=0,toolba r=0,width=590,resizable=0'); Popup.focus(); Popup.document.write(' <TABLE> <tr>...</tr> </TABLE> ');">Enlarge this table</A> but the Javascript processor will see the unescaped string: javascript:Popup=window.open('','IntlPopup','alwaysRaised=1,dependent=1,heig ht=300,location=0,menubar=1,personalbar=0,scrollbars=0,status=0,toolbar=0,wi dth=590,resizable=0'); Popup.focus(); Popup.document.write(' <TABLE> <tr>...</tr> </TABLE> '); and therefore 'do the right thing'. Or should, anyway. I hope that this helps, Jeni Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: document.write & copy-of, Mike Brown | Thread | Re: document.write & copy-of, Mike Brown |
Re: Saxon and MSXML3 differences, Jeni Tennison | Date | Re: How do I get the name of the cu, David Carlisle |
Month |