Subject: Re: [xsl] Weird behavior with attributes and > From: Mike Brown <mike@xxxxxxxx> Date: Fri, 31 Aug 2001 20:40:53 -0600 (MDT) |
Nesbitt, David wrote: > I need to generate JSP v1.0 (so I can't use the new JSP XML > representations). Here is what I have tried to do: > > <xsl:output method="html"/> > <xsl:variable name="open.expression"><![CDATA[<%= ]]></xsl:variable> > <xsl:variable name="close.expression"><![CDATA[ %>]]></xsl:variable> > . . . The CDATA sections are only a convenience for input so that you don't have to escape markup characters. It has exactly the same meaning as if escaped the markup characters and didn't wrap it in the CDATA tags. This would be more efficient for the processor: <xsl:variable name="open.expression" select="'<%= '"/> <xsl:variable name="open.expression" select="' >'"/> because it would create strings rather than result tree fragments. > <input> > <xsl:attribute name="type">hidden</xsl:attribute> > <xsl:attribute name="name"> > <xsl:value-of select="$open.expression" > disable-output-escaping="yes"/>javaName<xsl:value-of > select="$close.expression" disable-output-escaping="yes"/> > </xsl:attribute> > <xsl:attribute name="value"> > <xsl:value-of select="$open.expression" > disable-output-escaping="yes"/>javaValue<xsl:value-of > select="$close.expression" disable-output-escaping="yes"/> > <xsl:attribute name="value"> > </input> > > Unfortunately, the following gets created: > > <input type="hidden" name="<%= javaName %>" value="<%= javaValue > %>"> disable-output-escaping applies to the instructions that create text nodes, but if the instruction is creating the content template for xsl:attribute, the flag won't apply to the attribute node. XSLT doesn't allow for attributes to have their escaping disabled, so vendors have implemented their own solutions to this "problem". SAXON, for example, has a saxon:disable-output-escaping for xsl:attribute elements. A pure XSLT solution would involve some very ugly, but not impossible, simulation of element start and end tags using text nodes with disabled output escaping. - Mike ____________________________________________________________________________ mike j. brown, fourthought.com | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | personal: http://hyperreal.org/~mike/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Weird behavior with attribute, Nesbitt, David | Thread | [xsl] javascript & XSL, P Vikram |
RE: [xsl] javascript & XSL, Chris Bayes | Date | Re: [xsl] javascript & XSL, Mike Brown |
Month |